Date: Sun, 26 Jun 2011 22:32:02 -0400 From: Eric McCorkle <eric@shadowsun.net> To: freebsd-current@freebsd.org Subject: Clang buildworld failure due to multiple definitions of __isnanf Message-ID: <4E07EBA2.70500@shadowsun.net>
next in thread | raw e-mail | index | archive | help
I've both seen reports and experienced make buildworld with clang failing in usr.bin/xlint/lint1 (really, make kernel-toolchain is what fails), because lint1 is statically linked, and there is a definition of __isnanf in both libc and libm. GCC, on the other hand, builds just fine. The file tree.c in usr.bin/xlint/lint1 calls both isnan and finite from math.h. After some investigation, I figured out what's going on. math.h includes a macro version of isnan, which expands out to an expression that calls isnan, __isnanl, and __isnanf. GCC seems to treat all of these as builtin functions, and implements them with its code generator, rather than generating calls. Clang, on the other hand, does not, which leaves calls to __isnanf in the resulting object file, which will result in multiple definitions at link time. There are several possible solutions. The workaround I used is to add -Wl,--allow-multiple-definition to LDADD in the makefile for xlint. A better solution, I think, is to modify math.h with something like this: #ifdef __clang__ #define isnan(n) __builtin_isnan(n) ... #endif (It might be a good idea to add these kinds of definitions for all of clang's builtins, actually.) Anyway, I hope this helps someone. PS. Sorry I don't have build logs, assembler output, etc. My FreeBSD machine's wireless card isn't supported (yet). -- Eric McCorkle Computer Science Ph.D Student, University of Massachusetts Research Intern, IBM Research
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E07EBA2.70500>