diff mbox series

[1/2] kconfig: detect LD implementation

Message ID 20220429093644.99574-2-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series linker: fix build with LLVM LD | expand

Commit Message

Roger Pau Monné April 29, 2022, 9:36 a.m. UTC
Detect GNU and LLVM ld implementations. This is required for further
patches that will introduce diverging behaviour depending on the
linker implementation in use.

Note that LLVM ld returns "compatible with GNU linkers" as part of the
version string, so be on the safe side and use '^' to only match at
the start of the line in case LLVM ever decides to change the text to
use "compatible with GNU ld" instead.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Michal Orzel <michal.orzel@arm.com>
---
This was discussed with Jan in:

https://lore.kernel.org/xen-devel/fbe0e0f0-85dd-434b-aca5-fa513b720c0b@suse.com/

While he would be fine to use the option if it was present, he isn't
convinced tools capabilities should be recorded in Kconfig, and hence
doesn't want to introduce the option himself (I hope I got this worded
right).
---
 xen/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Julien Grall April 29, 2022, 10 a.m. UTC | #1
Hi Roger,

On 29/04/2022 10:36, Roger Pau Monne wrote:
> Detect GNU and LLVM ld implementations. This is required for further
> patches that will introduce diverging behaviour depending on the
> linker implementation in use.
> 
> Note that LLVM ld returns "compatible with GNU linkers" as part of the
> version string, so be on the safe side and use '^' to only match at
> the start of the line in case LLVM ever decides to change the text to
> use "compatible with GNU ld" instead.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Reviewed-by: Michal Orzel <michal.orzel@arm.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,
diff mbox series

Patch

diff --git a/xen/Kconfig b/xen/Kconfig
index ec2bd9fbcf..134e6e68ad 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -23,6 +23,12 @@  config CLANG_VERSION
 	int
 	default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
 
+config LD_IS_GNU
+	def_bool $(success,$(LD) --version | head -n 1 | grep -q "^GNU ld")
+
+config LD_IS_LLVM
+	def_bool $(success,$(LD) --version | head -n 1 | grep -q "^LLD")
+
 # -fvisibility=hidden reduces -fpic cost, if it's available
 config CC_HAS_VISIBILITY_ATTRIBUTE
 	def_bool $(cc-option,-fvisibility=hidden)