From: Nico Weber Date: Thu, 6 Dec 2018 18:50:39 +0000 (+0000) Subject: Allow forwarding -fdebug-compilation-dir to cc1as X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7ed3c458ebaac2f62761c6c44ee044a75cad925;p=clang Allow forwarding -fdebug-compilation-dir to cc1as The flag -fdebug-compilation-dir is useful to make generated .o files independent of the path of the build directory, without making the compile command-line dependent on the path of the build directory, like -fdebug-prefix-map requires. This change makes it so that the driver can forward the flag to -cc1as, like it already can for -cc1. We might want to consider making -fdebug-compilation-dir a driver flag in a follow-up. (Since -fdebug-compilation-dir defaults to PWD, it's already possible to get this effect by setting PWD, but explicit compiler flags are better than env vars, because e.g. ninja tracks command lines and reruns commands that change.) Somewhat related to PR14625. Differential Revision: https://reviews.llvm.org/D55377 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348515 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 3ebf440800..bd04317966 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -2152,6 +2152,9 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, } CmdArgs.push_back(Value.data()); TakeNextArg = true; + } else if (Value == "-fdebug-compilation-dir") { + CmdArgs.push_back("-fdebug-compilation-dir"); + TakeNextArg = true; } else { D.Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName() << Value; diff --git a/test/Driver/integrated-as.s b/test/Driver/integrated-as.s index 1dcd4f611a..3ad0860b90 100644 --- a/test/Driver/integrated-as.s +++ b/test/Driver/integrated-as.s @@ -50,3 +50,9 @@ // RUN: %clang -### -target x86_64--- -x assembler -c -fPIC -integrated-as %s 2>&1 | FileCheck --check-prefix=PIC %s // PIC: "-mrelocation-model" "pic" + +// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Wa,-fdebug-compilation-dir,. 2>&1 | FileCheck --check-prefix=WA_DEBUGDIR %s +// WA_DEBUGDIR: "-fdebug-compilation-dir" "." + +// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Xassembler -fdebug-compilation-dir -Xassembler . 2>&1 | FileCheck --check-prefix=XA_DEBUGDIR %s +// XA_DEBUGDIR: "-fdebug-compilation-dir" "."