Compiling only device codes in NVCC without host compiler

Hello, in NVCC, I’m trying to find out a way to only compile the kernel functions that runs on the device, and not compile or link any host codes, which means that it doesn’t need a host cpp compiler such as g++(for Linux) or cl.exe(for Windows).
I’ve tried the --device-c option when compiling .cu with NVCC, but it turns out that NVCC will always check if a host compiler is available.
The problem is that I want to compile/link the host codes by myself, not automatically by NVCC, so I only want it to compile the device codes to obj that can be run with CUDA runtime or sth else…

Maybe the “–cubin” option?

I don’t believe there is a (provided) way if you are starting with a c++ source file (i.e. a .cu file) and using nvcc based on the compilation trajectory. The host compiler C++ preprecessor is always called first, and you can confirm this by setting --verbose in nvcc compilation. On linux, for example, the first actual tool/command issued is to gcc.

The ptxas tool can be used to compile PTX code to device code (SASS) without invokiing any other tool or compiler.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.