#include <assert.h>
#include "busybox.h"
-/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
-#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
-#warning Static linking against glibc produces buggy executables
-#warning (glibc does not cope well with ld --gc-sections).
-#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
-#warning Note that glibc is unsuitable for static linking anyway.
-#warning If you still want to do it, remove -Wl,--gc-sections
-#warning from scripts/trylink and remove this warning.
-#error Aborting compilation.
-#endif
-
#if ENABLE_BUILD_LIBBUSYBOX
int main(int argc, char **argv)
{
#define ETHTOOL_BUSINFO_LEN 32
/* these strings are set to whatever the driver author decides... */
struct ethtool_drvinfo {
- __u32 cmd;
+ uint32_t cmd;
char driver[32]; /* driver short name, "tulip", "eepro100" */
char version[32]; /* driver version string */
char fw_version[32]; /* firmware version string, if applicable */
/* For PCI devices, use pci_dev->slot_name. */
char reserved1[32];
char reserved2[16];
- __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
- __u32 testinfo_len;
- __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
- __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
+ uint32_t n_stats; /* number of u64's from ETHTOOL_GSTATS */
+ uint32_t testinfo_len;
+ uint32_t eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
+ uint32_t regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
};
#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
#endif
}
check_cc() {
- if $CC $1 -shared -o /dev/null -xc /dev/null > /dev/null 2>&1; then
- echo "$1";
+ if $CC $1 -shared -o /dev/null -xc /dev/null >/dev/null 2>&1; then
+ echo "$1";
else
- echo "$2";
+ echo "$2";
fi
}
+check_libc_is_glibc() {
+ local tempname="/tmp/temp.$$.$RANDOM.c"
+ echo "\
+ #include <stdlib.h>
+ /* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
+ #if defined(__GLIBC__) && !defined(__UCLIBC__)
+ syntax error here
+ #endif
+ " >"$tempname"
+ if $CC "$tempname" -c -o /dev/null >/dev/null 2>&1; then
+ echo "$2";
+ else
+ echo "$1";
+ fi
+ rm "$tempname"
+}
+
EXE="$1"
CC="$2"
LDFLAGS="$3"
# The -Wl,--sort-section option is not supported by older versions of ld
SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""`
+# Static linking against glibc produces buggy executables
+# (glibc does not cope well with ld --gc-sections).
+# See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
+# Note that glibc is unsuitable for static linking anyway.
+# We are removing -Wl,--gc-sections from link command line.
+GC_SECTION=`(
+. ./.config
+if test x"$CONFIG_STATIC" = x"y"; then
+ check_libc_is_glibc "" "-Wl,--gc-sections"
+else
+ echo "-Wl,--gc-sections"
+fi
+)`
+
# Sanitize lib list (dups, extra spaces etc)
LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs`
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
- -Wl,--gc-sections \
+ $GC_SECTION \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list \
|| {
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
- -Wl,--gc-sections \
+ $GC_SECTION \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list
if test $? = 0; then
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
- -Wl,--gc-sections \
+ $GC_SECTION \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list \
-Wl,--warn-common \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
- -Wl,--gc-sections \
+ $GC_SECTION \
-Wl,-T -Wl,busybox_ldscript \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
- -Wl,--gc-sections \
+ $GC_SECTION \
-Wl,--start-group $O_FILES -Wl,--end-group \
-L"$sharedlib_dir" -lbusybox \
-Wl,--warn-common \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
- -Wl,--gc-sections \
+ $GC_SECTION \
-L"$sharedlib_dir" -lbusybox \
-Wl,--warn-common \
|| {