Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[cmake] check_cxx_compiler_flag test for -std=c++11 fails to use linker flags, unable to find nonstandard location of libc++ #19070

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR19071
Status NEW
Importance P normal
Reported by David Fang (fang@csl.cornell.edu)
Reported on 2014-03-06 18:06:59 -0800
Last modified on 2015-08-10 00:38:08 -0700
Version trunk
Hardware All All
CC eugeni.stepanov@gmail.com, geek4civic@gmail.com, llvm-bugs@lists.llvm.org, vonosmas@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
On a system where libc++ is installed in a nonstandard location, the test for -
std=c++11 fails when trying to link the test executable, even when -L is passed
to linker flags:

-- Target triple: powerpc-apple-darwin8.11.0
-- Host OS X version: 10.4
-- Native target architecture is PowerPC
-- Threads enabled.
-- Doxygen disabled.
-- Building with -fPIC
CMake Error at cmake/modules/HandleLLVMOptions.cmake:298 (message):
  LLVM requires C++11 support but the '-std=c++11' flag isn't supported.
Call Stack (most recent call first):
  CMakeLists.txt:301 (include)

-- Configuring incomplete, errors occurred!
make: *** [cmake_check_build_system] Error 1

from CMakeFiles/CMakeError.log:
Performing C++ SOURCE FILE Test CXX_SUPPORTS_CXX11 failed with the following
output:
Change Dir: /Users/fang/local/src/LLVM-svn/clang34-stage1-
build/CMakeFiles/CMakeTmp

Run Build Command:/sw/bin/make "cmTryCompileExec1310359099/fast"
make[1]: Entering directory `/Volumes/Isolde/builds/LLVM/clang34-stage1-
build/CMakeFiles/CMakeTmp'
/sw/bin/make -f CMakeFiles/cmTryCompileExec1310359099.dir/build.make
CMakeFiles/cmTryCompileExec1310359099.dir/build
make[2]: Entering directory `/Volumes/Isolde/builds/LLVM/clang34-stage1-
build/CMakeFiles/CMakeTmp'
/Volumes/Mercedes2/sw/bin/cmake -E cmake_progress_report
/Users/fang/local/src/LLVM-svn/clang34-stage1-
build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec1310359099.dir/src.cxx.o
/sw/opt/llvm-3.4/bin/clang++    -std=c++11 -stdlib=libc++ -cxx-isystem
/sw/include/c++/v1 -B/sw/lib/odcctools/bin -no-integrated-as -fPIC -fvisibility-
inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-
initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-
dtor  -DCXX_SUPPORTS_CXX11   -std=c++11 -o
CMakeFiles/cmTryCompileExec1310359099.dir/src.cxx.o -c
/Users/fang/local/src/LLVM-svn/clang34-stage1-build/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTryCompileExec1310359099
/Volumes/Mercedes2/sw/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec1310359099.dir/link.txt --verbose=1
/sw/opt/llvm-3.4/bin/clang++    -std=c++11 -stdlib=libc++ -cxx-isystem
/sw/include/c++/v1 -B/sw/lib/odcctools/bin -no-integrated-as -fPIC -fvisibility-
inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-
initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-
dtor  -DCXX_SUPPORTS_CXX11 -Wl,-search_paths_first -Wl,-
headerpad_max_install_names
CMakeFiles/cmTryCompileExec1310359099.dir/src.cxx.o  -o
cmTryCompileExec1310359099  -lm
ld: library not found for -lc++
clang-3.4: error: linker command failed with exit code 1 (use -v to see
invocation)
make[2]: Leaving directory `/Volumes/Isolde/builds/LLVM/clang34-stage1-
build/CMakeFiles/CMakeTmp'
make[1]: Leaving directory `/Volumes/Isolde/builds/LLVM/clang34-stage1-
build/CMakeFiles/CMakeTmp'
make[2]: *** [cmTryCompileExec1310359099] Error 1
make[1]: *** [cmTryCompileExec1310359099/fast] Error 2

% grep LINKER_FLAGS CMakeCache.txt
CMAKE_EXE_LINKER_FLAGS:STRING= -L/sw/lib/c++
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_MODULE_LINKER_FLAGS:STRING= -L/sw/lib/c++
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_SHARED_LINKER_FLAGS:STRING= -L/sw/lib/c++
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=

and libc++ lives at /sw/lib/c++/libc++.dylib so that user may choose which
libc++ to use (vendor's vs. built).

Can the trivial executable test be fixed to account for linker flags?
Better yet would be if there were an equivalent option to -cxx-isystem for
linking.
Quuxplusone commented 10 years ago
workaround is to pass -L linker flags to CMAKE_CXX_COMPILER_FLAGS, as silly as
that seems.

cmake versions: 2.8.10.2 and 2.8.12.
Entirely possible that this should be fixed in cmake.
Quuxplusone commented 9 years ago

This becomes a lot more fun when you add MSan into the mix :)

I've filed http://www.cmake.org/Bug/view.php?id=15264

Quuxplusone commented 9 years ago
(In reply to comment #2)
> This becomes a lot more fun when you add MSan into the mix :)
>
> I've filed http://www.cmake.org/Bug/view.php?id=15264

According to their issue history,
http://www.cmake.org/Bug/view.php?id=14066#c37279
this should be fixed with cmake-3.2.