:: commit 6c22743c7ec2b2c35b25698d368d1c8427afc96b

mintsuki <mintsuki@protonmail.com> — 2021-03-06 05:02

parents: 249d058931

Do not build necessary gnu-efi dependencies using the host compiler, use our toolchain instead

diff --git a/Makefile b/Makefile
index 6cd99174..2a6fa394 100644
--- a/Makefile
+++ b/Makefile
@@ -68,11 +68,12 @@ test-clean:
 	rm -rf test_image test.hdd test.iso
 
 toolchain:
-	./make_toolchain.sh ./toolchain -j`nproc`
+	scripts/make_toolchain.sh "`realpath ./toolchain`" -j`nproc`
 
 gnu-efi:
 	git clone https://git.code.sf.net/p/gnu-efi/code --branch=3.0.12 --depth=1 $@
-	$(MAKE) -C gnu-efi
+	$(MAKE) -C gnu-efi/gnuefi CC=x86_64-elf-gcc AR=x86_64-elf-ar
+	$(MAKE) -C gnu-efi/lib CC=x86_64-elf-gcc ARCH=x86_64 x86_64/efi_stub.o
 
 ovmf:
 	mkdir -p ovmf
diff --git a/make_toolchain.sh b/scripts/make_toolchain.sh
similarity index 91%
rename from make_toolchain.sh
rename to scripts/make_toolchain.sh
index 86dc2b9c..dead1d56 100755
--- a/make_toolchain.sh
+++ b/scripts/make_toolchain.sh
@@ -76,3 +76,5 @@ cd build-gzip
 make
 make install
 cd ..
+
+wget 'https://github.com/managarm/mlibc/raw/1f84a68500a2939f8dccd4083f8c111b2610cba6/options/elf/include/elf.h' -O "$PREFIX/lib/gcc/x86_64-elf/$GCCVERSION/include/elf.h"
diff --git a/stage23/Makefile b/stage23/Makefile
index f0dd8422..d76b9590 100644
--- a/stage23/Makefile
+++ b/stage23/Makefile
@@ -124,9 +124,9 @@ limine.elf: $(OBJ) font.o sys/smp_trampoline.o limine.map.o
 limine_efi.elf: $(OBJ) font.o sys/smp_trampoline.o
 	$(LD) -shared -Bsymbolic \
 		-T../gnu-efi/gnuefi/elf_x86_64_efi.lds \
-		../gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o \
-		../gnu-efi/x86_64/gnuefi/libgnuefi.a \
-		../gnu-efi/x86_64/lib/x86_64/efi_stub.o \
+		../gnu-efi/gnuefi/crt0-efi-x86_64.o \
+		../gnu-efi/gnuefi/libgnuefi.a \
+		../gnu-efi/lib/x86_64/efi_stub.o \
 		$(OBJ) font.o sys/smp_trampoline.o -o $@
 
 -include $(HEADER_DEPS)
tab: 248 wrap: offon