llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.22k stars 11.65k forks source link

libc++ fails to build with cmake on Snow Leopard and Leopard (works with buildit script) #26054

Open 0e6f8740-1d2a-4afc-85fd-df25c3a603fd opened 8 years ago

0e6f8740-1d2a-4afc-85fd-df25c3a603fd commented 8 years ago
Bugzilla Link 25680
Version trunk
OS All

Extended Description

libc++ builds on Leopard using the legacy buildit shell script, but it fails when using cmake. Due to our inability to skip building libc++ with cmake options (bug #​25665), this also impacts our ability to just build clang using cmake.

The buildit script compiles algorithm.cpp successfully with:

/opt/local/bin/clang++-mp-3.7 -c -g -Os -arch x86_64 -arch i386 -nostdinc++ -std=c++11 -U__STRICT_ANSI__ -I../include ../src/algorithm.cpp

The cmake build fails with:

/opt/local/bin/clang++-mp-3.7 -D_DEBUG -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -DSTDC_LIMIT_MACROS -I/opt/local/var/macports/build/_Users_jeremy_src_macports_dports_jeremyhu_lang_llvm-3.8/clang-3.8/work/build/projects/libcxx/lib -I/opt/local/var/macports/build/_Users_jeremy_src_macports_dports_jeremyhu_lang_llvm-3.8/clang-3.8/work/trunk/projects/libcxx/lib -I/opt/local/var/macports/build/_Users_jeremy_src_macports_dports_jeremyhu_lang_llvm-3.8/clang-3.8/work/build/include -I/opt/local/var/macports/build/_Users_jeremy_src_macports_dports_jeremyhu_lang_llvm-3.8/clang-3.8/work/trunk/include -I/opt/local/var/macports/build/_Users_jeremy_src_macports_dports_jeremyhu_lang_llvm-3.8/clang-3.8/work/trunk/projects/libcxx/include -pipe -Os -std=c++11 -arch x86_64 -arch i386 -fPIC -fvisibility-inlines-hidden -arch x86_64 -arch i386 -UNDEBUG -std=c++11 -nostdinc++ -Wall -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wno-error -fPIC -o CMakeFiles/cxx.dir//src/algorithm.cpp.o -c /opt/local/var/macports/build/_Users_jeremy_src_macports_dports_jeremyhu_lang_llvm-3.8/clang-3.8/work/trunk/projects/libcxx/src/algorithm.cpp

In file included from .../projects/libcxx/src/algorithm.cpp:11: In file included from .../projects/libcxx/include/random:1638: In file included from .../projects/libcxx/include/cmath:301: .../projects/libcxx/include/math.h:1199:91: error: use of undeclared identifier 'llrintf' inline _LIBCPP_INLINE_VISIBILITY long long llrint(float lcpp_x) _NOEXCEPT {return llrintf(lcpp_x);} ^

Adding -U__STRICT_ANSI__ to the compilation line (like cmake does) results in a successful compilation of algorithm.cpp.

0e6f8740-1d2a-4afc-85fd-df25c3a603fd commented 8 years ago

Leopard and Snow Leopard's math.h have this defined inside:

if ( defined (STDC_VERSION) && STDC_VERSION >= 199901L ) || ! defined( __STRICT_ANSI ) || ! defined( GNUC__ )

/* long long is not part of C90. Make sure you are passing -std=c99 or -std=gnu99 or better if you need this. */
extern long long int llrint ( double );
extern long long int llrintf ( float );

extern long long int llround ( double );
extern long long int llroundf ( float );

endif / #if ( defined (STDC_VERSION) && STDC_VERSION >= 199901L ) || ! defined( __STRICT_ANSI ) || ! defined( GNUC__ ) /

So this issue impacts Snow Leopard as well.