Dmitri Gribenko
2014-Mar-22 19:50 UTC
[LLVMdev] compiler-rt CMake build ignores CMAKE_CXX_FLAGS
Hello, It looks like compiler-rt CMake scripts don't take CMAKE_CXX_FLAGS into account. This is because clang_compile and clang_link_shared functions call the newly-built compiler directly, and they don't add those flags. Using CMAKE_CXX_FLAGS is necessary on systems where the C++11-enabled libstdc++ is installed not in the default location. For example, the CentOS buildbot uses: -DCMAKE_CXX_FLAGS=--gcc-toolchain=/opt/centos/devtoolset-1.1/root/usr I tried adding ${CMAKE_CXX_FLAGS} to the compiler invocation in clang_compile (with and without quotes), but in both cases the resulting command is not correct, all of CMAKE_CXX_FLAGS is treated as a single option, for example: [6/67] Generating gtest-all.cc.x86_64.o FAILED: cd /home/llvmbb/clang/build-cmake-r+a/projects/compiler-rt/lib/tsan/tests/unit && /home/llvmbb/clang/build-cmake-r+a/./bin/clang -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fno-function-sections -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE -fno-rtti -DGTEST_NO_LLVM_RAW_OSTREAM=1 -I/home/llvmbb/clang/llvm/utils/unittest/googletest/include -I/home/llvmbb/clang/llvm/utils/unittest/googletest -I/home/llvmbb/clang/llvm/projects/compiler-rt/lib -I/home/llvmbb/clang/llvm/projects/compiler-rt/lib/tsan/rtl -std=c++11 -DGTEST_HAS_RTTI=0 --gcc-toolchain=/opt/centos/devtoolset-1.1/root/usr\ -fPIC\ -fvisibility-inlines-hidden\ -Wall\ -W\ -Wno-unused-parameter\ -Wwrite-strings\ -Wmissing-field-initializers\ -pedantic\ -Wno-long-long\ -Wcovered-switch-default\ -Wnon-virtual-dtor\ -std=c++11\ -fcolor-diagnostics\ -ffunction-sections\ -fdata-sections\ -Wall\ -std=c++11 -m64 -c -o gtest-all.cc.x86_64.o /home/llvmbb/clang/llvm/utils/unittest/googletest/src/gtest-all.cc Note the backslases in the command. Could maintainers of the compiler-rt CMake scripts help me with this? Dmitri -- main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
Alexey Samsonov
2014-Mar-23 18:03 UTC
[LLVMdev] compiler-rt CMake build ignores CMAKE_CXX_FLAGS
Hi Dmitri, On Sat, Mar 22, 2014 at 11:50 PM, Dmitri Gribenko <gribozavr at gmail.com>wrote:> Hello, > > It looks like compiler-rt CMake scripts don't take CMAKE_CXX_FLAGS > into account. This is because clang_compile and clang_link_shared > functions call the newly-built compiler directly, and they don't add > those flags. >Indeed.> > Using CMAKE_CXX_FLAGS is necessary on systems where the C++11-enabled > libstdc++ is installed not in the default location. For example, the > CentOS buildbot uses: > > -DCMAKE_CXX_FLAGS=--gcc-toolchain=/opt/centos/devtoolset-1.1/root/usr > > I tried adding ${CMAKE_CXX_FLAGS} to the compiler invocation in > clang_compile (with and without quotes), but in both cases the > resulting command is not correct, all of CMAKE_CXX_FLAGS is treated as > a single option, for example: >Yes, recently I discovered the same problem and also though of adding CMAKE_CXX_FLAGS to manual clang invocations. I think it just needs to be done.> > [6/67] Generating gtest-all.cc.x86_64.o > FAILED: cd > /home/llvmbb/clang/build-cmake-r+a/projects/compiler-rt/lib/tsan/tests/unit > && /home/llvmbb/clang/build-cmake-r+a/./bin/clang -fPIC -fno-builtin > -fno-exceptions -fomit-frame-pointer -funwind-tables > -fno-stack-protector -fvisibility=hidden -fno-function-sections -O3 > -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions > -Wno-non-virtual-dtor -fPIE -fno-rtti -DGTEST_NO_LLVM_RAW_OSTREAM=1 > -I/home/llvmbb/clang/llvm/utils/unittest/googletest/include > -I/home/llvmbb/clang/llvm/utils/unittest/googletest > -I/home/llvmbb/clang/llvm/projects/compiler-rt/lib > -I/home/llvmbb/clang/llvm/projects/compiler-rt/lib/tsan/rtl -std=c++11 > -DGTEST_HAS_RTTI=0 > --gcc-toolchain=/opt/centos/devtoolset-1.1/root/usr\ -fPIC\ > -fvisibility-inlines-hidden\ -Wall\ -W\ -Wno-unused-parameter\ > -Wwrite-strings\ -Wmissing-field-initializers\ -pedantic\ > -Wno-long-long\ -Wcovered-switch-default\ -Wnon-virtual-dtor\ > -std=c++11\ -fcolor-diagnostics\ -ffunction-sections\ -fdata-sections\ > -Wall\ -std=c++11 -m64 -c -o gtest-all.cc.x86_64.o > /home/llvmbb/clang/llvm/utils/unittest/googletest/src/gtest-all.cc > > Note the backslases in the command. >Yep, because CMAKE_CXX_FLAGS is a string, and its contents is automatically escaped when we use it in COMMAND in CMake rules. I guess we'll have to manually turn CMAKE_CXX_FLAGS into a CMake semicolon-separated list.> > Could maintainers of the compiler-rt CMake scripts help me with this? >Thanks for the detailed description of your use case. I will try to address this problem tomorrow.> > Dmitri > > -- > main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if > (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/ >-- Alexey Samsonov, MSK -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140323/c3bb2cec/attachment.html>
Alexey Samsonov
2014-Mar-24 09:49 UTC
[LLVMdev] compiler-rt CMake build ignores CMAKE_CXX_FLAGS
Submitted r204593. On Sun, Mar 23, 2014 at 10:03 PM, Alexey Samsonov <samsonov at google.com>wrote:> Hi Dmitri, > > On Sat, Mar 22, 2014 at 11:50 PM, Dmitri Gribenko <gribozavr at gmail.com>wrote: > >> Hello, >> >> It looks like compiler-rt CMake scripts don't take CMAKE_CXX_FLAGS >> into account. This is because clang_compile and clang_link_shared >> functions call the newly-built compiler directly, and they don't add >> those flags. >> > > Indeed. > > >> >> Using CMAKE_CXX_FLAGS is necessary on systems where the C++11-enabled >> libstdc++ is installed not in the default location. For example, the >> CentOS buildbot uses: >> >> -DCMAKE_CXX_FLAGS=--gcc-toolchain=/opt/centos/devtoolset-1.1/root/usr >> >> I tried adding ${CMAKE_CXX_FLAGS} to the compiler invocation in >> clang_compile (with and without quotes), but in both cases the >> resulting command is not correct, all of CMAKE_CXX_FLAGS is treated as >> a single option, for example: >> > > Yes, recently I discovered the same problem and also though of adding > CMAKE_CXX_FLAGS > to manual clang invocations. I think it just needs to be done. > > >> >> [6/67] Generating gtest-all.cc.x86_64.o >> FAILED: cd >> /home/llvmbb/clang/build-cmake-r+a/projects/compiler-rt/lib/tsan/tests/unit >> && /home/llvmbb/clang/build-cmake-r+a/./bin/clang -fPIC -fno-builtin >> -fno-exceptions -fomit-frame-pointer -funwind-tables >> -fno-stack-protector -fvisibility=hidden -fno-function-sections -O3 >> -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions >> -Wno-non-virtual-dtor -fPIE -fno-rtti -DGTEST_NO_LLVM_RAW_OSTREAM=1 >> -I/home/llvmbb/clang/llvm/utils/unittest/googletest/include >> -I/home/llvmbb/clang/llvm/utils/unittest/googletest >> -I/home/llvmbb/clang/llvm/projects/compiler-rt/lib >> -I/home/llvmbb/clang/llvm/projects/compiler-rt/lib/tsan/rtl -std=c++11 >> -DGTEST_HAS_RTTI=0 >> --gcc-toolchain=/opt/centos/devtoolset-1.1/root/usr\ -fPIC\ >> -fvisibility-inlines-hidden\ -Wall\ -W\ -Wno-unused-parameter\ >> -Wwrite-strings\ -Wmissing-field-initializers\ -pedantic\ >> -Wno-long-long\ -Wcovered-switch-default\ -Wnon-virtual-dtor\ >> -std=c++11\ -fcolor-diagnostics\ -ffunction-sections\ -fdata-sections\ >> -Wall\ -std=c++11 -m64 -c -o gtest-all.cc.x86_64.o >> /home/llvmbb/clang/llvm/utils/unittest/googletest/src/gtest-all.cc >> >> Note the backslases in the command. >> > > Yep, because CMAKE_CXX_FLAGS is a string, and its contents is automatically > escaped when we use it in COMMAND in CMake rules. I guess we'll have to > manually > turn CMAKE_CXX_FLAGS into a CMake semicolon-separated list. > > >> >> Could maintainers of the compiler-rt CMake scripts help me with this? >> > > Thanks for the detailed description of your use case. > I will try to address this problem tomorrow. > > >> >> Dmitri >> >> -- >> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if >> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/ >> > > -- > Alexey Samsonov, MSK >-- Alexey Samsonov, MSK -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140324/ff340457/attachment.html>