Skip to content

Commit 8564ed2

Browse files
Andi KleenH. Peter Anvin
authored andcommitted
Kbuild, lto: Add a gcc-ld script to let run gcc as ld
For LTO we need to run the link step with gcc, not ld. Since there are a lot of linker options passed to it, add a gcc-ld wrapper that wraps them as -Wl, 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 ccbef16 commit 8564ed2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

scripts/gcc-ld

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
# run gcc with ld options
3+
# used as a wrapper to execute link time optimizations
4+
# yes virginia, this is not pretty
5+
6+
ARGS="-nostdlib"
7+
8+
while [ "$1" != "" ] ; do
9+
case "$1" in
10+
-save-temps|-m32|-m64) N="$1" ;;
11+
-r) N="$1" ;;
12+
-[Wg]*) N="$1" ;;
13+
-[olv]|-[Ofd]*|-nostdlib) N="$1" ;;
14+
--end-group|--start-group)
15+
N="-Wl,$1" ;;
16+
-[RTFGhIezcbyYu]*|\
17+
--script|--defsym|-init|-Map|--oformat|-rpath|\
18+
-rpath-link|--sort-section|--section-start|-Tbss|-Tdata|-Ttext|\
19+
--version-script|--dynamic-list|--version-exports-symbol|--wrap|-m)
20+
A="$1" ; shift ; N="-Wl,$A,$1" ;;
21+
-[m]*) N="$1" ;;
22+
-*) N="-Wl,$1" ;;
23+
*) N="$1" ;;
24+
esac
25+
ARGS="$ARGS $N"
26+
shift
27+
done
28+
29+
exec $CC $ARGS

0 commit comments

Comments
 (0)