Skip to contentSkip to conversation

kbuild: pass -fno-pic when probing for -mfentry

PATCH In review Ricardo Ribalda 3 participants 3 messages Oct 20

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

PATCH 1/1 kbuild: pass -fno-pic when probing for -mfentry

Some distros (namely Debian) configure their 32-bit toolchain with --enable-default-pie.

To properly probe for -mfentry on them we need to pass -fno-pic, otherwise allmodconfig will fail with:

./arch/x86/include/asm/ftrace.h:9:3: error: #error Compiler does not support fentry?

Fixes 454e00cf8ee5 ("kbuild: avoid re-running compiler and linker probes")

---
I found this while testing next with media-ci.

Full logs:
https://gitlab.freedesktop.org/linux-media/users/ribalda/-/jobs/113299249#L4729

---
 scripts/Kconfig.toolchain | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/Kconfig.toolchain +3 -1
index b0b9a663ddbe..53b361cf365a 100644
@@ -170,8 +170,10 @@ config CC_HAS_MNOP_MCOUNT
 	def_bool $(cc-option,-mnop-mcount)
 
 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
+# 32-bit x86 gcc does not support -mfentry in combination with -fpic, which will
+# be enabled by default when gcc is configured with --enable-default-pie.
 config CC_HAS_MFENTRY
-	def_bool $(cc-option,-mfentry)
+	def_bool $(cc-option,-fno-pic -mfentry)
 
 config LD_OPT_FORCE_GROUP_ALLOCATION
 	def_string "$(ld-option-str,--force-group-allocation)"

---
base-commit: 3d229ce89862b8e82d71a9e11d6f840ca272a6d6
change-id: 20261020-pie-6774df20b0fa

Best regards,

Signature · 1 line
Ricardo Ribalda <[email protected]>
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Ricardo Ribalda

Some distros (namely Debian) configure their 32-bit toolchain with --enable-default-pie.

To properly probe for -mfentry on them we need to pass -fno-pic, otherwise allmodconfig will fail with:

./arch/x86/include/asm/ftrace.h:9:3: error: #error Compiler does not support fentry?

Fixes 454e00cf8ee5 ("kbuild: avoid re-running compiler and linker probes")

Thanks! Makes sense to me, so:

Quoted 30 lines

---
I found this while testing next with media-ci.

Full logs:
https://gitlab.freedesktop.org/linux-media/users/ribalda/-/jobs/113299249#L4729

---
 scripts/Kconfig.toolchain | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/Kconfig.toolchain +3 -2
index b0b9a663ddbe..53b361cf365a 100644
@@ -170,8 +170,10 @@ config CC_HAS_MNOP_MCOUNT
 	def_bool $(cc-option,-mnop-mcount)
 
 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
+# 32-bit x86 gcc does not support -mfentry in combination with -fpic, which will
+# be enabled by default when gcc is configured with --enable-default-pie.
 config CC_HAS_MFENTRY
-	def_bool $(cc-option,-mfentry)
+	def_bool $(cc-option,-fno-pic -mfentry)
 
 config LD_OPT_FORCE_GROUP_ALLOCATION
 	def_string "$(ld-option-str,--force-group-allocation)"
 
---

base-commit: 3d229ce89862b8e82d71a9e11d6f840ca272a6d6
change-id: 20261020-pie-6774df20b0fa

Quoted 4 lines

Best regards,
--
Ricardo Ribalda <[email protected]>

--
Cheers, Lorenzo

#2 lore raw
In reply to Ricardo Ribalda

Hi Ricardo,

Quoted 8 lines · Ricardo Ribalda

Some distros (namely Debian) configure their 32-bit toolchain with --enable-default-pie.

To properly probe for -mfentry on them we need to pass -fno-pic, otherwise allmodconfig will fail with:

./arch/x86/include/asm/ftrace.h:9:3: error: #error Compiler does not support fentry?

Quoted 7 lines
Fixes 454e00cf8ee5 ("kbuild: avoid re-running compiler and linker probes")

---
I found this while testing next with media-ci.

Full logs:
https://gitlab.freedesktop.org/linux-media/users/ribalda/-/jobs/113299249#L4729

Thanks a lot for the patch/report. I noticed another problem with this check and the fix is quite ugly, so I think I would rather just back out of this move altogether, along with documenting these pitfalls for future travelers:

https://lore.kernel.org/[email protected]/

Quoted 29 lines
---
 scripts/Kconfig.toolchain | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/Kconfig.toolchain +3 -2
index b0b9a663ddbe..53b361cf365a 100644
@@ -170,8 +170,10 @@ config CC_HAS_MNOP_MCOUNT
 	def_bool $(cc-option,-mnop-mcount)
 
 # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
+# 32-bit x86 gcc does not support -mfentry in combination with -fpic, which will
+# be enabled by default when gcc is configured with --enable-default-pie.
 config CC_HAS_MFENTRY
-	def_bool $(cc-option,-mfentry)
+	def_bool $(cc-option,-fno-pic -mfentry)
 
 config LD_OPT_FORCE_GROUP_ALLOCATION
 	def_string "$(ld-option-str,--force-group-allocation)"
 
---

base-commit: 3d229ce89862b8e82d71a9e11d6f840ca272a6d6
change-id: 20261020-pie-6774df20b0fa

Best regards,

Signature · 1 line
Ricardo Ribalda <[email protected]>
Signature · 2 lines
Cheers,
Nathan