From c49866acceb1ffbcc0f723993648f0678e92a91c Mon Sep 17 00:00:00 2001 From: Christof Douma <19784376+cddouma@users.noreply.github.com> Date: Thu, 13 Feb 2020 11:08:46 +0000 Subject: [PATCH] [clang] stop baremetal driver to append .a to lib When the clang baremetal driver selects the rt.builtins static library it prefix with "-l" and appends ".a". The result is a nonsense option which lld refuses to accept. Differential Revision: https://reviews.llvm.org/D73904 Change-Id: Ic753b6104e259fbbdc059b68fccd9b933092d828 --- clang/lib/Driver/ToolChains/BareMetal.cpp | 2 +- clang/test/Driver/arm-compiler-rt.c | 7 +++++++ clang/test/Driver/baremetal.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index 7c302720c410..95f46b489e46 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -157,7 +157,7 @@ void BareMetal::AddCXXStdlibLibArgs(const ArgList &Args, void BareMetal::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs) const { CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" + - getTriple().getArchName() + ".a")); + getTriple().getArchName())); } void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/test/Driver/arm-compiler-rt.c b/clang/test/Driver/arm-compiler-rt.c index b1acd6d67363..f9de71a8c101 100644 --- a/clang/test/Driver/arm-compiler-rt.c +++ b/clang/test/Driver/arm-compiler-rt.c @@ -1,3 +1,10 @@ +// RUN: %clang -target arm-none-eabi \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -rtlib=compiler-rt -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix ARM-EABI +// ARM-EABI: "-L{{.*[/\\]}}Inputs/resource_dir_with_arch_subdir/lib/baremetal" +// ARM-EABI: "-lclang_rt.builtins-arm" + // RUN: %clang -target arm-linux-gnueabi \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -rtlib=compiler-rt -### %s 2>&1 \ diff --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp index 68031fede72c..3ef5a56425a3 100644 --- a/clang/test/Driver/baremetal.cpp +++ b/clang/test/Driver/baremetal.cpp @@ -13,7 +13,7 @@ // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for" -// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" +// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m" // CHECK-V6M-C-SAME: "-o" "{{.*}}.o" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ @@ -35,7 +35,7 @@ // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-DEFAULTCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind" -// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" +// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m" // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o" // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \ @@ -48,7 +48,7 @@ // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-LIBCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind" -// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" +// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m" // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o" // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \ @@ -61,7 +61,7 @@ // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-LIBSTDCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind" -// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" +// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m" // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o" // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \