[LinkerWrapper] Fix optimized debugging builds for NVPTX LTO
authorJoseph Huber <jhuber6@vols.utk.edu>
Mon, 26 Sep 2022 18:39:11 +0000 (13:39 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 27 Sep 2022 15:49:17 +0000 (10:49 -0500)
commitf50a7c7a26e074231cc9a60a3fcaef7520ceb67f
treee07a31414087d880faf6ae0f7798c3e584fc1e3b
parent77b202f974faa82679d9984aeef58355dc80ba80
[LinkerWrapper] Fix optimized debugging builds for NVPTX LTO

The ptxas assembler does not allow the `-g` flag along with
optimizations. Normally this is degraded to line info in the driver, but
when using LTO we did not have this step and the linker wrapper was not
correctly degrading the option. Note that this will not work if the user
does not pass `-g` again to the linker invocation. That will require
setting some flags in the binary to indicate that debugging was used
when building.

This fixes #57990

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D134660
clang/test/Driver/linker-wrapper.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp