From: Kees Cook <kees@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: "Kees Cook" <kees@kernel.org>, "Nicolas Schier" <nsc@kernel.org>,
"Julian Braha" <julianbraha@gmail.com>,
"Matthew Maurer" <mmaurer@google.com>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Gary Guo" <gary@garyguo.net>,
linux-kbuild@vger.kernel.org,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Vegard Nossum" <vegard.nossum@oracle.com>,
"Nauman Sabir" <officialnaumansabir@gmail.com>,
"Tejun Heo" <tj@kernel.org>, "Nicolas Pitre" <nico@fluxnic.net>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Andrew Jones" <andrew.jones@linux.dev>,
"Graham Roff" <grahamr@qti.qualcomm.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: [PATCH 3/3] kconfig: Add "ld-option-str"
Date: Fri, 18 Sep 2026 17:59:27 -0700 [thread overview]
Message-ID: <20260919005929.4077729-3-kees@kernel.org> (raw)
In-Reply-To: <20260919005923.i.879-kees@kernel.org>
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>
---
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nsc@kernel.org>
Cc: Julian Braha <julianbraha@gmail.com>
Cc: Matthew Maurer <mmaurer@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Gary Guo <gary@garyguo.net>
Cc: <linux-kbuild@vger.kernel.org>
---
scripts/Kconfig.include | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
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
--
2.34.1
next prev parent reply other threads:[~2026-09-19 0:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 0:59 [PATCH 0/3] kconfig: Introduce cc-option-str Kees Cook
2026-09-19 0:59 ` [PATCH 1/3] kconfig: Add "def_string", "def_int" and "def_hex" Kees Cook
2026-09-19 0:59 ` [PATCH 2/3] kconfig: Replace "cc-option-bit" with "cc-option-str" Kees Cook
2026-09-19 0:59 ` Kees Cook [this message]
2026-09-19 1:25 ` [PATCH 0/3] kconfig: Introduce cc-option-str Nathan Chancellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260919005929.4077729-3-kees@kernel.org \
--to=kees@kernel.org \
--cc=andrew.jones@linux.dev \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=gary@garyguo.net \
--cc=grahamr@qti.qualcomm.com \
--cc=julianbraha@gmail.com \
--cc=krzk@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=masahiroy@kernel.org \
--cc=mmaurer@google.com \
--cc=nathan@kernel.org \
--cc=nico@fluxnic.net \
--cc=nsc@kernel.org \
--cc=officialnaumansabir@gmail.com \
--cc=ojeda@kernel.org \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=tj@kernel.org \
--cc=vegard.nossum@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®