[llvm-dev] Compiling LLVM with locally built clang | Errors

543 views
Skip to first unread message

SANJAY SRIVALLABH SINGAPURAM via llvm-dev

unread,
Feb 27, 2017, 2:12:07 AM2/27/17
to llvm...@lists.llvm.org
Hello,

I issued the following command to point the build to use clang and clang++, from a local llvm build directory included in PATH, instead of /usr/bin/{cc,c++},

cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm_src

The configuration failed with the error stating the compiler didn't recognize '-std=c++11' flag, whereas clang compiled a dummy c++ file with warnings.

int main(){return 0;} ( which was used during the config, found in build/CMakeFiles/CMakeErrors.log )

How can I resolve this ?

Thank You,
Sanjay

Flamedoge via llvm-dev

unread,
Feb 27, 2017, 6:35:34 AM2/27/17
to SANJAY SRIVALLABH SINGAPURAM, llvm...@lists.llvm.org
This might be error from `clang -std=c++11 a.c`. I would dump out and see what commands CMake is running to check if it's feeding c++ options to c files.

Regards,
Kevin

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


SANJAY SRIVALLABH SINGAPURAM via llvm-dev

unread,
Feb 27, 2017, 10:43:43 AM2/27/17
to Flamedoge, llvm...@lists.llvm.org
Hello Kevin,

The error doesn't seem to be with sending C++  options to clang. Here's the CMake output,
-- Performing Test CXX_SUPPORTS_CXX11
-- Performing Test CXX_SUPPORTS_CXX11 - Failed
CMake Error at cmake/modules/HandleLLVMOptions.cmake:511 (message):
  LLVM requires C++11 support but the '-std=c++11' flag isn't supported.
Call Stack (most recent call first):
  CMakeLists.txt:578 (include)

The configuration runs fine when LLVM_ENABLE_LLD is set to OFF. But, when enabled, the debug stops at the test checking for C++11 support,
-- Performing Test CXX_SUPPORTS_CXX11
-- Performing Test CXX_SUPPORTS_CXX11 - Failed
CMake Error at cmake/modules/HandleLLVMOptions.cmake:511 (message):
  LLVM requires C++11 support but the '-std=c++11' flag isn't supported.
Call Stack (most recent call first):
  CMakeLists.txt:578 (include)

These lines of CMakeError.log reveal that clang++ actually fails because of "-fuse-ld=lld",
[...] ( the following test is the only one that sends -std=c++11 to clang++ )
Performing C++ SOURCE FILE Test CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR failed with the following output:
Change Dir: /home/sanjay/Software/polly/llvm_build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_9cfd8"
[1/2] Building CXX object CMakeFiles/cmTC_9cfd8.dir/src.cxx.o
[2/2] Linking CXX executable cmTC_9cfd8
FAILED: : && /home/sanjay/Software/clang_vanilla/llvm_build/bin/clang++   -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -pedantic -Wno-long-long -DCXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR  -std=c++11 -Werror=non-virtual-dtor  -fuse-ld=lld CMakeFiles/cmTC_9cfd8.dir/src.cxx.o  -o cmTC_9cfd8  -lm && :
clang-5.0: error: invalid linker name in argument '-fuse-ld=lld'
ninja: build stopped: subcommand failed.

Source file was:
class base {public: virtual void anchor();protected: ~base();};
                                 class derived final : public base { public: ~derived();};
                                 int main() { return 0; }
[...]
Performing C++ SOURCE FILE Test CXX_SUPPORTS_WERROR_DATE_TIME failed with the following output:
Change Dir: /home/sanjay/Software/polly/llvm_build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_39bc5"
[1/2] Building CXX object CMakeFiles/cmTC_39bc5.dir/src.cxx.o
[2/2] Linking CXX executable cmTC_39bc5
FAILED: : && /home/sanjay/Software/clang_vanilla/llvm_build/bin/clang++   -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -pedantic -Wno-long-long -Wno-comment -DCXX_SUPPORTS_WERROR_DATE_TIME  -fuse-ld=lld CMakeFiles/cmTC_39bc5.dir/src.cxx.o  -o cmTC_39bc5  -lm && :
clang-5.0: error: invalid linker name in argument '-fuse-ld=lld'
ninja: build stopped: subcommand failed.

Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test CXX_SUPPORTS_CXX11 failed with the following output:
Change Dir: /home/sanjay/Software/polly/llvm_build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_25a8d"
[1/2] Building CXX object CMakeFiles/cmTC_25a8d.dir/src.cxx.o
[2/2] Linking CXX executable cmTC_25a8d
FAILED: : && /home/sanjay/Software/clang_vanilla/llvm_build/bin/clang++   -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -pedantic -Wno-long-long -Wno-comment -DCXX_SUPPORTS_CXX11  -fuse-ld=lld CMakeFiles/cmTC_25a8d.dir/src.cxx.o  -o cmTC_25a8d  -lm && :
clang-5.0: error: invalid linker name in argument '-fuse-ld=lld'
ninja: build stopped: subcommand failed.

Source file was:
int main() { return 0; }
(EOF)

It's odd that cmake reports that clang++ failed on "-std=c++11" when the problem was with "-fuse-ld=lld".

Also, do I have to explicitly indicate that lld needs to be built when building LLVM ? ( I couldn't find lld in llvm_build/bin )

Thank You,
Sanjay Srivallabh
Reply all
Reply to author
Forward
0 new messages