Bug#696519: llvm-gcc-4.6: undefined reference to signbit when using boost's sign function

Ben Goodrich bg2382 at columbia.edu
Sat Dec 22 08:04:38 UTC 2012


Package: llvm-gcc-4.6
Version: 3.2-1~exp1
Severity: normal

When attempting to compile a file that utilizes boost's sign function, such as

goodrich at CYBERPOWERPC:/tmp$ cat sign.cpp
#include <boost/math/special_functions/sign.hpp>
#include <iostream>
int main() {
   std::cout << "expect 1, get " << boost::math::sign(10.0) << std::endl;
   std::cout << "expect 0, get " << boost::math::sign(0.0) << std::endl;
   std::cout << "expect -1, get " << boost::math::sign(-5.0) << std::endl;
   return 0;
}

llvm-g++ fails to compile it with the error "undefined reference to signbit"

goodrich at CYBERPOWERPC:/tmp$ llvm-g++ -v sign.cpp
Using built-in specs.
COLLECT_GCC=g++-4.6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian  
4.6.3-14' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs  
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr  
--program-suffix=-4.6 --enable-shared --enable-linker-build-id  
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext  
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6  
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu  
--enable-libstdcxx-debug --enable-libstdcxx-time=yes  
--enable-gnu-unique-object --enable-plugin --enable-objc-gc  
--with-arch-32=i586 --with-tune=generic --enable-checking=release  
--build=x86_64-linux-gnu --host=x86_64-linux-gnu  
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14)
COLLECT_GCC_OPTIONS='-fplugin=/usr/lib/gcc/x86_64-linux-gnu/4.6/plugin/dragonegg.so' '-v' '-shared-libgcc' '-mtune=generic'  
'-march=x86-64'
  /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1plus -quiet -v -imultilib .  
-imultiarch x86_64-linux-gnu  
-iplugindir=/usr/lib/gcc/x86_64-linux-gnu/4.6/plugin -D_GNU_SOURCE  
sign.cpp -iplugindir=/usr/lib/gcc/x86_64-linux-gnu/4.6/plugin -quiet  
-dumpbase sign.cpp -mtune=generic -march=x86-64 -auxbase sign -version  
-fplugin=/usr/lib/gcc/x86_64-linux-gnu/4.6/plugin/dragonegg.so -o  
/tmp/ccjP1Fvf.s
GNU C++ (Debian 4.6.3-14) version 4.6.3 (x86_64-linux-gnu)
         compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR  
version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Versions of loaded plugins:
  dragonegg: 3.2
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory  
"/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
  /usr/include/c++/4.6
  /usr/include/c++/4.6/x86_64-linux-gnu/.
  /usr/include/c++/4.6/backward
  /usr/lib/gcc/x86_64-linux-gnu/4.6/include
  /usr/local/include
  /usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
  /usr/include/x86_64-linux-gnu
  /usr/include
End of search list.
GNU C++ (Debian 4.6.3-14) version 4.6.3 (x86_64-linux-gnu)
         compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR  
version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Versions of loaded plugins:
  dragonegg: 3.2
Compiler executable checksum: ab35f31c589c345bfc3f13f058b31f15
COLLECT_GCC_OPTIONS='-fplugin=/usr/lib/gcc/x86_64-linux-gnu/4.6/plugin/dragonegg.so' '-v' '-shared-libgcc' '-mtune=generic'  
'-march=x86-64'
  as --64 -o /tmp/ccYQzrnW.o /tmp/ccjP1Fvf.s
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-fplugin=/usr/lib/gcc/x86_64-linux-gnu/4.6/plugin/dragonegg.so' '-v' '-shared-libgcc' '-mtune=generic'  
'-march=x86-64'
  /usr/lib/gcc/x86_64-linux-gnu/4.6/collect2 --sysroot=/ --build-id  
--no-add-needed --eh-frame-hdr -m elf_x86_64 --hash-style=both  
-dynamic-linker /lib64/ld-linux-x86-64.so.2  
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o  
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o  
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o  
-L/usr/lib/gcc/x86_64-linux-gnu/4.6  
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu  
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib  
-L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu  
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../..  
/tmp/ccYQzrnW.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc  
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtend.o  
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crtn.o
/tmp/ccYQzrnW.o: In function  
`__gnu_cxx::__enable_if<std::__is_arithmetic<double>::__value,  
int>::__type std::signbit<double>(double)':
sign.cpp:(.text._ZSt7signbitIdEN9__gnu_cxx11__enable_ifIXsrSt15__is_arithmeticIT_E7__valueEiE6__typeES3_[__gnu_cxx::__enable_if<std::__is_arithmetic<double>::__value, int>::__type std::signbit<double>(double)]+0x1d): undefined reference to  
`signbit'
collect2: ld returned 1 exit status

However, clang++ (and every version of g++ I have tried) can compile it

goodrich at CYBERPOWERPC:/tmp$ clang++ -v -stdlib=libc++ sign.cpp
Debian clang version 3.2-9 (tags/RELEASE_32/rc3) (based on LLVM 3.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
  "/usr/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj  
-mrelax-all -disable-free -disable-llvm-verifier -main-file-name  
sign.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno  
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array  
-target-cpu x86-64 -target-linker-version 2.22  
-momit-leaf-frame-pointer -v -resource-dir /usr/bin/../lib/clang/3.2  
-fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem  
/usr/include/c++/v1 -internal-isystem /usr/local/include  
-internal-isystem /usr/bin/../lib/clang/3.2/include -internal-isystem  
/usr/include/clang/3.2/include/ -internal-externc-isystem   
-internal-externc-isystem /usr/include/x86_64-linux-gnu  
-internal-externc-isystem /usr/include/x86_64-linux-gnu  
-internal-externc-isystem /usr/include -fdeprecated-macro  
-fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 191  
-mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions  
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/sign-WpNpcj.o -x  
c++ sign.cpp
clang -cc1 version 3.2 based upon LLVM 3.2svn default target  
x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/clang/3.2/include"
ignoring nonexistent directory ""
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
  /usr/include/c++/v1
  /usr/local/include
  /usr/include/clang/3.2/include
  /usr/include/x86_64-linux-gnu
  /usr/include
End of search list.
  "/usr/bin/ld" --hash-style=both --build-id --eh-frame-hdr -m  
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out  
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o  
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o  
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o  
-L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8  
-L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu  
-L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../lib64  
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu  
-L/usr/lib/../lib64 -L/usr/lib/x86_64-linux-gnu/../../lib64  
-L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/lib -L/usr/lib  
/tmp/sign-WpNpcj.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc  
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/crtend.o  
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o

and then it executes successfully

goodrich at CYBERPOWERPC:/tmp$ ./a.out
expect 1, get 1
expect 0, get 0
expect -1, get -1

Thank you.

-- System Information:
Debian Release: 7.0
   APT prefers unstable
   APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.6-9.slh.1-aptosid-amd64 (SMP w/8 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages llvm-gcc-4.6 depends on:
ii  dragonegg-4.6  3.2~rc3-1~exp1
ii  g++-4.6        4.6.3-14
ii  gcc-4.6        4.6.3-14

llvm-gcc-4.6 recommends no packages.

llvm-gcc-4.6 suggests no packages.

-- no debconf information



More information about the Pkg-llvm-team mailing list