diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index 24da31e225..7ac2276521 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -53,7 +53,7 @@ rule ArchitectureSetup architecture } if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { # TODO: These should be included in Clang's compiler specs. - archFlags += -fPIC ; + ccBaseFlags += -fPIC ; HAIKU_LINKFLAGS_$(architecture) += -shared ; } ccBaseFlags += $(archFlags) ; @@ -395,6 +395,25 @@ rule KernelArchitectureSetup architecture HAIKU_BOOT_LINKFLAGS = ; HAIKU_BOOT_LDFLAGS = -Bstatic ; + # Remove -fPIC and other unwanted options from the BOOT flags (they are sometimes + # added to force PIC in general.) + local fixedBootCCFlags ; + local fixedBootC++Flags ; + for flag in $(HAIKU_BOOT_CCFLAGS) { + if $(flag) = "-fpic" || $(flag) = "-fPIC" { + continue ; + } + fixedBootCCFlags += $(flag) ; + } + for flag in $(HAIKU_BOOT_C++FLAGS) { + if $(flag) = "-fpic" || $(flag) = "-fPIC" { + continue ; + } + fixedBootC++Flags += $(flag) ; + } + HAIKU_BOOT_CCFLAGS = $(fixedBootCCFlags) ; + HAIKU_BOOT_C++FLAGS = $(fixedBootC++Flags) ; + # Any special kernel base addresses if $(HAIKU_BOOT_LOADER_BASE) { HAIKU_BOOT_LDFLAGS += @@ -439,14 +458,6 @@ rule KernelArchitectureSetup architecture HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ; HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ; - # Just slip these in here as well for EFI (if used) - HAIKU_BOOT_EFI_CCFLAGS += -mno-red-zone ; - HAIKU_BOOT_EFI_C++FLAGS += -mno-red-zone ; - if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { - HAIKU_BOOT_EFI_CCFLAGS += -maccumulate-outgoing-args ; - HAIKU_BOOT_EFI_C++FLAGS += -maccumulate-outgoing-args ; - } - if x86 in $(HAIKU_ARCHS[2-]) || x86_gcc2 in $(HAIKU_ARCHS[2-]) { Echo "Enable kernel ia32 compatibility" ; HAIKU_KERNEL_DEFINES += _COMPAT_MODE ; @@ -461,9 +472,15 @@ rule KernelArchitectureSetup architecture case efi : # efi bootloader is PIC HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -fpic -fno-stack-protector - -fPIC -fshort-wchar -Wno-error=unused-variable -Wno-error=main ; + -fPIC -fshort-wchar -Wno-error=unused-variable -Wno-error=main + -mno-red-zone ; HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -fpic -fno-stack-protector - -fPIC -fshort-wchar -Wno-error=unused-variable -Wno-error=main ; + -fPIC -fshort-wchar -Wno-error=unused-variable -Wno-error=main + -mno-red-zone ; + if $(HAIKU_CC_IS_CLANG_$(architecture)) != 1 { + HAIKU_BOOT_$(bootTarget:U)_CCFLAGS += -maccumulate-outgoing-args ; + HAIKU_BOOT_$(bootTarget:U)_C++FLAGS += -maccumulate-outgoing-args ; + } HAIKU_BOOT_$(bootTarget:U)_LDFLAGS = -Bstatic -Bsymbolic -nostdlib -znocombreloc -no-undefined ; case bios_ia32 :