-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix Hardening options and LTO for multi-configuration generators #260
Conversation
From my personal test on MacOS M1 (unfortunately not implementable in Github Actions yet), The problem is that CMake 3.23 and below run the check with the current environment and toolchain settings. Since we specify Here're two possible solutions:
error logCMake Warning at build/clang/_deps/_sample_project_project_options-src/src/Optimization.cmake:20 (message):
Interprocedural Optimization is not supported. Not using it. Here is the
error log: Change Dir:
'/Users/feignclaims/code/cpp/cpp_conan_template/build/clang/CMakeFiles/_CMakeLTOTest-CXX/bin'
Run Build Command(s): /opt/homebrew/bin/ninja -v
[1/8] "" -format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++
-DCMAKE_INTDIR=\"Debug\" -stdlib=libc++ -L/opt/homebrew/opt/llvm/lib/c++
-Wno-unused-command-line-argument -g -std=c++26 -flto=thin -arch arm64
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk
-fPIC -x c++
/Users/feignclaims/code/cpp/cpp_conan_template/build/clang/CMakeFiles/_CMakeLTOTest-CXX/src/foo.cpp
-c -o CMakeFiles/foo.dir/Debug/foo.cpp.o -resource-dir
"/opt/homebrew/Cellar/llvm/18.1.5/lib/clang/18" -MT
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi -MD -MF
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi.d >
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi.tmp && mv
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi.tmp
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi
FAILED: CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi
"" -format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++
-DCMAKE_INTDIR=\"Debug\" -stdlib=libc++ -L/opt/homebrew/opt/llvm/lib/c++
-Wno-unused-command-line-argument -g -std=c++26 -flto=thin -arch arm64
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk
-fPIC -x c++
/Users/feignclaims/code/cpp/cpp_conan_template/build/clang/CMakeFiles/_CMakeLTOTest-CXX/src/foo.cpp
-c -o CMakeFiles/foo.dir/Debug/foo.cpp.o -resource-dir
"/opt/homebrew/Cellar/llvm/18.1.5/lib/clang/18" -MT
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi -MD -MF
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi.d >
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi.tmp && mv
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi.tmp
CMakeFiles/foo.dir/Debug/foo.cpp.o.ddi
/bin/sh: : command not found
[2/8] "" -format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++
-DCMAKE_INTDIR=\"Debug\" -stdlib=libc++ -L/opt/homebrew/opt/llvm/lib/c++
-Wno-unused-command-line-argument -g -std=c++26 -flto=thin -arch arm64
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk
-fPIE -x c++
/Users/feignclaims/code/cpp/cpp_conan_template/build/clang/CMakeFiles/_CMakeLTOTest-CXX/src/main.cpp
-c -o CMakeFiles/boo.dir/Debug/main.cpp.o -resource-dir
"/opt/homebrew/Cellar/llvm/18.1.5/lib/clang/18" -MT
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi -MD -MF
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi.d >
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi.tmp && mv
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi.tmp
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi
FAILED: CMakeFiles/boo.dir/Debug/main.cpp.o.ddi
"" -format=p1689 -- /opt/homebrew/opt/llvm/bin/clang++
-DCMAKE_INTDIR=\"Debug\" -stdlib=libc++ -L/opt/homebrew/opt/llvm/lib/c++
-Wno-unused-command-line-argument -g -std=c++26 -flto=thin -arch arm64
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk
-fPIE -x c++
/Users/feignclaims/code/cpp/cpp_conan_template/build/clang/CMakeFiles/_CMakeLTOTest-CXX/src/main.cpp
-c -o CMakeFiles/boo.dir/Debug/main.cpp.o -resource-dir
"/opt/homebrew/Cellar/llvm/18.1.5/lib/clang/18" -MT
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi -MD -MF
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi.d >
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi.tmp && mv
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi.tmp
CMakeFiles/boo.dir/Debug/main.cpp.o.ddi
/bin/sh: : command not found
ninja: build stopped: subcommand failed.
Call Stack (most recent call first):
build/clang/_deps/_sample_project_project_options-src/src/Index.cmake:212 (enable_interprocedural_optimization)
build/clang/_deps/_sample_project_project_options-src/src/DynamicProjectOptions.cmake:257 (project_options)
cmake/sample_project_custom_project_options.cmake:30 (dynamic_project_options)
CMakeLists.txt:12 (include) |
All vcpkg-related cross tests failed after requiring CMake 3.24 as the minium version. I compared the logs from the last test with this one. Maybe this is caused by
|
You can set a if(POLICY CMP0138)
cmake_policy(SET CMP0138 NEW)
endif() |
I forgot this solution, thanks. |
ci on Given that the pull request performs well in other tests, I believe it is now suitable for review and possibly ready for merging. |
fix #259 by using generator expressions and
CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG>
.