Skip to contentSkip to conversation

Makefile: Move -no-pie from CFLAGS into LDFLAGS

PATCH In review Thomas Huth 3 participants 4 messages Aug 22, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Move -no-pie from CFLAGS into LDFLAGS

"-no-pie" is an option for linking, not for compiling, so we must put this into the lDFLAGS, not into CFLAGS. Without this change, the linking currently fails on Ubuntu 22.04 when compiling on a s390x host.

Fixes e489c25e ("Rework the common LDFLAGS to become more useful again")
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index 8809a8b6..e7998a40 100644
@@ -80,7 +80,7 @@ COMMON_CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,)
 ifeq ($(CONFIG_EFI),y)
 COMMON_CFLAGS += $(EFI_CFLAGS)
 else
-COMMON_CFLAGS += $(fno_pic) $(no_pie)
+COMMON_CFLAGS += $(fno_pic)
 endif
 COMMON_CFLAGS += $(wclobbered)
 COMMON_CFLAGS += $(wunused_but_set_parameter)
@@ -92,7 +92,7 @@ CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
 
-LDFLAGS += -nostdlib -z noexecstack
+LDFLAGS += -nostdlib $(no_pie) -z noexecstack
 
 $(libcflat): $(cflatobjs)
 	$(AR) rcs $@ $^
Signature · 1 line
2.39.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Thomas Huth

"-no-pie" is an option for linking, not for compiling, so we must put this into the lDFLAGS, not into CFLAGS. Without this change, the linking

                ^ L
Quoted 34 lines

currently fails on Ubuntu 22.04 when compiling on a s390x host.

Fixes e489c25e ("Rework the common LDFLAGS to become more useful again")
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index 8809a8b6..e7998a40 100644
@@ -80,7 +80,7 @@ COMMON_CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,)
 ifeq ($(CONFIG_EFI),y)
 COMMON_CFLAGS += $(EFI_CFLAGS)
 else
-COMMON_CFLAGS += $(fno_pic) $(no_pie)
+COMMON_CFLAGS += $(fno_pic)
 endif
 COMMON_CFLAGS += $(wclobbered)
 COMMON_CFLAGS += $(wunused_but_set_parameter)
@@ -92,7 +92,7 @@ CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
 
-LDFLAGS += -nostdlib -z noexecstack
+LDFLAGS += -nostdlib $(no_pie) -z noexecstack
 
 $(libcflat): $(cflatobjs)
 	$(AR) rcs $@ $^
Signature · 1 line
2.39.3

Otherwise,

Thanks,
drew

#2 lore raw
In reply to Thomas Huth
Quoted 7 lines · Thomas Huth

"-no-pie" is an option for linking, not for compiling, so we must put this into the lDFLAGS, not into CFLAGS. Without this change, the linking currently fails on Ubuntu 22.04 when compiling on a s390x host.

Fixes e489c25e ("Rework the common LDFLAGS to become more useful again")

Just tested it on my system, this fixes the compile problem.

#3 lore raw
Quoted 10 lines · Janosch Frank
Quoted 7 lines · Thomas Huth

"-no-pie" is an option for linking, not for compiling, so we must put this into the lDFLAGS, not into CFLAGS. Without this change, the linking currently fails on Ubuntu 22.04 when compiling on a s390x host.

Fixes e489c25e ("Rework the common LDFLAGS to become more useful again")

Just tested it on my system, this fixes the compile problem.

Great, thanks for checking, so I pushed it now to the repo.

Thomas