SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.69k stars 3.19k forks source link

FreeBSD build problems #13899

Open dansimonm opened 2 years ago

dansimonm commented 2 years ago

I'm having some issues with Meta/serenity.sh run in FreeBSD 13.0-RELEASE-p11:

FAILED: CMakeFiles/LangomCore.dir/home/dan/iso/aos/serenity/Userland/Libraries/LibCore/DateTime.cpp.o ... /home/dan/iso/aos/serenity/Userland/Libraries/LibCore/DateTime.cpp:254:39; error: 'daylight' was not declared in this scope 254 | builder.append(tzname[daylight]); ...

It could be related to this FreeBSD bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241978 (it works in OpenBSD 7.1 btw; I will recheck this when FreeBSD 13.1 comes out, maybe it will be fixed then!)

PS: Side point, you need texinfo as a dependency to build the toolchain!

dansimonm commented 2 years ago

Nope, same issue with the recent FreeBSD 13.1 release. At least on my ThinkPad X280 running FreeBSD 13.1-RELEASE GENERIC amd64. I have also tried setting UTC as my timezone, rather then my local Europe/Oslo timezone, but I get the same error non the less. Has anyone managed to run SerenityOS on the recent 13 branch of FreeBSD?

hoanga commented 2 years ago

hello, i made a little more progress in getting a build to run on freebsd 13.1 (with the following freebsd-patches-for-serenityos.zip ) here are the extra steps i needed to add to get this to build:

serenity has troubles compiling inside of a freebsd jail because of some of the prerequisite packages, so would suggest either on hardware or inside of a vm.

this gets through the compiling successfully and can even build an image but ran into some issues running the image:

0.877 [#0 init_stage2(1:1)]: IDE controller @ PCI [0000:00:01:01]: ISA Compatibility mode-only controller, supports bus mastering
0.877 [#0 init_stage2(1:1)]: IDE controller @ PCI [0000:00:01:01]: primary channel DMA capable? 0
0.877 [#0 init_stage2(1:1)]: IDE controller @ PCI [0000:00:01:01]: secondary channel DMA capable? 0
0.888 [#0 init_stage2(1:1)]: IDEChannel: Primary master ATA device found: Name=QEMU HARDDISK, Capacity=754116096, Capabilities=0x0b00
0.895 [#0 init_stage2(1:1)]: Trying to unregister unused handler (?)
0.899 [#0 init_stage2(1:1)]: Trying to unregister unused handler (?)
0.903 [init_stage2(1:1)]: PCI [0000:03:01:00]: AHCI controller reset
0.903 [#0 init_stage2(1:1)]: PCI [0000:03:01:00]: AHCI command list entries count - 32
0.910 [init_stage2(1:1)]: AHCI Port 1: Device not detected, Phy not enabled
0.915 [init_stage2(1:1)]: AHCI Port 2: Device not detected, Phy not enabled
0.915 [init_stage2(1:1)]: AHCI Port 3: Device not detected, Phy not enabled
0.918 [init_stage2(1:1)]: AHCI Port 4: Device not detected, Phy not enabled
0.918 [init_stage2(1:1)]: AHCI Port 5: Device not detected, Phy not enabled
0.918 [init_stage2(1:1)]: AHCI Port 6: Device not detected, Phy not enabled
0.941 [#0 init_stage2(1:1)]: Master Boot Record: invalid signature
0.945 [#0 init_stage2(1:1)]: Master Boot Record: invalid signature
1.005 [init_stage2(1:1)]: VirtualFileSystem: mounted root from Ext2FS (device:3,0)
1.017 [init_stage2(1:1)]: Write-protected kernel symbols after init.
1.021 [init_stage2(1:1)]: Unmapped 1792 KiB of kernel text after init! :^)
1.039 [#0 init_stage2(1:1)]: Failed to exec /bin/SystemServer: Error(errno=2)
[init_stage2(1:1)]: KERNEL PANIC! :^(
[init_stage2(1:1)]: init_stage2: Error spawning init process: Error(errno=2)
[init_stage2(1:1)]: at ./Kernel/init.cpp:386 in void Kernel::init_stage2(void*)
[init_stage2(1:1)]: Kernel + 0x00d21551  Kernel::__panic(char const*, unsigned int, char const*) +0xf1
[init_stage2(1:1)]: Kernel + 0x010b8d14  Kernel::init_stage2(void*) +0x17e4
[init_stage2(1:1)]: Kernel + 0x010ffe50  exit_kernel_thread +0x0

if the changes look like they might be acceptable, then i can try to clean them up for a pr.

ADKaster commented 2 years ago

@hoanga Those two diffs looks straightforward.

I'm not sure about the datetime one. It would probably be better to come up with a way to actually format the current timezone name for FreeBSD?

For the mount one, it looks like doing a privelidged mount operation doesn't work on FreeBSD then? In that case, a solution that recommends the fuse2fs package would probably work better?

It looks like from your output that the root filesystem image was not actually created, or the SystemServer binary was not actually installed into the created _disk_image ?

I would recommend opening a pull request with your patches and some documentation updates to https://github.com/SerenityOS/serenity/blob/master/Documentation/BuildInstructionsOther.md#freebsd-prerequisites so we can discuss the right path for claiming some kind of freebsd host support there.

hoanga commented 2 years ago

hi @ADKaster, thanks for the comments!

for the datetime, it probably would be better in the long run to have a formatted timezone name although i do not have any suggestions on how that would work at present. i will try to give it some thought when/if i get some time.

for the mount operation, i think the problem was that the unmount was not too happy for some reason which ended up interrupting the creation of the root filesystem image. the fuse option is probably the way to go for freebsd. after a little more fiddling i was able to get a generated root filesystem and builds are in a better shape for freebsd from what i can see.

i have setup a pr here that incorporates the patches i posted up earlier and includes an extra update to handle the case that freebsd doesn't have prctl as well as include a documentation update.

iah commented 2 years ago

I made a complete new git clone and build on FreeBSD without any issues. First try though got an unknown error for not being root. Ran again with success. But it feel completely sluggish.

The first error I encountered: unmounting filesystem... umount: unmount of /usr/home/isak/src/serenityos/serenity/Build/x86_64/mnt failed: Device busy umount: unmount of /usr/home/isak/src/serenityos/serenity/Build/x86_64/mnt failed: Device busy die: this script needs to run as root FAILED: CMakeFiles/qemu-image _disk_image /home/isak/src/serenityos/serenity/Build/x86_64/CMakeFiles/qemu-image /home/isak/src/serenityos/serenity/Build/x86_64/_disk_image cd /home/isak/src/serenityos/serenity/Build/x86_64 && /usr/local/bin/cmake -E env SERENITY_SOURCE_DIR=/home/isak/src/serenityos/serenity SERENITY_ARCH=x86_64 SERENITY_TOOLCHAIN=GNU LLVM_VERSION=12.1.0 /home/isak/src/serenityos/serenity/Meta/build-image-qemu.sh ninja: build stopped: subcommand failed.

As a side note I ran rebuild-toolchain with the x96_64 argument and also the run command with the same argument.