babbleberry / rpi4-osdev

Tutorial: Writing a "bare metal" operating system for Raspberry Pi 4
https://www.rpi4os.com
Creative Commons Zero v1.0 Universal
3.37k stars 246 forks source link

Part 2: Build error: Unable to disambiguate -nostartfiles #16

Closed SabeehKhan18 closed 2 years ago

SabeehKhan18 commented 2 years ago

Using WSL for emulating ubuntu, I downloaded and unpacked the latest x86_64 Linux hosted cross compilers (gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz). After editing the makefile from part 2-building to point to my compiler directory, I got the following error:

/bin/rm kernel8.elf .o .img > /dev/null 2> /dev/null || true ../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles -c boot.S -o boot.o ../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles -c kernel.c -o kernel.o ../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-ld -nostdlib -nostartfiles boot.o kernel.o -T link.ld -o kernel8.elf ../gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-ld: Error: unable to disambiguate: -nostartfiles (did you mean --nostartfiles ?) make: *** [makefile:15: kernel8.img] Error 1

Changing -nostartfiles to --nostartfiles on the ld command resulted in unrecognized option '--nostartfiles'

Removing -nostartfiles resulted in a successful build, but I have not yet executed the image. Should this tag option be removed?

Thank you for your help and guidance!

babbleberry commented 2 years ago

Thanks for sharing this - I'll work to reproduce and test the generated image without the tag. I'll also see if there's a reason this tag has been deprecated or what it has been replaced with!

babbleberry commented 2 years ago

OK, it seems like ld no longer ignores erroneous command line arguments. nostartfiles is a gcc argument, not an ld argument - it was my mistake, but has only been picked up with the latest Arm drop of gcc.

So you can safely remove -nostartfiles. I've updated the repo to reflect this. Really grateful for you bringing it to my attention!

Please close this issue if you're happy it's resolved.

All the best, Adam

SabeehKhan18 commented 2 years ago

Thank you so much! I was worried I was doing something wrong.