Discussion:
How to force linking to an archive?
Jeffrey Walton
2013-11-21 14:26:11 UTC
Permalink
I'm trying to evaluate a third party library based on autotools. The
evaluation includes some basic dynamic analysis using Clang 3.3 (the
analysis is provided by the sanitzers).

`make check` is failing due to missing symbols:

libjpeg.a(jmemmgr.o): In function `do_sarray_io':
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:695: undefined reference to
`__ubsan_handle_type_mismatch'
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:695: undefined reference to
`__ubsan_handle_type_mismatch'
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:696: undefined reference to
`__ubsan_handle_type_mismatch'
...

However, I'm including the required clang library through LDLIBS:

export LDLIBS="/usr/local/lib/clang/lib/linux/3.3/libclang_rt.full-x86_64.a
/usr/local/lib/clang/lib/linux/3.3/libclang_rt.ubsan-x86_64.a"
export CC=/usr/local/bin/clang
export CXX=/usr/local/bin/clang++
export CFLAGS="-g3 -fsanitize=address -fsanitize=undefined"
export CXXFLAGS="-g3 -fsanitize=address -fsanitize=undefined -fno-sanitize=vptr"

The missing functions are part of the libs specified in LDLIBS:

$ nm --defined libclang_rt.ubsan-x86_64.a | grep -i __ubsan_handle_type_mismatch
0000000000000000 T __ubsan_handle_type_mismatch
0000000000000740 T __ubsan_handle_type_mismatch_abort
...

How does one force the incusion of a library when using autotools?

Thanks in advance.
Jeffrey Walton
2013-11-21 23:05:46 UTC
Permalink
I think configuration and libtool are the problem here (I'm seeing the
problem on mulitple projects, with both Mac OS X and Linux).

For example, here's libpng:

/bin/sh ./libtool --tag=CC --mode=link /usr/local/bin/clang -g3
-fsanitize=address -fsanitize=undefined -no-undefined -export-dynamic
-version-number 16:7:0 -export-symbols libpng.sym -o libpng16.la
-rpath /usr/local/lib png.lo pngerror.lo pngget.lo pngmem.lo
pngpread.lo pngread.lo pngrio.lo pngrtran.lo pngrutil.lo pngset.lo
pngtrans.lo pngwio.lo pngwrite.lo pngwtran.lo pngwutil.lo -lz
libtool: link: sed 's,^,_,' < libpng.sym > .libs/libpng16-symbols.expsym
libtool: link: /usr/local/bin/clang -dynamiclib -o
.libs/libpng16.16.dylib .libs/png.o .libs/pngerror.o .libs/pngget.o
.libs/pngmem.o .libs/pngpread.o .libs/pngread.o .libs/pngrio.o
.libs/pngrtran.o .libs/pngrutil.o .libs/pngset.o .libs/pngtrans.o
.libs/pngwio.o .libs/pngwrite.o .libs/pngwtran.o .libs/pngwutil.o
-lz -install_name /usr/local/lib/libpng16.16.dylib
-compatibility_version 24 -current_version 24.0 -Wl,-single_module
-Wl,-exported_symbols_list,.libs/libpng16-symbols.expsym
Undefined symbols for architecture x86_64:
"___asan_handle_no_return", referenced from:
_png_set_sig_bytes in png.o
_png_data_freer in png.o
_png_colorspace_set_chromaticities in png.o
_png_colorspace_set_endpoints in png.o
_png_icc_profile_error in png.o
_png_compare_ICC_profile_with_sRGB in png.o
_png_colorspace_set_rgb_coefficients in png.o
...

This is despite the fact that LDLIBS was exported with the proper
static libraries. I've tried using both static and dynamic libraries.
I even opened the resulting Makefile and added a LDLIBS=<...> line (it
was missing).

So this may be a bit off-topic since it looks like a collaboration
between autotools and libtools, but how do I configure libtool to use
a library for an autotools project?

Thanks in advance.
Post by Jeffrey Walton
I'm trying to evaluate a third party library based on autotools. The
evaluation includes some basic dynamic analysis using Clang 3.3 (the
analysis is provided by the sanitzers).
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:695: undefined reference to
`__ubsan_handle_type_mismatch'
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:695: undefined reference to
`__ubsan_handle_type_mismatch'
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:696: undefined reference to
`__ubsan_handle_type_mismatch'
...
export LDLIBS="/usr/local/lib/clang/lib/linux/3.3/libclang_rt.full-x86_64.a
/usr/local/lib/clang/lib/linux/3.3/libclang_rt.ubsan-x86_64.a"
export CC=/usr/local/bin/clang
export CXX=/usr/local/bin/clang++
export CFLAGS="-g3 -fsanitize=address -fsanitize=undefined"
export CXXFLAGS="-g3 -fsanitize=address -fsanitize=undefined -fno-sanitize=vptr"
$ nm --defined libclang_rt.ubsan-x86_64.a | grep -i __ubsan_handle_type_mismatch
0000000000000000 T __ubsan_handle_type_mismatch
0000000000000740 T __ubsan_handle_type_mismatch_abort
...
How does one force the incusion of a library when using autotools?
Thanks in advance.
Christian Rössel
2013-11-22 11:53:07 UTC
Permalink
Jeffrey,
Post by Jeffrey Walton
I'm trying to evaluate a third party library based on autotools. The
evaluation includes some basic dynamic analysis using Clang 3.3 (the
analysis is provided by the sanitzers).
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:695: undefined reference to
`__ubsan_handle_type_mismatch'
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:695: undefined reference to
`__ubsan_handle_type_mismatch'
/home/jwalton/Desktop/jpeg-6b/jmemmgr.c:696: undefined reference to
`__ubsan_handle_type_mismatch'
...
export LDLIBS="/usr/local/lib/clang/lib/linux/3.3/libclang_rt.full-x86_64.a
/usr/local/lib/clang/lib/linux/3.3/libclang_rt.ubsan-x86_64.a"
export CC=/usr/local/bin/clang
export CXX=/usr/local/bin/clang++
export CFLAGS="-g3 -fsanitize=address -fsanitize=undefined"
export CXXFLAGS="-g3 -fsanitize=address -fsanitize=undefined -fno-sanitize=vptr"
it should be LIBS instead of LDLIBS, see the section 'Some influential
environment variables' in the configure --help output. There is also no
need to export variables as you can set them on the command line:
./configure [OPTION]... [VAR=VALUE]...

Hope that helps,
Christian
Post by Jeffrey Walton
$ nm --defined libclang_rt.ubsan-x86_64.a | grep -i __ubsan_handle_type_mismatch
0000000000000000 T __ubsan_handle_type_mismatch
0000000000000740 T __ubsan_handle_type_mismatch_abort
...
How does one force the incusion of a library when using autotools?
Thanks in advance.
_______________________________________________
Autoconf mailing list
https://lists.gnu.org/mailman/listinfo/autoconf
Loading...