We were seeing the following unexpected warnings in our builds:
C:/BuildAgent/work/19dd4d6ddfbe72aa/SecretProject/vcpkg_installed/x64-windows/include\fmt/format.h(771): warning : base class dllexport/dllimport specification differs from that of the derived class
C:/BuildAgent/work/19dd4d6ddfbe72aa/SecretProject/vcpkg_installed/x64-windows/include\fmt/format.h(3268): warning : base class dllexport/dllimport specification differs from that of the derived class
We use spdlog and fmt all over the place and weren't seeing these warnings elsewhere. Strangely there were not the usual error/warning codes that the compiler emits.
Then I noticed why - these diagnostics were preceded by the module name:
SomeFilter.cu
So this was not the normal C++ compiler, this was nvcc
complaining. Searching the web for this exact error message revealed virtually nothing.
So I searched for the NVCC command line reference and found:
which turned out to be quite useless. Searching for 'warning' reveals you can disable all warnings (most undesirable!) but not how to control specific diagnostics. Nothing in the Visual Studio settings revealed a suitable option, and searching all over the web (including SO) revealed nothing much of use. I eventually tried:
nvcc --help
and was presented with a huge list of options (662 lines, only some of which are covered in the online docs). Of particular note were these:
--display-error-number (-err-no)
This option displays a diagnostic number for any message generated by the
CUDA frontend compiler (note: not the host compiler).
--diag-error <error-number>,... (-diag-error)
Emit error for specified diagnostic message(s) generated by the CUDA frontend
compiler (note: does not affect diagnostics generated by the host compiler/preprocessor).
--diag-suppress <error-number>,... (-diag-suppress)
Suppress specified diagnostic message(s) generated by the CUDA frontend compiler
(note: does not affect diagnostics generated by the host compiler/preprocessor).
--diag-warn <error-number>,... (-diag-warn)
Emit warning for specified diagnostic message(s) generated by the CUDA frontend
compiler (note: does not affect diagnostics generated by the host compiler/preprocessor).
So I tried adding --display-error-number
and it failed saying the option was not recognised. Turns out you need to tell it
to pass this option to the front-end compiler with an additional option (not documented in the built-in help either!) and use
underscores instead of dashes:
-Xcudafe --display_error_number
Finally this showed me the error message with the code:
warning #1388-D: base class dllexport/dllimport specification differs from that of the derived class
and I was able to add the following lines to solve the problem:
-Xcudafe --display_error_number --diag-suppress 1388
If you're using Visual Studio, you have to add this in the under "CUDA C/C+ > Command Line > Additional Options".
I also eventually found some pragmas that can be used instead of the flags (provided you know the error number):
#pragma diag_suppress 1388