[cfe-dev] Non-PIC code causes ld --shared to fail when using -fsanitize=undefined in trunk but not 3.4.
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri May 2 05:04:13 PDT 2014
It is not clear to me which list covers use of this flag, but as it
appears to this user as a compiler bug, I am posting here. Please tell
me where is the correct place if this is not it.
We use clang to run UBSAN over code for the R project, which makes
extensive use of DSOs to dynamically load extensions. This works fine
with 3.4, but not with the trunk.
For an empty file test.c, trunk gives
clang -fsanitize=undefined -fpic -g -O2 -mtune=native -c test.c -o test.o
clang -fsanitize=undefined -shared -o test.so test.o
/usr/bin/ld:
/usr/local/clang3.5t/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.san-x86_64.a(sanitizer_tls_get_addr.o):
relocation R_X86_64_TPOFF32 against `_ZN11__sanitizerL4dtlsE' can not be
used when making a shared object; recompile with -fPIC
/usr/local/clang3.5t/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.san-x86_64.a(sanitizer_tls_get_addr.o):
could not read symbols: Bad value
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
whereas 3.4 successfully compiled test.so.
This is x86_64 Linux, specifically Fedora 20, and trunk compiled
starting with clang 3.4. I first saw this around early Feb 2014, and
some bisection shows that r200062 was the last version I tried that worked.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the cfe-dev
mailing list