rules_cuda icon indicating copy to clipboard operation
rules_cuda copied to clipboard

gcc: error: unrecognized command line option '-Qunused-arguments'; did you mean '-Wunused-parameter'

Open danielgordon10 opened this issue 3 years ago • 2 comments

I am getting this error when trying to compile some go code. Do you know what might be causing it?

Longer error message

ERROR: /home/daniel/thirdwave/twa/go/lib/geometry/BUILD.bazel:29:8: GoLink twa/go/lib/geometry/geometry_test_/geometry_test failed (Exit 1): builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder link -sdk external/go_sdk -installsuffix linux_amd64 -arc ... (remaining 175 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder link -sdk external/go_sdk -installsuffix linux_amd64 -arc ... (remaining 175 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
external/go_sdk/pkg/tool/linux_amd64/link: running external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc failed: exit status 1
gcc: error: unrecognized command line option '-Qunused-arguments'; did you mean '-Wunused-parameter'?

link: error running subcommand external/go_sdk/pkg/tool/linux_amd64/link: exit status 2
Target //twa/go/lib/geometry:geometry_test failed to build

danielgordon10 avatar Apr 01 '21 19:04 danielgordon10

Yeah. The way this rule works is by having the https://github.com/liuliu/rules_cuda/blob/main/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc.tpl as your de-facto compiler / linker. Under the hood, it parses parameters and pass to nvcc.

On linker phase, Bazel will collect all linker parameters and pass into the linker.

Depending on your bazelrc settings, if it uses nvcc, it may not understand all the modern linker parameters: https://github.com/liuliu/rules_cuda/blob/main/.bazelrc#L2, in that case, it may encounter this error.

There are two ways to workaround this: 1. Use clang rather than nvcc (as demonstrated in the example bazelrc file as cuda_clang) that should understand much more modern flags; 2. Update your CUDA toolkit so nvcc is a bit more modern. 3. Change the crosstool_wrapper_driver_is_not_gcc.tpl file such that this particular parameter is omitted.

liuliu avatar Apr 01 '21 20:04 liuliu

@danielgordon10 if you have an example to reprod this issue, I can help to resolve it. Thanks!

liuliu avatar Apr 03 '21 03:04 liuliu