bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiling bash statically in 4.2/4.3/4.4 with GCC 6.1.0


From: Eduardo Bustamante
Subject: Re: Compiling bash statically in 4.2/4.3/4.4 with GCC 6.1.0
Date: Fri, 12 May 2017 08:55:46 -0500

FWIW, I'm able to compile bash statically with:

address@hidden:~/src/gnu/bash$ ./configure --enable-static-link
--without-bash-malloc
[...]
address@hidden:~/src/gnu/bash$ make
[...]
address@hidden:~/src/gnu/bash$ file bash
bash: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
statically linked, for GNU/Linux 2.6.32,
BuildID[sha1]=183cd0733ecc4aae4d60226fd419c616cfcc5f57, not stripped
address@hidden:~/src/gnu/bash$ ./bash --version
GNU bash, version 4.4.12(2)-maint (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

In my system (Debian), libc.a is provided by libc6-dev:

address@hidden:~/src/gnu/bash$ dpkg -S /usr/lib/x86_64-linux-gnu/libc.a
libc6-dev:amd64: /usr/lib/x86_64-linux-gnu/libc.a

address@hidden:~/src/gnu/bash$ gcc --version
gcc (Debian 6.3.0-16) 6.3.0 20170425
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


It fails if I try to use clang though:

address@hidden:~/src/gnu/bash$ CC=clang ./configure
--enable-static-link --without-bash-malloc
[...]
address@hidden:~/src/gnu/bash$ make
bison -y -d ./parse.y
./parse.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
touch parser-built
rm -f mksyntax
clang -DPROGRAM='"bash"' -DCONF_HOSTTYPE='"x86_64"'
-DCONF_OSTYPE='"linux-gnu"'
-DCONF_MACHTYPE='"x86_64-unknown-linux-gnu"' -DCONF_VENDOR='"unknown"'
-DLOCALEDIR='"/usr/local/share/locale"' -DPACKAGE='"bash"' -DSHELL
-DHAVE_CONFIG_H -DDEBUG -DMALLOC_DEBUG -I.  -I. -I./include -I./lib
-g -O2 -Wno-parentheses -Wno-format-security   -rdynamic -g -O2
-Wno-parentheses -Wno-format-security  -static -rdynamic -g -O2
-Wno-parentheses -Wno-format-security  -o mksyntax ./mksyntax.c
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer
equality in 
`/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/libc.a(strcmp.o)'
can not be used when making an executable; recompile with -fPIE and
relink with -pie
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:702: recipe for target 'mksyntax' failed
make: *** [mksyntax] Error 1

address@hidden:~/src/gnu/bash$ clang --version
clang version 3.8.1-23 (tags/RELEASE_381/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

It seems to be caused by the combination of `-static' and `rdynamic'
(from LOCAL_LDFLAGS). This "works" though:

address@hidden:~/src/gnu/bash$ CC=clang ./configure
--enable-static-link --without-bash-malloc
[...]
address@hidden:~/src/gnu/bash$ make LOCAL_LDFLAGS=
[...]
address@hidden:~/src/gnu/bash$ file ./bash
./bash: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
statically linked, for GNU/Linux 2.6.32,
BuildID[sha1]=26ee2a8080868b2923e21f3c17c6814ae30905fb, not stripped
address@hidden:~/src/gnu/bash$ ./bash --version
GNU bash, version 4.4.12(1)-maint (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]