build: Restore WERROR_FLAG to nasm calls, add NASMFLAGS_FOR_TARGET

This commit is contained in:
mintsuki 2024-07-25 09:45:40 +02:00
parent 3fd16ba98c
commit caf80b196a
5 changed files with 38 additions and 17 deletions

View File

@ -111,6 +111,9 @@ export CPPFLAGS_FOR_TARGET
override DEFAULT_LDFLAGS_FOR_TARGET := @LDFLAGS_FOR_TARGET@
$(eval $(call DEFAULT_VAR,LDFLAGS_FOR_TARGET,$(DEFAULT_LDFLAGS_FOR_TARGET)))
export LDFLAGS_FOR_TARGET
override DEFAULT_NASMFLAGS_FOR_TARGET := @NASMFLAGS_FOR_TARGET@
$(eval $(call DEFAULT_VAR,NASMFLAGS_FOR_TARGET,$(DEFAULT_NASMFLAGS_FOR_TARGET)))
export NASMFLAGS_FOR_TARGET
override LIMINE_VERSION := @PACKAGE_VERSION@
@ -210,12 +213,12 @@ uninstall:
$(call MKESCAPE,$(BUILDDIR))/stage1.stamp: $(STAGE1_FILES) $(call MKESCAPE,$(BUILDDIR))/decompressor-build/decompressor.bin $(call MKESCAPE,$(BUILDDIR))/common-bios/stage2.bin.gz
$(MKDIR_P) '$(call SHESCAPE,$(BINDIR))'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/hdd' && nasm bootsect.asm -Wall -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-bios-hdd.bin'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/hdd' && nasm bootsect.asm -Wall -w-reloc $(WERROR_FLAG) -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-bios-hdd.bin'
ifneq ($(BUILD_BIOS_CD),no)
cd '$(call SHESCAPE,$(SRCDIR))/stage1/cd' && nasm bootsect.asm -Wall -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-bios-cd.bin'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/cd' && nasm bootsect.asm -Wall -w-reloc $(WERROR_FLAG) -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-bios-cd.bin'
endif
ifneq ($(BUILD_BIOS_PXE),no)
cd '$(call SHESCAPE,$(SRCDIR))/stage1/pxe' && nasm bootsect.asm -Wall -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-bios-pxe.bin'
cd '$(call SHESCAPE,$(SRCDIR))/stage1/pxe' && nasm bootsect.asm -Wall -w-reloc $(WERROR_FLAG) -fbin -DBUILDDIR="'"'$(call NASMESCAPE,$(BUILDDIR))'"'" -o '$(call SHESCAPE,$(BINDIR))/limine-bios-pxe.bin'
endif
cp '$(call SHESCAPE,$(BUILDDIR))/common-bios/limine-bios.sys' '$(call SHESCAPE,$(BINDIR))/'
touch '$(call SHESCAPE,$(BUILDDIR))/stage1.stamp'

View File

@ -62,6 +62,11 @@ $(call MKESCAPE,$(BUILDDIR))/./flanterm/backends/fb.o: override CPPFLAGS_FOR_TAR
-DFLANTERM_FB_DISABLE_BUMP_ALLOC \
-DFLANTERM_FB_ENABLE_MASKING
override NASMFLAGS_FOR_TARGET += \
-Wall \
-w-reloc \
$(WERROR_FLAG)
ifeq ($(TARGET),bios)
override CFLAGS_FOR_TARGET += \
-fno-PIE \
@ -72,7 +77,8 @@ ifeq ($(TARGET),bios)
override CPPFLAGS_FOR_TARGET := \
$(CPPFLAGS_FOR_TARGET) \
-DBIOS
override NASM_TARGET := \
override NASMFLAGS_FOR_TARGET += \
-f elf32 \
-DIA32_TARGET
endif
@ -92,7 +98,8 @@ ifeq ($(TARGET),uefi-x86-64)
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/x86_64' \
$(CPPFLAGS_FOR_TARGET) \
-DUEFI
override NASM_TARGET := \
override NASMFLAGS_FOR_TARGET += \
-f elf64 \
-DX86_64_TARGET
endif
@ -108,7 +115,8 @@ ifeq ($(TARGET),uefi-ia32)
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/ia32' \
$(CPPFLAGS_FOR_TARGET) \
-DUEFI
override NASM_TARGET := \
override NASMFLAGS_FOR_TARGET += \
-f elf32 \
-DIA32_TARGET
endif
@ -572,29 +580,29 @@ endif
ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_bios_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
endif
ifeq ($(TARGET),uefi-x86-64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86_64
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_uefi_x86_64
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf64 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
endif
ifeq ($(TARGET),uefi-aarch64)
@ -620,13 +628,13 @@ endif
ifeq ($(TARGET),uefi-ia32)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_uefi_ia32
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_x86
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall $(NASM_TARGET) -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'
endif

View File

@ -138,7 +138,7 @@ parking64:
add rdi, qword [rbx + (passed_info.hhdm - smp_trampoline_start)]
mov eax, 1
lock xchg dword [rbx + (passed_info.booted_flag - smp_trampoline_start)], eax
xchg dword [rbx + (passed_info.booted_flag - smp_trampoline_start)], eax
xor eax, eax
.loop:

View File

@ -341,6 +341,10 @@ m4_define([DEFAULT_LDFLAGS_FOR_TARGET], [])
AC_ARG_VAR([LDFLAGS_FOR_TARGET], [linker flags for Limine @<:@default: ]DEFAULT_LDFLAGS_FOR_TARGET[@:>@])
test "x$LDFLAGS_FOR_TARGET" = "x" && LDFLAGS_FOR_TARGET="DEFAULT_LDFLAGS_FOR_TARGET"
m4_define([DEFAULT_NASMFLAGS_FOR_TARGET], [-F dwarf -g])
AC_ARG_VAR([NASMFLAGS_FOR_TARGET], [nasm flags for Limine @<:@default: ]DEFAULT_NASMFLAGS_FOR_TARGET[@:>@])
test "x$NASMFLAGS_FOR_TARGET" = "x" && NASMFLAGS_FOR_TARGET="DEFAULT_NASMFLAGS_FOR_TARGET"
LIMINE_COPYRIGHT=$($GREP Copyright "$SRCDIR/COPYING")
AC_SUBST([LIMINE_COPYRIGHT])

View File

@ -62,6 +62,12 @@ ifeq ($(LD_FOR_TARGET_HAS_NO_PIE),yes)
override LDFLAGS_FOR_TARGET += -no-pie
endif
override NASMFLAGS_FOR_TARGET += \
-Wall \
-w-reloc \
$(WERROR_FLAG) \
-f elf32
override C_FILES := $(shell find . -type f -name '*.c' | LC_ALL=C sort)
override ASM_FILES := $(shell find . -type f -name '*.asm' | LC_ALL=C sort)
override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o))
@ -82,4 +88,4 @@ $(call MKESCAPE,$(BUILDDIR))/%.o: %.c
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
nasm '$(call SHESCAPE,$<)' -Wall -f elf32 -o '$(call SHESCAPE,$@)'
nasm '$(call SHESCAPE,$<)' $(NASMFLAGS_FOR_TARGET) -o '$(call SHESCAPE,$@)'