[clang] bd8a950 - [clang][driver] Fix multiarch output name with -Wl arg
Keith Smiley via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 29 10:11:34 PDT 2021
Author: Keith Smiley
Date: 2021-10-29T10:09:38-07:00
New Revision: bd8a9507ef8c3a493c15828f7f2fbc241a9e5c93
URL: https://github.com/llvm/llvm-project/commit/bd8a9507ef8c3a493c15828f7f2fbc241a9e5c93
DIFF: https://github.com/llvm/llvm-project/commit/bd8a9507ef8c3a493c15828f7f2fbc241a9e5c93.diff
LOG: [clang][driver] Fix multiarch output name with -Wl arg
Previously if you passed a `-Wl,-foo` _before_ the source filename, the
first `InputInfos`, which is used for the base input name would be an
`InputArg` kind, which would never have a base input name. Now we use
that by default, but pick the first `InputInfo` that is of kind
`Filename` to get the name from if there is one.
Differential Revision: https://reviews.llvm.org/D112767
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/test/Driver/darwin-dsymutil.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index cd13a6d8b830..5b64ca8657d0 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4697,8 +4697,14 @@ InputInfo Driver::BuildJobsForActionNoCache(
CachedResults, A->getOffloadingDeviceKind()));
}
- // Always use the first input as the base input.
+ // Always use the first file input as the base input.
const char *BaseInput = InputInfos[0].getBaseInput();
+ for (auto &Info : InputInfos) {
+ if (Info.isFilename()) {
+ BaseInput = Info.getBaseInput();
+ break;
+ }
+ }
// ... except dsymutil actions, which use their actual input as the base
// input.
diff --git a/clang/test/Driver/darwin-dsymutil.c b/clang/test/Driver/darwin-dsymutil.c
index 922b5d27f438..9f77e7237d02 100644
--- a/clang/test/Driver/darwin-dsymutil.c
+++ b/clang/test/Driver/darwin-dsymutil.c
@@ -51,6 +51,14 @@
// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Wl,-foo -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
// Check that we only use dsymutil when needed.
//
More information about the cfe-commits
mailing list