[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

Dan Liew via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 4 11:20:28 PDT 2021


delcypher updated this revision to Diff 342809.
delcypher edited the summary of this revision.
delcypher added a comment.

Use `isOSDarwin()` instead of explicitly checking Darwin OS enum values.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101682/new/

https://reviews.llvm.org/D101682

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/darwin-print-file-name.c
  clang/test/Driver/darwin-print-runtime-dir.c


Index: clang/test/Driver/darwin-print-runtime-dir.c
===================================================================
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{$}}
Index: clang/test/Driver/darwin-print-file-name.c
===================================================================
--- /dev/null
+++ clang/test/Driver/darwin-print-file-name.c
@@ -0,0 +1,27 @@
+// Regression test. Previously Clang just returned the library name instead
+// of the full path.
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a --target=x86_64-apple-darwin20.3.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a --target=x86_64-apple-macosx11.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{/|\\}}libclang_rt.osx.a
+
+// RUN: %clang -print-file-name=libclang_rt.ios.a --target=arm64-apple-ios14.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR-IOS %s
+// PRINT-RUNTIME-DIR-IOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.ios.a
+
+// RUN: %clang -print-file-name=libclang_rt.tvos.a --target=arm64-apple-tvos14.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR-TVOS %s
+// PRINT-RUNTIME-DIR-TVOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.tvos.a
+
+// RUN: %clang -print-file-name=libclang_rt.watchos.a --target=arm64-apple-watchos5.0.0 \
+// RUN:        -resource-dir=%S/Inputs/resource_dir \
+// RUN:      | FileCheck --check-prefix=PRINT-RUNTIME-DIR-WATCHOS %s
+// PRINT-RUNTIME-DIR-WATCHOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.watchos.a
Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -387,6 +387,9 @@
 }
 
 StringRef ToolChain::getOSLibName() const {
+  if (Triple.isOSDarwin())
+    return "darwin";
+
   switch (Triple.getOS()) {
   case llvm::Triple::FreeBSD:
     return "freebsd";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101682.342809.patch
Type: text/x-patch
Size: 3329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210504/a1b2edb8/attachment.bin>


More information about the cfe-commits mailing list