From owner-freebsd-current@FreeBSD.ORG Mon Jun 27 02:32:05 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0335B106566C for ; Mon, 27 Jun 2011 02:32:05 +0000 (UTC) (envelope-from eric@shadowsun.net) Received: from mail.atlantawebhost.com (dns1.atlantawebhost.com [66.223.40.39]) by mx1.freebsd.org (Postfix) with ESMTP id 94FCB8FC15 for ; Mon, 27 Jun 2011 02:32:04 +0000 (UTC) Received: (qmail 22231 invoked from network); 26 Jun 2011 22:32:04 -0400 Received: from ool-6039c07a.static.optonline.net (HELO Macintosh-21.local) (96.57.192.122) by mail.atlantawebhost.com with SMTP; 26 Jun 2011 22:32:03 -0400 Message-ID: <4E07EBA2.70500@shadowsun.net> Date: Sun, 26 Jun 2011 22:32:02 -0400 From: Eric McCorkle User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: freebsd-current@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Clang buildworld failure due to multiple definitions of __isnanf X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2011 02:32:05 -0000 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