r348515 - Allow forwarding -fdebug-compilation-dir to cc1as

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 6 10:50:39 PST 2018


Author: nico
Date: Thu Dec  6 10:50:39 2018
New Revision: 348515

URL: http://llvm.org/viewvc/llvm-project?rev=348515&view=rev
Log:
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

Modified:
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp
    cfe/trunk/test/Driver/integrated-as.s

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=348515&r1=348514&r2=348515&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Dec  6 10:50:39 2018
@@ -2152,6 +2152,9 @@ static void CollectArgsForIntegratedAsse
           }
           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;

Modified: cfe/trunk/test/Driver/integrated-as.s
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/integrated-as.s?rev=348515&r1=348514&r2=348515&view=diff
==============================================================================
--- cfe/trunk/test/Driver/integrated-as.s (original)
+++ cfe/trunk/test/Driver/integrated-as.s Thu Dec  6 10:50:39 2018
@@ -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" "."




More information about the cfe-commits mailing list