From c863fa3468fd62b4e709fadc8c0713422da568e4 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 29 Jan 2015 19:08:51 +0000 Subject: [PATCH] [PowerPC] Work around TLS linker bug Work around a bug in GNU ld (and gold) linker versions up to 2.25 that may mis-optimize code generated by this version of clang/LLVM to access general-dynamic or local-dynamic TLS variables. Bug is fixed here: https://sourceware.org/ml/binutils/2015-01/msg00318.html git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227480 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 7 +++++++ test/Driver/ppc-features.cpp | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 1ff5be7b03..2258f69ef8 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -7515,6 +7515,13 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA, D.DyldPrefix + getLinuxDynamicLinker(Args, ToolChain))); } + // Work around a bug in GNU ld (and gold) linker versions up to 2.25 + // that may mis-optimize code generated by this version of clang/LLVM + // to access general-dynamic or local-dynamic TLS variables. + if (ToolChain.getArch() == llvm::Triple::ppc64 || + ToolChain.getArch() == llvm::Triple::ppc64le) + CmdArgs.push_back("--no-tls-optimize"); + CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); diff --git a/test/Driver/ppc-features.cpp b/test/Driver/ppc-features.cpp index 39d6357dcc..feecf3ceed 100644 --- a/test/Driver/ppc-features.cpp +++ b/test/Driver/ppc-features.cpp @@ -132,8 +132,10 @@ // linker features // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK_BE_LD_ARGS %s // CHECK_BE_LD_ARGS: "elf64ppc" +// CHECK_BE_LD_ARGS: "--no-tls-optimize" // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK_LE_LD_ARGS %s // CHECK_LE_LD_ARGS: "elf64lppc" +// CHECK_LE_LD_ARGS: "--no-tls-optimize" -- 2.40.0