Wrong compile flags passed to nvcc by gtest
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 296
- Forks
- 66
- Avg merge
- 1h 3m
- Merged PRs (30d)
- 1
Description
When trying to compile camp on MSVC the "/wd4251" flag is passed to nvcc probably leading to an error, as it's not recognized by nvcc.
I'm using the following script to compile:
@echo off
setlocal
cd /d %~dp0
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set arch_command_length=32 || set arch_command_length=64
echo "%PROCESSOR_ARCHITECTURE%" | find /i "arm" > NUL && goto ARM || goto AMD
:ARM
IF %arch_command_length% == 32 (
set arch_string=x86_arm
set arch_command_length_string=x86
) ELSE (
set arch_string=amd64_arm64
set arch_command_length_string=x64
)
goto VC_VARC_INIT
:AMD
IF %arch_command_length% == 32 (
set arch_string=x86
set arch_command_length_string=x86
) ELSE (
set arch_string=amd64
set arch_command_length_string=x64
)
goto VC_VARC_INIT
:VC_VARC_INIT
call vcvarsall.bat %arch_string% -vcvars_ver=
call D:\My_Programs\Fortran\setvars.bat
set compiler_path=%VCToolsInstallDir%\bin\Host%arch_command_length_string%\%arch_command_length_string%\cl.exe
set linker_path=%VCToolsInstallDir%\bin\Host%arch_command_length_string%\%arch_command_length_string%\link.exe
set archiver_path=%VCToolsInstallDir%\bin\Host%arch_command_length_string%\%arch_command_length_string%\lib.exe
call "%DevEnvDir%\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DBLT_CXX_STD=c++17 -DENABLE_MPI=ON -DENABLE_CUDA=ON -DENABLE_OPENMP=ON -DCMAKE_AR:FILEPATH="%archiver_path%" -DCMAKE_LINKER:FILEPATH="%linker_path%" -DCMAKE_INSTALL_PREFIX:PATH="%CD%\out\install" -DCMAKE_CXX_COMPILER:FILEPATH="%compiler_path%" -DCMAKE_C_COMPILER:FILEPATH="%compiler_path%" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_MAKE_PROGRAM="%DevEnvDir%\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\Destranix\Documents\00Uni\Simulation\camp\"
call "%DevEnvDir%\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" --build . --config Release
Possibly a mechanism should be included to automatically mask compile-flags accordingly when compiling using a different compiler and/or to specify to which special compilers flags shell be passed.
EDIT:
Hotfix for this bug if the /wd-Options are the only ones causing problems:
Change https://github.com/LLNL/blt/blob/8c229991e65e7a9603c621b47cb3ba158bb7468c/thirdparty_builtin/CMakeLists.txt#L79-L81
list(APPEND _gtest_compile_flags
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4251>
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/wd4251>
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/wd4275>
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/wd4275>
)
blt_append_custom_compiler_flag( FLAGS_VAR gtest_extra_flags
DEFAULT " "
MSVC ${_gtest_compile_flags}
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in thirdparty_builtin/CMakeLists.txt around lines 79-81 and inspect how _gtest_compile_flags and gtest_extra_flags are assembled by blt_append_custom_compiler_flag. Reproduce the MSVC/Ninja/CUDA configuration from the issue if possible. Done means nvcc no longer receives incompatible /wd flags while the intended MSVC flags still reach host compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100