No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Hancox, James

Hi all,

 

I’m trying out the CMake 3.9.0-rc3 support for CUDA with Visual Studio generators*, and trying to port over an existing project that uses FindCUDA. I’m sure I’m missing something obvious, but I can’t see any mechanism to set -Xcompiler flags.

 

To be more explicit, I need to set /bigobj on the host compiler for a .cu file. If I use the CUDA Visual Studio Integration GUI, I can do this through CUDA C/C++->Host->Additional Compiler Options, which populates the CudaCompile\AdditionalCompilerOptions section of the .vcxproj. At compile time any flags in this field are passed to nvcc by the -Xcompiler flag, which in turn passes them through to the host compiler.

 

Unfortunately I cannot find any way to achieve this through CMake. I have tried to add it to CMAKE_CUDA_FLAGS like so:

set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler \"/bigobj\"")

 

But the generated .vcxproj does not have any trace of this line in it. (This method does work for setting -Xcudafe parameters as expected, but it almost seems like -Xcompiler flags are being deliberately stripped out.)

 

Is there some other mechanism for passing parameters into -Xcompiler?

 

Best wishes,

James Hancox

 

 

*To be precise, I’m using Visual Studio 12 2013 Win64 generator, CUDA 8.0.61 and CMake 3.9.0-rc3.

 


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Brad King
On 06/21/2017 09:08 AM, Hancox, James wrote:
> it almost seems like -Xcompiler flags are being deliberately stripped out.)

Unfortunately we have to strip them out to work around a bug in CUDA's VS
integration.

The -Xcompiler options are parsed for inclusion in AdditionalCompilerOptions
in the .vcxproj file by flag map entries here:

  https://gitlab.kitware.com/cmake/cmake/blob/v3.9.0-rc3/Source/cmVS10CudaFlagTable.h#L3-6

Then a subset of the options that have dedicated elements defined by the
CUDA VS integration are extracted by flag map entries here:

  https://gitlab.kitware.com/cmake/cmake/blob/v3.9.0-rc3/Source/cmVS10CudaHostFlagTable.h

Ideally we should then leave the rest in AdditionalCompilerOptions, but
CUDA's VS integration puts them in the wrong place and breaks builds.
Therefore we have to drop them:

  https://gitlab.kitware.com/cmake/cmake/blob/v3.9.0-rc3/Source/cmVisualStudio10TargetGenerator.cxx#L2508-2510

We've reported this to NVIDIA but can't take the workaround out until
a version of CUDA comes out that fixes it.

-Brad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Hancox, James
Hi Brad,

Thanks for the information, that makes a lot of sense. Here's hoping that CUDA 9 fixes the problem! Sadly it's a bit of a showstopper right now, but I'll be sure to try this again in a future version.

 Cheers,
James

-----Original Message-----
From: Brad King [mailto:[hidden email]]
Sent: 21 June 2017 16:49
To: Hancox, James <[hidden email]>
Cc: [hidden email]; Robert Maynard <[hidden email]>
Subject: Re: [CMake] No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

On 06/21/2017 09:08 AM, Hancox, James wrote:
> it almost seems like -Xcompiler flags are being deliberately stripped
> out.)

Unfortunately we have to strip them out to work around a bug in CUDA's VS integration.

The -Xcompiler options are parsed for inclusion in AdditionalCompilerOptions in the .vcxproj file by flag map entries here:

  https://gitlab.kitware.com/cmake/cmake/blob/v3.9.0-rc3/Source/cmVS10CudaFlagTable.h#L3-6

Then a subset of the options that have dedicated elements defined by the CUDA VS integration are extracted by flag map entries here:

  https://gitlab.kitware.com/cmake/cmake/blob/v3.9.0-rc3/Source/cmVS10CudaHostFlagTable.h

Ideally we should then leave the rest in AdditionalCompilerOptions, but CUDA's VS integration puts them in the wrong place and breaks builds.
Therefore we have to drop them:

  https://gitlab.kitware.com/cmake/cmake/blob/v3.9.0-rc3/Source/cmVisualStudio10TargetGenerator.cxx#L2508-2510

We've reported this to NVIDIA but can't take the workaround out until a version of CUDA comes out that fixes it.

-Brad


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com ______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Brad King
On 06/21/2017 12:04 PM, Hancox, James wrote:
> Sadly it's a bit of a showstopper right now

I found a better workaround that can preserve -Xcompiler flags.
Please see the MR here:

  https://gitlab.kitware.com/cmake/cmake/merge_requests/996

-Brad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Hancox, James
That's great news! I'll definitely try that out in the next RC. Thanks again for looking into this so quickly.

James

-----Original Message-----
From: Brad King [mailto:[hidden email]]
Sent: 21 June 2017 19:30
To: Hancox, James <[hidden email]>
Cc: [hidden email]; Robert Maynard <[hidden email]>
Subject: Re: [CMake] No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

On 06/21/2017 12:04 PM, Hancox, James wrote:
> Sadly it's a bit of a showstopper right now

I found a better workaround that can preserve -Xcompiler flags.
Please see the MR here:

  https://gitlab.kitware.com/cmake/cmake/merge_requests/996

-Brad


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com ______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Brad King
On 06/22/2017 07:32 AM, Hancox, James wrote:
> That's great news! I'll definitely try that out in the next RC.

It should be in a nightly binary from here:

 https://cmake.org/files/dev/?C=M;O=D

The cmake-3.9.20170621-g87dac-win64-x64.zip file should have it and
can be extracted and used without installing.

-Brad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Hancox, James
Hi Brad,

I picked up rc4 (since according to the release notes it has your changes merged in) and tried it out. Sadly I'm still running into problems! It looks like a semicolon is incorrectly added when -Xcompiler is appended to AdditionalOptions:

<AdditionalOptions>-lineinfo;-Xcompiler="/bigobj -Zi -Ob1"</AdditionalOptions>

This causes MSBuild to fail with the following error message:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 8.0.targets(635,9): error MSB5016: The name "-Xcompiler" contains an invalid character "-".  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 8.0.targets

I tried manually replacing the semicolon with a space, and this fixes the issue for me (and -Xcompiler is passed through as expected).

I've created a minimal test case to reproduce the error, and put it on Github at https://github.com/jameshancox/cmake_example_xcompiler , hope it helps.

Cheers,
James


-----Original Message-----
From: Brad King [mailto:[hidden email]]
Sent: 22 June 2017 15:06
To: Hancox, James <[hidden email]>
Cc: [hidden email]; Robert Maynard <[hidden email]>
Subject: Re: [CMake] No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

On 06/22/2017 07:32 AM, Hancox, James wrote:
> That's great news! I'll definitely try that out in the next RC.

It should be in a nightly binary from here:

 https://cmake.org/files/dev/?C=M;O=D

The cmake-3.9.20170621-g87dac-win64-x64.zip file should have it and can be extracted and used without installing.

-Brad


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com ______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No mechanism to set -Xcompiler options with Visual Studio CUDA integration?

Brad King
On 06/23/2017 07:40 AM, Hancox, James wrote:
> a semicolon is incorrectly added when -Xcompiler is appended
> to AdditionalOptions:

Thanks for trying it!  This has also been reported here:

 https://gitlab.kitware.com/cmake/cmake/issues/17008

Follow that for progress.

Thanks,
-Brad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...