From a5e2b76e51239e82711ddb166a447106b05ec1a9 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sat, 27 Jul 2019 13:15:58 -0700 Subject: [PATCH] llvmPackages_8.clang: bare-metal driver linker fix Clang passes an incorrect -l linker flag for compiler-rt. See https://reviews.llvm.org/D51899 --- .../llvm/8/clang/compiler-rt-baremetal.patch | 53 +++++++++++++++++++ .../compilers/llvm/8/clang/default.nix | 2 + 2 files changed, 55 insertions(+) create mode 100644 pkgs/development/compilers/llvm/8/clang/compiler-rt-baremetal.patch diff --git a/pkgs/development/compilers/llvm/8/clang/compiler-rt-baremetal.patch b/pkgs/development/compilers/llvm/8/clang/compiler-rt-baremetal.patch new file mode 100644 index 000000000000..a4a0f21b0fcd --- /dev/null +++ b/pkgs/development/compilers/llvm/8/clang/compiler-rt-baremetal.patch @@ -0,0 +1,53 @@ +Index: lib/Driver/ToolChains/BareMetal.cpp +=================================================================== +--- a/lib/Driver/ToolChains/BareMetal.cpp ++++ b/lib/Driver/ToolChains/BareMetal.cpp +@@ -157,7 +157,7 @@ + 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, +Index: test/Driver/baremetal.cpp +=================================================================== +--- a/test/Driver/baremetal.cpp ++++ b/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 \ diff --git a/pkgs/development/compilers/llvm/8/clang/default.nix b/pkgs/development/compilers/llvm/8/clang/default.nix index 0b38660c4c4d..4ba7aa62f62d 100644 --- a/pkgs/development/compilers/llvm/8/clang/default.nix +++ b/pkgs/development/compilers/llvm/8/clang/default.nix @@ -47,6 +47,8 @@ let # Backport for the `--unwindlib=[libgcc|compiler-rt]` flag, which is # needed for our bootstrapping to not interfere with C. ./unwindlib.patch + # https://reviews.llvm.org/D51899 + ./compiler-rt-baremetal.patch ]; postPatch = ''