Skip to content

Patch rocThrust gtest build type for Windows compatibility. #358

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

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

ScottTodd
Copy link
Member

Progress on #36.

I was seeing errors like this:

279.4	[119/236  22% :: 279.314] Linking CXX executable test\adjacent_difference.hip.exe
279.4	FAILED: test/adjacent_difference.hip.exe 
282.3	C:\Windows\system32\cmd.exe /C "cd . && D:\projects\TheRock\build\core\clr\dist\lib\llvm\bin\clang++.exe -nostartfiles -nostdlib -DWIN32 -D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -fms-extensions -fms-compatibility -D_ENABLE_EXTENDED_ALIGNED_STORAGE  -Wno-documentation-unknown-command -Wno-documentation-pedantic -Wno-unused-command-line-argument -Wno-ignored-attributes -Wno-unknown-attributes -Wno-duplicate-decl-specifier --hip-path=D:/projects/TheRock/build/core/clr/dist --hip-device-lib-path=D:/projects/TheRock/build/core/clr/dist/lib/llvm/amdgcn/bitcode -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -L D:/projects/TheRock/build/compiler/amd-llvm/stage/lib/llvm/lib  -L D:/projects/TheRock/build/core/clr/stage/lib   -Xlinker /subsystem:console  -fuse-ld=lld-link CMakeFiles/sqlite3.dir/_deps/sqlite_local-src/sqlite3.c.obj test/CMakeFiles/adjacent_difference.hip.dir/test_adjacent_difference.cpp.obj -o test\adjacent_difference.hip.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:test\adjacent_difference.hip.lib -Xlinker /pdb:test\adjacent_difference.hip.pdb -Xlinker /version:0.0   deps/gtest/lib/gtestd.lib  deps/gtest/lib/gtest_maind.lib  D:/projects/TheRock/build/core/clr/dist/lib/amdhip64.lib  --hip-link  --offload-arch=gfx1100  --offload-arch=gfx1101  --offload-arch=gfx1102  D:/projects/TheRock/build/core/clr/dist/lib/llvm/lib/clang/19/lib/windows/clang_rt.builtins-x86_64.lib  deps/gtest/lib/gtestd.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && C:\Windows\system32\cmd.exe /C "cd /D D:\projects\TheRock\build\math-libs\rocThrust\build\test && "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different D:/projects/TheRock/math-libs/rocThrust/rtest.py D:/projects/TheRock/build/math-libs/rocThrust/build/test && cd /D D:\projects\TheRock\build\math-libs\rocThrust\build\test && "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different D:/projects/TheRock/math-libs/rocThrust/rtest.xml D:/projects/TheRock/build/math-libs/rocThrust/build/test""
282.3	lld-link: error: /failifmismatch: mismatch detected for '_ITERATOR_DEBUG_LEVEL':

282.3	>>> test/CMakeFiles/adjacent_difference.hip.dir/test_adjacent_difference.cpp.obj has value 0

282.3	>>> gtestd.lib(gtest-all.cc.obj) has value 2

282.3	clang++: error: linker command failed with exit code 1 (use -v to see invocation)

The documentation for _ITERATOR_DEBUG_LEVEL https://learn.microsoft.com/en-us/cpp/standard-library/iterator-debug-level?view=msvc-170 suggested that gtest was getting built in Debug while the rest of the project was getting built in Release. There are likely other dependencies affected by this issue, but this was minimally what I needed to build all rocThrust tests on Windows:

[build] [rocThrust] [235/236  97% :: 2.054] Linking CXX executable test\vector_insert.hip.exe
[build] [rocThrust] [235/236  98% :: 2.054] Linking CXX executable test\vector.hip.exe
[build] [rocThrust] [235/236  98% :: 2.066] Linking CXX executable test\vector_allocators.hip.exe
[build] [rocThrust] [235/236  99% :: 2.126] Linking CXX executable test\binary_search_vector_descending.hip.exe
[build] [rocThrust] [235/236  99% :: 2.160] Linking CXX executable test\binary_search_vector.hip.exe
[build] [rocThrust completed in 2 seconds]
[build] [5/7  71% :: 21.535] Stage installing sub-project rocThrust
[build] [6/7  85% :: 22.261] Merging sub-project dist directory for rocThrust
[driver] Build completed: 00:00:22.298
[build] Build finished with exit code 0

Copy link
Member

@marbre marbre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg...

Comment on lines +19 to +20
- CMAKE_ARGS -DBUILD_GTEST=ON -DINSTALL_GTEST=ON -Dgtest_force_shared_crt=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+ CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_GTEST=ON -DINSTALL_GTEST=ON -Dgtest_force_shared_crt=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that rocThrust already adds this CMake option for googlebenchmark: https://github.com/ROCm/rocThrust/blob/dfb07406c7ecc401e82a05497f99b0ef5aeb13f8/cmake/Dependencies.cmake#L167

    download_project(
      PROJ                googlebenchmark
      GIT_REPOSITORY      https://github.com/google/benchmark.git
      GIT_TAG             v${BENCHMARK_VERSION}
      GIT_SHALLOW         TRUE
      INSTALL_DIR         ${GOOGLEBENCHMARK_ROOT}
      CMAKE_ARGS          -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_CXX_STANDARD=14 ${COMPILER_OVERRIDE}

@ScottTodd ScottTodd merged commit 32d50c9 into ROCm:main Apr 7, 2025
3 of 5 checks passed
@ScottTodd ScottTodd deleted the windows-rocthrust-gtest branch April 7, 2025 22:18
@github-project-automation github-project-automation bot moved this from TODO to Done in TheRock Triage Apr 7, 2025
ScottTodd added a commit that referenced this pull request Apr 7, 2025
Progress on #36.

This, together with #358, fixes test
compilation for hipCUB and rocThrust.

Details:

* `-fms-extensions` and `-fms-compatibility` are documented here:
https://clang.llvm.org/docs/MSVCCompatibility.html
* Projects like hipCUB set `-D_ENABLE_EXTENDED_ALIGNED_STORAGE` to
acknowledge using extended aligned storage:
https://github.com/ROCm/hipCUB/blob/40f174daf777856949c624317c16ffbfe93e9108/rmake.py#L105-L108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants