summaryrefslogtreecommitdiff
path: root/scripts/Kconfig.include
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-09-18 17:59:27 -0700
committerNathan Chancellor <nathan@kernel.org>2026-09-24 11:37:05 -0400
commitcfcc465018818fb4f08148a28adb5b0cb40a9ec1 (patch)
tree0a74916617a2364cc2ad8abde50f9a75e082b3ee /scripts/Kconfig.include
parent889a621272f9b7e19f35efa3d836347b4e209290 (diff)
downloadlinux-cfcc465018818fb4f08148a28adb5b0cb40a9ec1.tar.gz
linux-cfcc465018818fb4f08148a28adb5b0cb40a9ec1.zip
kconfig: Add "ld-option-str"
Add the linker counterpart to $(cc-option-str), sharing a $(ld-probe) with $(ld-option) the way the compiler macros share $(cc-probe). Like $(cc-option-str), it can now be used as: config LD_OPT_FOO def_string "$(ld-option-str,--new-option,--old-option)" An omitted fallback expands to the empty string. Build tested ARCH=x86_64 defconfig with GCC 16.2.0, and checked against GNU ld 2.47. Assisted-by: LLM Signed-off-by: Kees Cook <kees@kernel.org> Tested-by: Julian Braha <julianbraha@gmail.com> Reviewed-by: Julian Braha <julianbraha@gmail.com> Link: https://patch.msgid.link/20260919005929.4077729-3-kees@kernel.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Diffstat (limited to 'scripts/Kconfig.include')
-rw-r--r--scripts/Kconfig.include12
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index 4ef2b64e97be..622d21e6953f 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -37,9 +37,19 @@ cc-option = $(success,$(cc-probe,$(1)))
# <fallback> defaults to an empty string and is returned untested.
cc-option-str = $(if-success,$(cc-probe,$(1)),$(1),$(2))
+# $(ld-probe,<flag>)
+# The command $(ld-option) and $(ld-option-str) test <flag> with. Not meant
+# to be called directly; use one of those two instead.
+ld-probe = $(LD) -v $(1)
+
# $(ld-option,<flag>)
# Return y if the linker supports <flag>, n otherwise
-ld-option = $(success,$(LD) -v $(1))
+ld-option = $(success,$(ld-probe,$(1)))
+
+# $(ld-option-str,<flag>[,<fallback>])
+# Return <flag> if the linker supports it, <fallback> otherwise.
+# <fallback> defaults to an empty string and is returned untested.
+ld-option-str = $(if-success,$(ld-probe,$(1)),$(1),$(2))
# $(as-instr,<instr>)
# Return y if the assembler supports <instr>, n otherwise