Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Nov 2011 21:47:25 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r227538 - head/tools/build
Message-ID:  <4EC2CFDD.7070206@FreeBSD.org>
In-Reply-To: <201111152015.pAFKFwqb015331@svn.freebsd.org>
References:  <201111152015.pAFKFwqb015331@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2011-11-15 21:15, Dimitry Andric wrote:
> Author: dim
> Date: Tue Nov 15 20:15:58 2011
> New Revision: 227538
> URL: http://svn.freebsd.org/changeset/base/227538
> 
> Log:
>   LLVM uses atomic operations, which are not supported on i386 and GCC
>   emits calls for them, rather than expanding them inline.  Older FreeBSD
>   versions compile for i386 by default and as such we end up with
>   unresolved symbols when we build LLVM's TableGen utility as a build
>   tool on them.  Add the functions that GCC emits here, but don't bother
>   to make them atomic. Such is not needed.
>   
>   Submitted by:	marcel
>   MFC after:	1 week

Note, this commit is a workaround for people upgrading their i386
machine to head from an older version, specifically head before r198344.

Before this revision, gcc defaulted to emitting code for real i386
CPU's, which lack support for gcc's atomic builtins.  Since the LLVM
code in head uses these, you would get link errors similar to:

[...building world...]
c++ -O2 -pipe -I/usr/src/usr.bin/clang/tblgen/../../../contrib/llvm/include -I/usr/src/usr.bin/clang/tblgen/../../../contrib/llvm/tools/clang/include -I/usr/src/usr.bin/clang/tblgen/../../../contrib/llvm/utils/TableGen -I. -I/usr/src/usr.bin/clang/tblgen/../../../contrib/llvm/../../lib/clang/include -DLLVM_ON_UNIX -DLLVM_ON_FREEBSD -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DLLVM_HOSTTRIPLE=\"i386-unknown-freebsd9.0\" -I/usr/obj/usr/src/tmp/legacy/usr/include  -static -L/usr/obj/usr/src/tmp/legacy/usr/lib -o tblgen ARMDecoderEmitter.o AsmMatcherEmitter.o AsmWriterEmitter.o AsmWriterInst.o CallingConvEmitter.o CodeEmitterGen.o CodeGenDAGPatterns.o CodeGenInstruction.o CodeGenRegisters.o CodeGenTarget.o DAGISelEmitter.o DAGISelMatcher.o DAGISelMatcherEmitter.o DAGISelMatcherGen.o DAGISelMatcherOpt.o DisassemblerEmitter.o EDEmitter.o FastISelEmitter.o FixedLenDecoderEmitter.o InstrEnumEmitter.o InstrInfoEmitter.o IntrinsicEmitter.o PseudoLoweringEmitter.o RegisterInfoEmitt
er.o SetTheory.o StringMatcher.o SubtargetEmitter.o TGValueTypes.o TableGen.o X86DisassemblerTables.o X86RecognizableInstr.o /usr/obj/usr/src/tmp/usr/src/usr.bin/clang/tblgen/../../../lib/clang/libllvmtablegen/libllvmtablegen.a /usr/obj/usr/src/tmp/usr/src/usr.bin/clang/tblgen/../../../lib/clang/libllvmsupport/libllvmsupport.a -legacy
/usr/obj/usr/src/tmp/usr/src/usr.bin/clang/tblgen/../../../lib/clang/libllvmsupport/libllvmsupport.a(Atomic.o)(.text+0x25): In function `llvm::sys::AtomicIncrement(unsigned int volatile*)':
: undefined reference to `__sync_add_and_fetch_4'
/usr/obj/usr/src/tmp/usr/src/usr.bin/clang/tblgen/../../../lib/clang/libllvmsupport/libllvmsupport.a(Atomic.o)(.text+0x45): In function `llvm::sys::AtomicDecrement(unsigned int volatile*)':
: undefined reference to `__sync_sub_and_fetch_4'
/usr/obj/usr/src/tmp/usr/src/usr.bin/clang/tblgen/../../../lib/clang/libllvmsupport/libllvmsupport.a(Atomic.o)(.text+0x5): In function `llvm::sys::AtomicAdd(unsigned int volatile*, unsigned int)':
: undefined reference to `__sync_add_and_fetch_4'
/usr/obj/usr/src/tmp/usr/src/usr.bin/clang/tblgen/../../../lib/clang/libllvmsupport/libllvmsupport.a(Atomic.o)(.text+0x61): In function `llvm::sys::CompareAndSwap(unsigned int volatile*, unsigned int, unsigned int)':
: undefined reference to `__sync_val_compare_and_swap_4'
*** Error code 1

Because it is not possible to reliably detect support for these atomic
builtins at compile time, Marcel provided these placeholder functions to
help the build complete successfully.

Note all the final executables will use 'real' atomic operations.  That
is, unless you compile with CPUTYPE?=i386, and I wish you the best of
luck in that case, you'll need it. :)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EC2CFDD.7070206>