-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[world rebuild|toolchain] Fix try compile handling #24493
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
…into fix_try_compile # Conflicts: # scripts/buildsystems/vcpkg.cmake
@ras0219-msft Could you please help review this PR? |
Tagged reviewed so other members will review this changes (doesn't means approved). |
@JavierMatosD @BillyONeal @vicroms: I feel like this PR got forgotten which is why i ping. |
This seems reasonable to me. I'm not sure how to verify that it is correct though. Can you show what a before/after of this change would imply? I realize it's been a long time :) |
if(POLICY CMP0056) | ||
cmake_policy(SET CMP0056 NEW) | ||
endif() | ||
if(POLICY CMP0066) | ||
cmake_policy(SET CMP0066 NEW) | ||
endif() | ||
if(POLICY CMP0067) | ||
cmake_policy(SET CMP0067 NEW) | ||
endif() | ||
if(POLICY CMP0137) | ||
cmake_policy(SET CMP0137 NEW) | ||
endif() | ||
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES | ||
VCPKG_CRT_LINKAGE VCPKG_TARGET_ARCHITECTURE VCPKG_SET_CHARSET_FLAG | ||
VCPKG_C_FLAGS VCPKG_CXX_FLAGS | ||
VCPKG_C_FLAGS_DEBUG VCPKG_CXX_FLAGS_DEBUG | ||
VCPKG_C_FLAGS_RELEASE VCPKG_CXX_FLAGS_RELEASE | ||
VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE VCPKG_LINKER_FLAGS_DEBUG | ||
VCPKG_PLATFORM_TOOLSET | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part that seems like the 'meat' of the change, and the rest seems like style changes. Does this need to be applied to xbox too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to revisit the xbox triplets when this was finished. Is it ready for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was in a perpetual circle waiting for @ras0219-msft to look at it because none of the other maintainers feel confident in vouching for the correctness of the change. In retrospect a specific test case of "this should work and does not" might have gone a long way to it not waiting like this for 2 years.
I'm not confident in the correctness either, but I'm willing to believe it did fix some problem for @Neumann-A , and I didn't see anything here that's obviously incorrect (why would passing more variables to try_compile be bad?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meat of the change is the removal of:
get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
The changes of CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
is just a result of that since the FLAGS being set in the if block require those variables to exist.
you can look into https://github.com/user-attachments/files/15814754/diff.txt to see what exactly did change due to that. removal and the adding of the VCPKG_ variables to CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
.
-//Flags used by the CXX compiler during RELEASE builds.
-CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG
+CMAKE_CXX_FLAGS_RELEASE:STRING='/MD /O2 /Oi /Gy /DNDEBUG /Z7 ' Shouldn't we be concerned about the extra |
That is CMake automagically doing it. I assume it is due to the additional space at the end of the flags. Since flags without that space don't have the extra |
@BillyONeal arm windows CI hanging building GTK3 here? |
Yeah, I kicked it by pushing a merge |
Remember #32327. Would have supplied logs. Might have enabled a fix. |
Thanks for the fix and sorry you were in a holding pattern for 2 years |
OK, so once I remove the property test and add the other elements to |
You can run the test port from this PR: PS D:\vcpkg> .\vcpkg.exe install try-compile:x64-windows --overlay-ports scripts\test_ports --enforce-port-checks
Computing installation plan...
The following packages will be built and installed:
try-compile:x64-windows@1 -- D:\vcpkg\scripts\test_ports\try-compile
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\bion\AppData\Local\vcpkg\archives in 245 us. Use --debug to see more details.
Installing 1/1 try-compile:x64-windows@1...
Building try-compile:x64-windows@1...
D:\vcpkg\scripts\test_ports\try-compile: info: installing overlay port from here
-- Configuring x64-windows
-- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
Stored binaries in 1 destinations in 22.6 ms.
Elapsed time to handle try-compile:x64-windows: 1.6 s
try-compile:x64-windows package ABI: f0f78eaa272af4799922a190f78bc5bcdb8d2396051fb83abbefe0c3b8989f8f
Total install time: 1.6 s
PS D:\vcpkg> .\vcpkg.exe install try-compile:x64-xbox-scarlett --overlay-ports scripts\test_ports --enforce-port-checks
Computing installation plan...
The following packages will be built and installed:
try-compile:x64-xbox-scarlett@1 -- D:\vcpkg\scripts\test_ports\try-compile
Detecting compiler hash for triplet x64-xbox-scarlett...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\bion\AppData\Local\vcpkg\archives in 217 us. Use --debug to see more details.
Installing 1/1 try-compile:x64-xbox-scarlett@1...
Building try-compile:x64-xbox-scarlett@1...
D:\vcpkg\triplets\community\x64-xbox-scarlett.cmake: info: loaded community triplet from here. Community triplets are not built in the curated registry and are thus less likely to succeed.
D:\vcpkg\scripts\test_ports\try-compile: info: installing overlay port from here
-- Configuring x64-xbox-scarlett
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:112 (message):
Command failed: D:/vcpkg-downloads/tools/ninja/1.10.2-windows/ninja.exe -v
Working Directory: D:/vcpkg/buildtrees/try-compile/x64-xbox-scarlett-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
D:\vcpkg\buildtrees\try-compile\config-x64-xbox-scarlett-dbg-CMakeCache.txt.log
D:\vcpkg\buildtrees\try-compile\config-x64-xbox-scarlett-rel-CMakeCache.txt.log
D:\vcpkg\buildtrees\try-compile\config-x64-xbox-scarlett-dbg-CMakeConfigureLog.yaml.log
D:\vcpkg\buildtrees\try-compile\config-x64-xbox-scarlett-rel-CMakeConfigureLog.yaml.log
D:\vcpkg\buildtrees\try-compile\config-x64-xbox-scarlett-out.log
Call Stack (most recent call first):
installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake:269 (vcpkg_execute_required_process)
scripts/test_ports/try-compile/portfile.cmake:5 (vcpkg_cmake_configure)
scripts/ports.cmake:191 (include)
error: building try-compile:x64-xbox-scarlett failed with: BUILD_FAILED
Elapsed time to handle try-compile:x64-xbox-scarlett: 1.1 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+try-compile
You can submit a new issue at:
https://github.com/microsoft/vcpkg/issues/new?title=[try-compile]+Build+error+on+x64-xbox-scarlett&body=Copy+issue+body+from+D%3A%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md
PS D:\vcpkg> D:\vcpkg\buildtrees\try-compile\config-x64-xbox-scarlett-out.log says: [1/2] "C:/Program Files/CMake/bin/cmake.exe" -E chdir ".." "C:/Program Files/CMake/bin/cmake.exe" "D:/vcpkg/scripts/test_ports/try-compile" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=D:/vcpkg/packages/try-compile_x64-xbox-scarlett" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DCMAKE_MAKE_PROGRAM=D:/vcpkg-downloads/tools/ninja/1.10.2-windows/ninja.exe" "-DXBOX_CONSOLE_TARGET=scarlett" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/vcpkg/scripts/toolchains/xbox.cmake" "-DVCPKG_TARGET_TRIPLET=x64-xbox-scarlett" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v143" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/vcpkg/installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
FAILED: ../CMakeCache.txt
"C:/Program Files/CMake/bin/cmake.exe" -E chdir ".." "C:/Program Files/CMake/bin/cmake.exe" "D:/vcpkg/scripts/test_ports/try-compile" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=D:/vcpkg/packages/try-compile_x64-xbox-scarlett" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DCMAKE_MAKE_PROGRAM=D:/vcpkg-downloads/tools/ninja/1.10.2-windows/ninja.exe" "-DXBOX_CONSOLE_TARGET=scarlett" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/vcpkg/scripts/toolchains/xbox.cmake" "-DVCPKG_TARGET_TRIPLET=x64-xbox-scarlett" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v143" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/vcpkg/installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
-- The C compiler identification is MSVC 19.40.33811.0
-- The CXX compiler identification is MSVC 19.40.33811.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (message):
Compiler flags are not passed consistently to try_compile!
-- Configuring incomplete, errors occurred!
[2/2] "C:/Program Files/CMake/bin/cmake.exe" -E chdir "../../x64-xbox-scarlett-dbg" "C:/Program Files/CMake/bin/cmake.exe" "D:/vcpkg/scripts/test_ports/try-compile" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=D:/vcpkg/packages/try-compile_x64-xbox-scarlett/debug" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DCMAKE_MAKE_PROGRAM=D:/vcpkg-downloads/tools/ninja/1.10.2-windows/ninja.exe" "-DXBOX_CONSOLE_TARGET=scarlett" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/vcpkg/scripts/toolchains/xbox.cmake" "-DVCPKG_TARGET_TRIPLET=x64-xbox-scarlett" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v143" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/vcpkg/installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
FAILED: ../../x64-xbox-scarlett-dbg/CMakeCache.txt
"C:/Program Files/CMake/bin/cmake.exe" -E chdir "../../x64-xbox-scarlett-dbg" "C:/Program Files/CMake/bin/cmake.exe" "D:/vcpkg/scripts/test_ports/try-compile" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=D:/vcpkg/packages/try-compile_x64-xbox-scarlett/debug" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DCMAKE_MAKE_PROGRAM=D:/vcpkg-downloads/tools/ninja/1.10.2-windows/ninja.exe" "-DXBOX_CONSOLE_TARGET=scarlett" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/vcpkg/scripts/toolchains/xbox.cmake" "-DVCPKG_TARGET_TRIPLET=x64-xbox-scarlett" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v143" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS= -DVCPKG_LET_ME_PASS" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/vcpkg/installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
-- The C compiler identification is MSVC 19.40.33811.0
-- The CXX compiler identification is MSVC 19.40.33811.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (message):
Compiler flags are not passed consistently to try_compile!
-- Configuring incomplete, errors occurred!
ninja: build stopped: subcommand failed. |
Thanks! The updated xbox triplet toolchain file is in this PR: #39654 |
while playing with qtbase on x64-uwp i found that it could not pass a try_compile command since important variables are not correctly forwarded. As such I concluded that the handling of try_compile in vcpkg is completely wrong.
(just learned qt6 does not support uwp. Nevertheless fixing try_compile is still and issue. )