Closed redstonedash closed 2 years ago
I think it has something to do with building limine? The only thing I can make from looking it up is the -no-pie -fno-pie and -fno-pic might help but the command the compiles limine excludes those commands
Try replacing the -fno-pic
flag with -fno-PIC
; should that fail, you will either need to use a cross compiler (for x86_64-elf
target) or you can use WSL if you're on Windows 10/11.
Alright, I followed the cross compiler instructions linked on the README and I get this output
username@ARK /cygdrive/c/Users/username/OSDev
$ make CC=$TARGET-gcc
git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
Cloning into 'limine'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 17 (delta 3), reused 7 (delta 1), pack-reused 0
Receiving objects: 100% (17/17), 410.04 KiB | 8.20 MiB/s, done.
Resolving deltas: 100% (3/3), done.
make -C limine
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/limine'
i686-elf-gcc -g -O2 -pipe -Wall -Wextra -std=c99 -D__USE_MINGW_ANSI_STDIO limine-version.c -o limine-version
limine-version.c:1:10: fatal error: stdio.h: No such file or directory
1 | #include <stdio.h>
| ^~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:45: limine-version] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/limine'
make: *** [GNUmakefile:29: limine] Error 2
I have a few more things I'm going to try.
Okay the other thing i was going to try was to compile limine with just CC and then compile the kernel with the cross compiler
username@ARK /cygdrive/c/Users/username/OSDev
$ make distclean
rm -rf iso_root barebones.iso barebones.hdd
make -C kernel clean
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/kernel'
rm -rf kernel.elf ./kernel.o ./kernel.d
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/kernel'
rm -rf limine ovmf-x64
make -C kernel distclean
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/kernel'
rm -rf kernel.elf ./kernel.o ./kernel.d
rm -f limine.h
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/kernel'
username@ARK /cygdrive/c/Users/username/OSDev
$ make limine
git clone https://github.com/limine-bootloader/limine.git --branch=v3.0-branch-binary --depth=1
Cloning into 'limine'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 17 (delta 3), reused 7 (delta 1), pack-reused 0
Receiving objects: 100% (17/17), 410.04 KiB | 4.14 MiB/s, done.
Resolving deltas: 100% (3/3), done.
make -C limine
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/limine'
cc -g -O2 -pipe -Wall -Wextra -std=c99 -D__USE_MINGW_ANSI_STDIO limine-version.c -o limine-version
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/limine'
username@ARK /cygdrive/c/Users/username/OSDev
$ make CC=$TARGET-gcc
make -C kernel
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/kernel'
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -o limine.h
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9993 100 9993 0 0 41629 0 --:--:-- --:--:-- --:--:-- 41811
i686-elf-gcc -O2 -g -Wall -Wextra -Wpedantic -pipe -I. -std=c11 -ffreestanding -fno-stack-protector -fno-stack-check -fno-pie -fno-pic -m64 -march=x86-64 -mabi=sysv -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -MMD -c kernel.c -o kernel.o
cc1: error: code model 'kernel' not supported in the 32 bit mode
cc1: sorry, unimplemented: 64-bit mode not compiled in
make[1]: *** [GNUmakefile:89: kernel.o] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/kernel'
make: *** [GNUmakefile:33: kernel] Error 2
Maybe I followed the instructions too closely. I was compiling for i686 elf. I will try again with x86_64-elf as the target
Okay. after redoing everything to compile for x86_64,
redstonedash@ARK /cygdrive/c/Users/redstonedash/OSDev
$ make cc=$TARGET-gcc
make -C kernel
make[1]: Entering directory '/cygdrive/c/Users/redstonedash/OSDev/kernel'
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -o limine.h
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9993 100 9993 0 0 44055 0 --:--:-- --:--:-- --:--:-- 44216
cc -O2 -g -Wall -Wextra -Wpedantic -pipe -I. -std=c11 -ffreestanding -fno-stack-protector -fno-stack-check -fno-pie -fno-pic -m64 -march=x86-64 -mabi=sysv -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -MMD -c kernel.c -o kernel.o
cc1: error: code model kernel does not support PIC mode
make[1]: *** [GNUmakefile:89: kernel.o] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/redstonedash/OSDev/kernel'
make: *** [GNUmakefile:33: kernel] Error 2
I can try again with WSL but i feel like this should work. what version of GCC do you use?
cc=
should be uppercase...
Ah, my bad. It says it doesn't recognize the option -z
username@ARK /cygdrive/c/Users/username/OSDev
$ make CC=$TARGET-gcc
make -C kernel
make[1]: Entering directory '/cygdrive/c/Users/username/OSDev/kernel'
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -o limine.h
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9993 100 9993 0 0 48087 0 --:--:-- --:--:-- --:--:-- 48275
x86_64-elf-gcc -O2 -g -Wall -Wextra -Wpedantic -pipe -I. -std=c11 -ffreestanding -fno-stack-protector -fno-stack-check -fno-pie -fno-pic -m64 -march=x86-64 -mabi=sysv -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -MMD -c kernel.c -o kernel.o
ld ./kernel.o -nostdlib -static -z max-page-size=0x1000 -T linker.ld -o kernel.elf
ld: unrecognized option '-z'
ld: use the --help option for usage information
make[1]: *** [GNUmakefile:82: kernel.elf] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/username/OSDev/kernel'
make: *** [GNUmakefile:33: kernel] Error 2
Because you also need to pass LD=$TARGET-ld
Thank you. Maybe it should be noted that CC with Cygwin will not work (I assume because it's trying to build a windows executable, which is why the -z command is not present). Other than that most of this thread is just me demonstrating my incompetence on unix systems
Running the make command on cygwin i get the following output
I would provide more information but I'm not really sure what else to include