diff --git a/generate_build.py b/generate_build.py index 4db01b9..ca95643 100755 --- a/generate_build.py +++ b/generate_build.py @@ -14,9 +14,9 @@ MODULES = { "makerd": program('src/tools/makerd', ["initrd", "kutil"], "makerd", ["native"]), - "nulldrv": program('src/drivers/nulldrv', [], "nulldrv", ["host"]), + "boot": program('src/boot', [], "boot.elf", ["boot"]), - "boot": program('src/boot', ["elf"], "boot.elf", ["host"]), + "nulldrv": program('src/drivers/nulldrv', [], "nulldrv", ["host"]), "kernel": program('src/kernel', ["elf", "initrd", "kutil"], "popcorn.elf", ["host"]), } diff --git a/scripts/templates/build.ninja.j2 b/scripts/templates/build.ninja.j2 index 5ecede4..bbfc9bd 100644 --- a/scripts/templates/build.ninja.j2 +++ b/scripts/templates/build.ninja.j2 @@ -65,7 +65,7 @@ rule nasm rule exe description = Linking $name - command = $ld -o $out $in $libs + command = $ld $ldflags -o $out $in $libs rule lib description = Archiving $name @@ -127,7 +127,7 @@ build $builddir/popcorn.fat : cp $srcroot/assets/ovmf/x64/OVMF.fd build $builddir/fatroot/popcorn.elf : cp $builddir/host/popcorn.elf name = kernel to FAT image -build $builddir/fatroot/efi/boot/bootx64.efi : cp $builddir/host/boot.efi +build $builddir/fatroot/efi/boot/bootx64.efi : cp $builddir/boot/boot.efi name = bootloader to FAT image build $builddir/fatroot/initrd.img : makerd ${srcroot}/assets/initrd.toml | $ diff --git a/scripts/templates/program.boot.ninja.j2 b/scripts/templates/program.boot.ninja.j2 index a6bf7f9..c3a807e 100644 --- a/scripts/templates/program.boot.ninja.j2 +++ b/scripts/templates/program.boot.ninja.j2 @@ -2,7 +2,11 @@ {% block variables %} {{ super() }} -cflags = $cflags $ +ld = ld +cc = clang +cxx = clang++ + +ccflags = $ccflags $ -DKERNEL_FILENAME=L\"popcorn.elf\" $ -DGNU_EFI_USE_MS_ABI $ -DHAVE_USE_MS_ABI $ @@ -12,8 +16,8 @@ cflags = $cflags $ -fshort-wchar ldflags = $ldflags $ - -shared $ - -T ${srcroot}/src/arch/x86_64/boot.ld + -T ${srcroot}/src/arch/x86_64/boot.ld $ + -shared {% endblock %} diff --git a/scripts/templates/program.kernel.ninja.j2 b/scripts/templates/program.kernel.ninja.j2 index 38a0a3d..54fecb3 100644 --- a/scripts/templates/program.kernel.ninja.j2 +++ b/scripts/templates/program.kernel.ninja.j2 @@ -3,7 +3,7 @@ {{ super() }} asflags = $asflags -I${srcroot}/src/kernel/ -libs = $libs -lc +libs = $libs ldflags = $ldflags -T ${srcroot}/src/arch/x86_64/kernel.ld {% endblock %} diff --git a/scripts/templates/target.boot.ninja.j2 b/scripts/templates/target.boot.ninja.j2 new file mode 100644 index 0000000..3334a91 --- /dev/null +++ b/scripts/templates/target.boot.ninja.j2 @@ -0,0 +1,35 @@ +{% extends "target.default.ninja.j2" %} + +{% block binaries %} +ld = ld +cc = clang +cxx = clang++ +nasm = nasm +{% endblock %} + +{% block variables %} + +ccflags = $ccflags $ + -ggdb $ + -nostdlib $ + -ffreestanding $ + -nodefaultlibs $ + -fno-builtin $ + -mno-sse $ + -fno-omit-frame-pointer $ + -mno-red-zone + +cxxflags = $cxxflags $ + -nostdlibinc $ + -isystem${srcroot}/sysroot/include/c++/v1 $ + -fno-exceptions $ + -fno-rtti + +ldflags = $ldflags $ + -g $ + -nostdlib $ + -znocombreloc $ + -Bsymbolic $ + -nostartfiles + +{% endblock %} diff --git a/scripts/templates/target.host.ninja.j2 b/scripts/templates/target.host.ninja.j2 index 527a73d..53e7eba 100644 --- a/scripts/templates/target.host.ninja.j2 +++ b/scripts/templates/target.host.ninja.j2 @@ -35,7 +35,6 @@ ldflags = $ldflags $ -nostdlib $ -nostartfiles $ -znocombreloc $ - -Bsymbolic $ -nostartfiles {% endblock %}