trylink: instead of build error, disable --gc-sections if GLIBC && STATIC
nameif: glibc build fixlet
This commit is contained in:
parent
ddc865fb0d
commit
3f9c848576
@ -10,17 +10,6 @@
|
||||
#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)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ typedef struct ethtable_s {
|
||||
#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 */
|
||||
@ -58,10 +58,10 @@ struct ethtool_drvinfo {
|
||||
/* 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
|
||||
|
@ -54,6 +54,23 @@ check_cc() {
|
||||
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"
|
||||
@ -64,6 +81,20 @@ LDLIBS="$6"
|
||||
# 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`
|
||||
|
||||
@ -76,7 +107,7 @@ try $CC $LDFLAGS \
|
||||
-o $EXE \
|
||||
-Wl,--sort-common \
|
||||
$SORT_SECTION \
|
||||
-Wl,--gc-sections \
|
||||
$GC_SECTION \
|
||||
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
|
||||
$l_list \
|
||||
|| {
|
||||
@ -100,7 +131,7 @@ while test "$LDLIBS"; do
|
||||
-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
|
||||
@ -129,7 +160,7 @@ if ! test -f busybox_ldscript; 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 \
|
||||
@ -151,7 +182,7 @@ else
|
||||
-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 \
|
||||
@ -207,7 +238,7 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then
|
||||
-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 \
|
||||
@ -246,7 +277,7 @@ int main(int argc, char **argv)
|
||||
-o $EXE \
|
||||
-Wl,--sort-common \
|
||||
$SORT_SECTION \
|
||||
-Wl,--gc-sections \
|
||||
$GC_SECTION \
|
||||
-L"$sharedlib_dir" -lbusybox \
|
||||
-Wl,--warn-common \
|
||||
|| {
|
||||
|
Loading…
Reference in New Issue
Block a user