summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-28 17:04:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-28 17:04:42 +0000
commit3f9c84857617b0cf0d1824664e371fb6a4cac2e3 (patch)
treec073e77c0c0362246ce7eaccb3c846b15b8d2417
parentddc865fb0ddee9ed75467a164f27472c2234910a (diff)
downloadbusybox-w32-3f9c84857617b0cf0d1824664e371fb6a4cac2e3.tar.gz
busybox-w32-3f9c84857617b0cf0d1824664e371fb6a4cac2e3.tar.bz2
busybox-w32-3f9c84857617b0cf0d1824664e371fb6a4cac2e3.zip
trylink: instead of build error, disable --gc-sections if GLIBC && STATIC
nameif: glibc build fixlet
-rw-r--r--applets/applets.c11
-rw-r--r--networking/nameif.c10
-rwxr-xr-xscripts/trylink49
3 files changed, 45 insertions, 25 deletions
diff --git a/applets/applets.c b/applets/applets.c
index 33951fa8f..40c482408 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -10,17 +10,6 @@
10#include <assert.h> 10#include <assert.h>
11#include "busybox.h" 11#include "busybox.h"
12 12
13/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
14#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
15#warning Static linking against glibc produces buggy executables
16#warning (glibc does not cope well with ld --gc-sections).
17#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
18#warning Note that glibc is unsuitable for static linking anyway.
19#warning If you still want to do it, remove -Wl,--gc-sections
20#warning from scripts/trylink and remove this warning.
21#error Aborting compilation.
22#endif
23
24#if ENABLE_BUILD_LIBBUSYBOX 13#if ENABLE_BUILD_LIBBUSYBOX
25int main(int argc, char **argv) 14int main(int argc, char **argv)
26{ 15{
diff --git a/networking/nameif.c b/networking/nameif.c
index 66376a500..f0b8d11b0 100644
--- a/networking/nameif.c
+++ b/networking/nameif.c
@@ -50,7 +50,7 @@ typedef struct ethtable_s {
50#define ETHTOOL_BUSINFO_LEN 32 50#define ETHTOOL_BUSINFO_LEN 32
51/* these strings are set to whatever the driver author decides... */ 51/* these strings are set to whatever the driver author decides... */
52struct ethtool_drvinfo { 52struct ethtool_drvinfo {
53 __u32 cmd; 53 uint32_t cmd;
54 char driver[32]; /* driver short name, "tulip", "eepro100" */ 54 char driver[32]; /* driver short name, "tulip", "eepro100" */
55 char version[32]; /* driver version string */ 55 char version[32]; /* driver version string */
56 char fw_version[32]; /* firmware version string, if applicable */ 56 char fw_version[32]; /* firmware version string, if applicable */
@@ -58,10 +58,10 @@ struct ethtool_drvinfo {
58 /* For PCI devices, use pci_dev->slot_name. */ 58 /* For PCI devices, use pci_dev->slot_name. */
59 char reserved1[32]; 59 char reserved1[32];
60 char reserved2[16]; 60 char reserved2[16];
61 __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */ 61 uint32_t n_stats; /* number of u64's from ETHTOOL_GSTATS */
62 __u32 testinfo_len; 62 uint32_t testinfo_len;
63 __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */ 63 uint32_t eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
64 __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */ 64 uint32_t regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
65}; 65};
66#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */ 66#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
67#endif 67#endif
diff --git a/scripts/trylink b/scripts/trylink
index f57a8a160..283edfdbb 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -47,13 +47,30 @@ try() {
47} 47}
48 48
49check_cc() { 49check_cc() {
50 if $CC $1 -shared -o /dev/null -xc /dev/null > /dev/null 2>&1; then 50 if $CC $1 -shared -o /dev/null -xc /dev/null >/dev/null 2>&1; then
51 echo "$1"; 51 echo "$1";
52 else 52 else
53 echo "$2"; 53 echo "$2";
54 fi 54 fi
55} 55}
56 56
57check_libc_is_glibc() {
58 local tempname="/tmp/temp.$$.$RANDOM.c"
59 echo "\
60 #include <stdlib.h>
61 /* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
62 #if defined(__GLIBC__) && !defined(__UCLIBC__)
63 syntax error here
64 #endif
65 " >"$tempname"
66 if $CC "$tempname" -c -o /dev/null >/dev/null 2>&1; then
67 echo "$2";
68 else
69 echo "$1";
70 fi
71 rm "$tempname"
72}
73
57EXE="$1" 74EXE="$1"
58CC="$2" 75CC="$2"
59LDFLAGS="$3" 76LDFLAGS="$3"
@@ -64,6 +81,20 @@ LDLIBS="$6"
64# The -Wl,--sort-section option is not supported by older versions of ld 81# The -Wl,--sort-section option is not supported by older versions of ld
65SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""` 82SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""`
66 83
84# Static linking against glibc produces buggy executables
85# (glibc does not cope well with ld --gc-sections).
86# See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
87# Note that glibc is unsuitable for static linking anyway.
88# We are removing -Wl,--gc-sections from link command line.
89GC_SECTION=`(
90. ./.config
91if test x"$CONFIG_STATIC" = x"y"; then
92 check_libc_is_glibc "" "-Wl,--gc-sections"
93else
94 echo "-Wl,--gc-sections"
95fi
96)`
97
67# Sanitize lib list (dups, extra spaces etc) 98# Sanitize lib list (dups, extra spaces etc)
68LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` 99LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs`
69 100
@@ -76,7 +107,7 @@ try $CC $LDFLAGS \
76 -o $EXE \ 107 -o $EXE \
77 -Wl,--sort-common \ 108 -Wl,--sort-common \
78 $SORT_SECTION \ 109 $SORT_SECTION \
79 -Wl,--gc-sections \ 110 $GC_SECTION \
80 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 111 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
81 $l_list \ 112 $l_list \
82|| { 113|| {
@@ -100,7 +131,7 @@ while test "$LDLIBS"; do
100 -o $EXE \ 131 -o $EXE \
101 -Wl,--sort-common \ 132 -Wl,--sort-common \
102 $SORT_SECTION \ 133 $SORT_SECTION \
103 -Wl,--gc-sections \ 134 $GC_SECTION \
104 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 135 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
105 $l_list 136 $l_list
106 if test $? = 0; then 137 if test $? = 0; then
@@ -129,7 +160,7 @@ if ! test -f busybox_ldscript; then
129 -o $EXE \ 160 -o $EXE \
130 -Wl,--sort-common \ 161 -Wl,--sort-common \
131 $SORT_SECTION \ 162 $SORT_SECTION \
132 -Wl,--gc-sections \ 163 $GC_SECTION \
133 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 164 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
134 $l_list \ 165 $l_list \
135 -Wl,--warn-common \ 166 -Wl,--warn-common \
@@ -151,7 +182,7 @@ else
151 -o $EXE \ 182 -o $EXE \
152 -Wl,--sort-common \ 183 -Wl,--sort-common \
153 $SORT_SECTION \ 184 $SORT_SECTION \
154 -Wl,--gc-sections \ 185 $GC_SECTION \
155 -Wl,-T -Wl,busybox_ldscript \ 186 -Wl,-T -Wl,busybox_ldscript \
156 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 187 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
157 $l_list \ 188 $l_list \
@@ -207,7 +238,7 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then
207 -o $EXE \ 238 -o $EXE \
208 -Wl,--sort-common \ 239 -Wl,--sort-common \
209 $SORT_SECTION \ 240 $SORT_SECTION \
210 -Wl,--gc-sections \ 241 $GC_SECTION \
211 -Wl,--start-group $O_FILES -Wl,--end-group \ 242 -Wl,--start-group $O_FILES -Wl,--end-group \
212 -L"$sharedlib_dir" -lbusybox \ 243 -L"$sharedlib_dir" -lbusybox \
213 -Wl,--warn-common \ 244 -Wl,--warn-common \
@@ -246,7 +277,7 @@ int main(int argc, char **argv)
246 -o $EXE \ 277 -o $EXE \
247 -Wl,--sort-common \ 278 -Wl,--sort-common \
248 $SORT_SECTION \ 279 $SORT_SECTION \
249 -Wl,--gc-sections \ 280 $GC_SECTION \
250 -L"$sharedlib_dir" -lbusybox \ 281 -L"$sharedlib_dir" -lbusybox \
251 -Wl,--warn-common \ 282 -Wl,--warn-common \
252 || { 283 || {