[PATCH] D102049: [BareMetal] Ensure that sysroot always comes after library paths
Petr Hosek via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 7 13:22:02 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b00b34b8a05: [BareMetal] Ensure that sysroot always comes after library paths (authored by phosek).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102049/new/
https://reviews.llvm.org/D102049
Files:
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal-sysroot.cpp
Index: clang/test/Driver/baremetal-sysroot.cpp
===================================================================
--- clang/test/Driver/baremetal-sysroot.cpp
+++ clang/test/Driver/baremetal-sysroot.cpp
@@ -1,6 +1,23 @@
// REQUIRES: shell
// UNSUPPORTED: system-windows
+// Test that --sysroot always comes after any library paths.
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi -fuse-ld=lld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/sys-root -L%S/lib \
+// RUN: | FileCheck --check-prefix=CHECK-V6M -DLIB_DIR=%S/lib %s
+// CHECK-V6M: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none-unknown-eabi"
+// CHECK-V6M-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-V6M-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-SAME: "-L[[LIB_DIR]]"
+// CHECK-V6M-SAME: "-L[[SYSROOT]]{{/|\\\\}}lib"
+// CHECK-V6M-SAME: "-L[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}baremetal"
+// CHECK-V6M-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+// CHECK-V6M-SAME: "-o" "{{.*}}.o"
+
// Test that when a --sysroot is not provided, driver picks the default
// location correctly if available.
@@ -11,12 +28,12 @@
// RUN: %T/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target armv6m-none-eabi \
-// RUN: | FileCheck --check-prefix=CHECK-V6M-C %s
-// CHECK-V6M-C: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none-unknown-eabi"
-// CHECK-V6M-C-SAME: "-internal-isystem" "{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
-// CHECk-V6M-C-SAME: "-internal-isystem" "{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
-// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
-// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: "-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
-// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
+// RUN: | FileCheck --check-prefix=CHECK-V6M-DEFAULT-SYSROOT %s
+// CHECK-V6M-DEFAULT-SYSROOT: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none-unknown-eabi"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-internal-isystem" "{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECk-V6M-DEFAULT-SYSROOT-SAME: "-internal-isystem" "{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
+// CHECK-V6M-DEFAULT-SYSROOT-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+// CHECK-V6M-DEFAULT-SYSROOT-SAME: "-o" "{{.*}}.o"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===================================================================
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -299,13 +299,14 @@
CmdArgs.push_back("-Bstatic");
- CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
-
- TC.AddFilePathLibArgs(Args, CmdArgs);
Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
options::OPT_e, options::OPT_s, options::OPT_t,
options::OPT_Z_Flag, options::OPT_r});
+ TC.AddFilePathLibArgs(Args, CmdArgs);
+
+ CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
+
if (TC.ShouldLinkCXXStdlib(Args))
TC.AddCXXStdlibLibArgs(Args, CmdArgs);
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102049.343751.patch
Type: text/x-patch
Size: 4305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210507/04adb9f8/attachment.bin>
More information about the cfe-commits
mailing list