Skip to content

Commit ccbef16

Browse files
Andi KleenH. Peter Anvin
authored andcommitted
Kbuild, lto: add ld-version and ld-ifversion macros
To check the linker version. Used by the LTO makefile. Signed-off-by: Andi Kleen <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 7d02b49 commit ccbef16

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

scripts/Kbuild.include

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ ld-option = $(call try-run,\
155155
# Important: no spaces around options
156156
ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
157157

158+
# ld-version
159+
# Usage: $(call ld-version)
160+
# Note this is mainly for HJ Lu's 3 number binutil versions
161+
ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
162+
163+
# ld-ifversion
164+
# Usage: $(call ld-ifversion, -ge, 22252, y)
165+
ld-ifversion = $(shell [ $(call ld-version) $(1) $(2) ] && echo $(3))
166+
158167
######
159168

160169
###

scripts/ld-version.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/awk -f
2+
# extract linker version number from stdin and turn into single number
3+
{
4+
gsub(".*)", "");
5+
split($1,a, ".");
6+
print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
7+
exit
8+
}

0 commit comments

Comments
 (0)