[cfe-dev] clang/llvm cmake static build broken on Linux

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Dec 30 07:45:34 PST 2014


This looks like a bug/limitation in bfd ld.

$ gcc test.c -o test -static -Wl,-export-dynamic -fuse-ld=bfd
ld.bfd: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in
`/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/libc.a(strcmp.o)'
can not be used when making an executable; recompile with -fPIE and relink
with -pie
collect2: error: ld returned 1 exit status
$ gcc test.c -o test -static -Wl,-export-dynamic -fuse-ld=gold
$ cat test.c
#include <string.h>

int main(int argc, char *argv[]) {
  return strcmp(argv[0], argv[1]);
}



On 29 December 2014 at 12:49, Vince Harron <vharron at google.com> wrote:

> The first checkin with support for LLVM_BUILD_STATIC has this linking
> error, so the flag just isn't intended do what I expected.  I am able to
> build lldb-platform/lldb-gdbserver statically with this flag so it's
> working for me.
>
> Vince
>
>
> On Sun, Dec 28, 2014 at 7:56 AM, Vince Harron <vharron at google.com> wrote:
>
>> Hi all,
>>
>> I just grabbed tot.  I'm still able to build dynamic but static linking
>> isn't working for me anymore.
>>
>> I'm not sure if I should be directing this to cfe-dev or llvm-dev
>>
>> [305/306] Linking CXX executable bin/clang-3.6
>>
>> /usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality
>> in
>> `/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libc.a(strcmp.o)'
>> can not be used when making an executable; recompile with -fPIE and relink
>> with -pie"
>>
>> Repro steps:
>>
>> #!/bin/bash -ex
>>
>> ROOT_DIR=$HOME/ll/static-fail
>>
>> mkdir $ROOT_DIR
>> cd $ROOT_DIR
>> svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
>> cd llvm/tools
>> svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
>> cd $ROOT_DIR
>> mkdir build
>> cd build
>> cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_STATIC=True
>> ninja clang
>>
>>
>> --
>>
>> Vince Harron | Technical Lead Manager | vharron at google.com | 858-442-0868
>>
>
>
>
> --
>
> Vince Harron | Technical Lead Manager | vharron at google.com | 858-442-0868
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141230/14afa805/attachment.html>


More information about the cfe-dev mailing list