trylink: fix glibc check; make --sort-section option look less ugly

This commit is contained in:
Denis Vlasenko 2008-04-30 00:15:56 +00:00
parent 3c07e4b877
commit a2dcb50175

View File

@ -66,7 +66,7 @@ check_libc_is_glibc() {
#if defined(__GLIBC__) && !defined(__UCLIBC__) #if defined(__GLIBC__) && !defined(__UCLIBC__)
syntax error here syntax error here
#endif #endif
" >"$tempname" " >"$tempname".c
if $CC "$tempname".c -c -o "$tempname".o >/dev/null 2>&1; then if $CC "$tempname".c -c -o "$tempname".o >/dev/null 2>&1; then
echo "$2"; echo "$2";
else else
@ -83,15 +83,15 @@ O_FILES="$5"
A_FILES="$6" A_FILES="$6"
LDLIBS="$7" LDLIBS="$7"
# The -Wl,--sort-section option is not supported by older versions of ld # The --sort-section option is not supported by older versions of ld
SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""` SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""`
# Static linking against glibc produces buggy executables # Static linking against glibc produces buggy executables
# (glibc does not cope well with ld --gc-sections). # (glibc does not cope well with ld --gc-sections).
# See sources.redhat.com/bugzilla/show_bug.cgi?id=3400 # See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
# Note that glibc is unsuitable for static linking anyway. # Note that glibc is unsuitable for static linking anyway.
# We are removing -Wl,--gc-sections from link command line. # We are removing -Wl,--gc-sections from link command line.
GC_SECTION=`( GC_SECTIONS=`(
. ./.config . ./.config
if test x"$CONFIG_STATIC" = x"y"; then if test x"$CONFIG_STATIC" = x"y"; then
check_libc_is_glibc "" "-Wl,--gc-sections" check_libc_is_glibc "" "-Wl,--gc-sections"
@ -112,7 +112,7 @@ try $CC $CFLAGS $LDFLAGS \
-o $EXE \ -o $EXE \
-Wl,--sort-common \ -Wl,--sort-common \
$SORT_SECTION \ $SORT_SECTION \
$GC_SECTION \ $GC_SECTIONS \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list \ $l_list \
|| { || {
@ -136,7 +136,7 @@ while test "$LDLIBS"; do
-o $EXE \ -o $EXE \
-Wl,--sort-common \ -Wl,--sort-common \
$SORT_SECTION \ $SORT_SECTION \
$GC_SECTION \ $GC_SECTIONS \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list $l_list
if test $? = 0; then if test $? = 0; then
@ -165,7 +165,7 @@ if ! test -f busybox_ldscript; then
-o $EXE \ -o $EXE \
-Wl,--sort-common \ -Wl,--sort-common \
$SORT_SECTION \ $SORT_SECTION \
$GC_SECTION \ $GC_SECTIONS \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list \ $l_list \
-Wl,--warn-common \ -Wl,--warn-common \
@ -187,7 +187,7 @@ else
-o $EXE \ -o $EXE \
-Wl,--sort-common \ -Wl,--sort-common \
$SORT_SECTION \ $SORT_SECTION \
$GC_SECTION \ $GC_SECTIONS \
-Wl,-T -Wl,busybox_ldscript \ -Wl,-T -Wl,busybox_ldscript \
-Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \
$l_list \ $l_list \
@ -243,7 +243,7 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then
-o $EXE \ -o $EXE \
-Wl,--sort-common \ -Wl,--sort-common \
$SORT_SECTION \ $SORT_SECTION \
$GC_SECTION \ $GC_SECTIONS \
-Wl,--start-group $O_FILES -Wl,--end-group \ -Wl,--start-group $O_FILES -Wl,--end-group \
-L"$sharedlib_dir" -lbusybox \ -L"$sharedlib_dir" -lbusybox \
-Wl,--warn-common \ -Wl,--warn-common \
@ -282,7 +282,7 @@ int main(int argc, char **argv)
-o $EXE \ -o $EXE \
-Wl,--sort-common \ -Wl,--sort-common \
$SORT_SECTION \ $SORT_SECTION \
$GC_SECTION \ $GC_SECTIONS \
-L"$sharedlib_dir" -lbusybox \ -L"$sharedlib_dir" -lbusybox \
-Wl,--warn-common \ -Wl,--warn-common \
|| { || {