aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-14 12:24:14 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-14 12:24:14 +0000
commitf1d93ec4206b50f7971f7df391dfc9bd52da8344 (patch)
tree7b695107ed753f44e922fac3c2450b61f1aa197e
parentb2e578a1f2c3cf317b391a7d2c059d6a5f5368b8 (diff)
downloadbusybox-w32-f1d93ec4206b50f7971f7df391dfc9bd52da8344.tar.gz
busybox-w32-f1d93ec4206b50f7971f7df391dfc9bd52da8344.tar.bz2
busybox-w32-f1d93ec4206b50f7971f7df391dfc9bd52da8344.zip
build system: pass CFLAGS to link stage too (closes bug 1376)
-rw-r--r--Makefile1
-rwxr-xr-xscripts/trylink23
2 files changed, 13 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index c8ff5fb52..60edff9b4 100644
--- a/Makefile
+++ b/Makefile
@@ -571,6 +571,7 @@ quiet_cmd_busybox__ ?= LINK $@
571 cmd_busybox__ ?= $(srctree)/scripts/trylink \ 571 cmd_busybox__ ?= $(srctree)/scripts/trylink \
572 "$@" \ 572 "$@" \
573 "$(CC)" \ 573 "$(CC)" \
574 "$(CFLAGS)" \
574 "$(LDFLAGS) $(EXTRA_LDFLAGS)" \ 575 "$(LDFLAGS) $(EXTRA_LDFLAGS)" \
575 "$(core-y)" \ 576 "$(core-y)" \
576 "$(libs-y)" \ 577 "$(libs-y)" \
diff --git a/scripts/trylink b/scripts/trylink
index 5ef0132eb..ebfe6cee3 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -77,10 +77,11 @@ check_libc_is_glibc() {
77 77
78EXE="$1" 78EXE="$1"
79CC="$2" 79CC="$2"
80LDFLAGS="$3" 80CFLAGS="$3"
81O_FILES="$4" 81LDFLAGS="$4"
82A_FILES="$5" 82O_FILES="$5"
83LDLIBS="$6" 83A_FILES="$6"
84LDLIBS="$7"
84 85
85# The -Wl,--sort-section option is not supported by older versions of ld 86# The -Wl,--sort-section option is not supported by older versions of ld
86SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""` 87SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""`
@@ -107,7 +108,7 @@ echo "Trying libraries: $LDLIBS"
107# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" 108# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
108l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 109l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
109test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 110test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
110try $CC $LDFLAGS \ 111try $CC $CFLAGS $LDFLAGS \
111 -o $EXE \ 112 -o $EXE \
112 -Wl,--sort-common \ 113 -Wl,--sort-common \
113 $SORT_SECTION \ 114 $SORT_SECTION \
@@ -131,7 +132,7 @@ while test "$LDLIBS"; do
131 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 132 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
132 test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 133 test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
133 $debug && echo "Trying -l options: '$l_list'" 134 $debug && echo "Trying -l options: '$l_list'"
134 try $CC $LDFLAGS \ 135 try $CC $CFLAGS $LDFLAGS \
135 -o $EXE \ 136 -o $EXE \
136 -Wl,--sort-common \ 137 -Wl,--sort-common \
137 $SORT_SECTION \ 138 $SORT_SECTION \
@@ -160,7 +161,7 @@ l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
160test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 161test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
161# --verbose gives us gobs of info to stdout (e.g. linker script used) 162# --verbose gives us gobs of info to stdout (e.g. linker script used)
162if ! test -f busybox_ldscript; then 163if ! test -f busybox_ldscript; then
163 try $CC $LDFLAGS \ 164 try $CC $CFLAGS $LDFLAGS \
164 -o $EXE \ 165 -o $EXE \
165 -Wl,--sort-common \ 166 -Wl,--sort-common \
166 $SORT_SECTION \ 167 $SORT_SECTION \
@@ -182,7 +183,7 @@ else
182 # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) 183 # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*)
183 # This will eliminate most of the padding (~3kb). 184 # This will eliminate most of the padding (~3kb).
184 # Hmm, "ld --sort-section alignment" should do it too. 185 # Hmm, "ld --sort-section alignment" should do it too.
185 try $CC $LDFLAGS \ 186 try $CC $CFLAGS $LDFLAGS \
186 -o $EXE \ 187 -o $EXE \
187 -Wl,--sort-common \ 188 -Wl,--sort-common \
188 $SORT_SECTION \ 189 $SORT_SECTION \
@@ -212,7 +213,7 @@ if test "$CONFIG_BUILD_LIBBUSYBOX" = y; then
212 ln -s "libbusybox.so.$BB_VER" "$sharedlib_dir"/libbusybox.so 2>/dev/null 213 ln -s "libbusybox.so.$BB_VER" "$sharedlib_dir"/libbusybox.so 2>/dev/null
213 214
214 EXE="$sharedlib_dir/libbusybox.so.${BB_VER}_unstripped" 215 EXE="$sharedlib_dir/libbusybox.so.${BB_VER}_unstripped"
215 try $CC $LDFLAGS \ 216 try $CC $CFLAGS $LDFLAGS \
216 -o $EXE \ 217 -o $EXE \
217 -shared -fPIC \ 218 -shared -fPIC \
218 -Wl,--enable-new-dtags \ 219 -Wl,--enable-new-dtags \
@@ -238,7 +239,7 @@ fi
238 239
239if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then 240if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then
240 EXE="$sharedlib_dir/busybox_unstripped" 241 EXE="$sharedlib_dir/busybox_unstripped"
241 try $CC $LDFLAGS \ 242 try $CC $CFLAGS $LDFLAGS \
242 -o $EXE \ 243 -o $EXE \
243 -Wl,--sort-common \ 244 -Wl,--sort-common \
244 $SORT_SECTION \ 245 $SORT_SECTION \
@@ -277,7 +278,7 @@ int main(int argc, char **argv)
277" >"$sharedlib_dir/applet.c" 278" >"$sharedlib_dir/applet.c"
278 279
279 EXE="$sharedlib_dir/$name" 280 EXE="$sharedlib_dir/$name"
280 try $CC $LDFLAGS "$sharedlib_dir/applet.c" \ 281 try $CC $CFLAGS $LDFLAGS "$sharedlib_dir/applet.c" \
281 -o $EXE \ 282 -o $EXE \
282 -Wl,--sort-common \ 283 -Wl,--sort-common \
283 $SORT_SECTION \ 284 $SORT_SECTION \