overlay: remove llvmPackages_8
parent
8aff4142c9
commit
4b2ffc218b
|
@ -96,13 +96,6 @@ in {
|
|||
ncurses = null;
|
||||
};
|
||||
|
||||
llvmPackages_8 = callPackage ./llvm-8 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
inherit (final.genodePackages.genodeSources) genodeBase;
|
||||
buildLlvmTools = buildPackages.llvmPackages_8.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_8.libraries;
|
||||
});
|
||||
|
||||
llvmPackages_11 = callPackage ./llvm-11 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_11.tools;
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
{ runCommand, stdenv, llvm, lld, version }:
|
||||
|
||||
let
|
||||
prefix =
|
||||
if stdenv.hostPlatform != stdenv.targetPlatform
|
||||
then "${stdenv.targetPlatform.config}-"
|
||||
else "";
|
||||
in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } ''
|
||||
mkdir -p $out/bin
|
||||
for prog in ${lld}/bin/*; do
|
||||
ln -s $prog $out/bin/${prefix}$(basename $prog)
|
||||
done
|
||||
for prog in ${llvm}/bin/*; do
|
||||
ln -s $prog $out/bin/${prefix}$(echo $(basename $prog) | sed -e "s|llvm-||")
|
||||
ln -sf $prog $out/bin/${prefix}$(basename $prog)
|
||||
done
|
||||
rm -f $out/bin/${prefix}cat
|
||||
ln -s ${lld}/bin/lld $out/bin/${prefix}ld
|
||||
''
|
|
@ -1,41 +0,0 @@
|
|||
From 61c9b97d7b81cc2c013b423bf1763a92b14fcae3 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Korous <jkorous@apple.com>
|
||||
Date: Tue, 26 Mar 2019 03:48:25 +0000
|
||||
Subject: [PATCH] [clangd][xpc][cmake] Respect explicit value of
|
||||
CLANGD_BUILD_XPC
|
||||
|
||||
We shouldn't prevent user from disabling XPC framework build on Darwin.
|
||||
However, by keeping it on by default our CI systems also test
|
||||
it by default on macOS.
|
||||
|
||||
Based on user request:
|
||||
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061778.html
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D59808
|
||||
|
||||
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@356974 91177308-0d34-0410-b5e6-96231b3b80d8
|
||||
---
|
||||
CMakeLists.txt | 13 ++++++++++---
|
||||
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 66ebeaeeaa..514b17fb3c 100644
|
||||
--- a/tools/extra/CMakeLists.txt
|
||||
+++ b/tools/extra/CMakeLists.txt
|
||||
@@ -1,6 +1,13 @@
|
||||
-option(CLANGD_BUILD_XPC "Build XPC Support For Clangd." OFF)
|
||||
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
- set(CLANGD_BUILD_XPC ON CACHE BOOL "" FORCE)
|
||||
+if (NOT DEFINED CLANGD_BUILD_XPC)
|
||||
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
+ set(CLANGD_BUILD_XPC_DEFAULT ON)
|
||||
+ else ()
|
||||
+ set(CLANGD_BUILD_XPC_DEFAULT OFF)
|
||||
+ endif ()
|
||||
+
|
||||
+ set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC Support For Clangd." FORCE)
|
||||
+
|
||||
+ unset(CLANGD_BUILD_XPC_DEFAULT)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(clang-apply-replacements)
|
|
@ -1,53 +0,0 @@
|
|||
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 \
|
|
@ -1,131 +0,0 @@
|
|||
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python
|
||||
, fixDarwinDylibNames
|
||||
, enableManpages ? false
|
||||
, enablePolly ? false # TODO: get this info from llvm (passthru?)
|
||||
}:
|
||||
|
||||
let
|
||||
self = stdenv.mkDerivation ({
|
||||
name = "clang-${version}";
|
||||
|
||||
src = fetch "cfe" "0ihnbdl058gvl2wdy45p5am55bq8ifx8m9mhcsgj9ax8yxlzvvvh";
|
||||
|
||||
unpackPhase = ''
|
||||
unpackFile $src
|
||||
mv cfe-${version}* clang
|
||||
sourceRoot=$PWD/clang
|
||||
unpackFile ${clang-tools-extra_src}
|
||||
mv clang-tools-extra-* $sourceRoot/tools/extra
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ cmake python ]
|
||||
++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
|
||||
|
||||
buildInputs = [ libxml2 llvm ]
|
||||
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCMAKE_CXX_FLAGS=-std=c++11"
|
||||
"-DCLANGD_BUILD_XPC=OFF"
|
||||
] ++ stdenv.lib.optionals enableManpages [
|
||||
"-DCLANG_INCLUDE_DOCS=ON"
|
||||
"-DLLVM_ENABLE_SPHINX=ON"
|
||||
"-DSPHINX_OUTPUT_MAN=ON"
|
||||
"-DSPHINX_OUTPUT_HTML=OFF"
|
||||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
||||
] ++ stdenv.lib.optionals enablePolly [
|
||||
"-DWITH_POLLY=ON"
|
||||
"-DLINK_POLLY_INTO_TOOLS=ON"
|
||||
];
|
||||
|
||||
patches = [
|
||||
./purity.patch
|
||||
./clang-xpc.patch
|
||||
# Backport for -static-pie, which the latter touches, and which is nice in
|
||||
# its own right.
|
||||
./static-pie.patch
|
||||
# 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
|
||||
./genode.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
|
||||
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
|
||||
lib/Driver/ToolChains/*.cpp
|
||||
|
||||
# Patch for standalone doc building
|
||||
sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
|
||||
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
|
||||
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
|
||||
'' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
substituteInPlace tools/extra/clangd/CMakeLists.txt \
|
||||
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
|
||||
'';
|
||||
|
||||
outputs = [ "out" "lib" "python" ];
|
||||
|
||||
# Clang expects to find LLVMgold in its own prefix
|
||||
postInstall = ''
|
||||
if [ -e ${llvm}/lib/LLVMgold.so ]; then
|
||||
ln -sv ${llvm}/lib/LLVMgold.so $out/lib
|
||||
fi
|
||||
|
||||
ln -sv $out/bin/clang $out/bin/cpp
|
||||
|
||||
# Move libclang to 'lib' output
|
||||
moveToOutput "lib/libclang.*" "$lib"
|
||||
substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
|
||||
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang."
|
||||
|
||||
mkdir -p $python/bin $python/share/clang/
|
||||
mv $out/bin/{git-clang-format,scan-view} $python/bin
|
||||
if [ -e $out/bin/set-xcode-analyzer ]; then
|
||||
mv $out/bin/set-xcode-analyzer $python/bin
|
||||
fi
|
||||
mv $out/share/clang/*.py $python/share/clang
|
||||
rm $out/bin/c-index-test
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
passthru = {
|
||||
isClang = true;
|
||||
inherit llvm;
|
||||
} // stdenv.lib.optionalAttrs (stdenv.targetPlatform.isLinux || (stdenv.cc.isGNU && stdenv.cc.cc ? gcc)) {
|
||||
gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
|
||||
homepage = http://llvm.org/;
|
||||
license = stdenv.lib.licenses.ncsa;
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
};
|
||||
} // stdenv.lib.optionalAttrs enableManpages {
|
||||
name = "clang-manpages-${version}";
|
||||
|
||||
buildPhase = ''
|
||||
make docs-clang-man
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/man/man1
|
||||
# Manually install clang manpage
|
||||
cp docs/man/*.1 $out/share/man/man1/
|
||||
'';
|
||||
|
||||
outputs = [ "out" ];
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta.description = "man page for Clang ${version}";
|
||||
});
|
||||
in self
|
|
@ -1,375 +0,0 @@
|
|||
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
|
||||
index d02d9744d..b57a7cb05 100644
|
||||
--- a/include/clang/Driver/Options.td
|
||||
+++ b/include/clang/Driver/Options.td
|
||||
@@ -2452,6 +2452,7 @@ def nolibc : Flag<["-"], "nolibc">;
|
||||
def nomultidefs : Flag<["-"], "nomultidefs">;
|
||||
def nopie : Flag<["-"], "nopie">;
|
||||
def no_pie : Flag<["-"], "no-pie">, Alias<nopie>;
|
||||
+def noposix : Flag<["-"], "noposix">;
|
||||
def noprebind : Flag<["-"], "noprebind">;
|
||||
def noseglinkedit : Flag<["-"], "noseglinkedit">;
|
||||
def nostartfiles : Flag<["-"], "nostartfiles">;
|
||||
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
|
||||
index 3c139d724..89d6df3f5 100644
|
||||
--- a/lib/Basic/Targets.cpp
|
||||
+++ b/lib/Basic/Targets.cpp
|
||||
@@ -147,6 +147,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
return new FreeBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Fuchsia:
|
||||
return new FuchsiaTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
||||
+ case llvm::Triple::Genode:
|
||||
+ return new GenodeTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Linux:
|
||||
return new LinuxTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::NetBSD:
|
||||
@@ -171,6 +173,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
return new FreeBSDTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Fuchsia:
|
||||
return new FuchsiaTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
||||
+ case llvm::Triple::Genode:
|
||||
+ return new GenodeTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Linux:
|
||||
return new LinuxTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::NetBSD:
|
||||
@@ -528,6 +532,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||
return new FreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Fuchsia:
|
||||
return new FuchsiaTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
||||
+ case llvm::Triple::Genode:
|
||||
+ return new GenodeTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::KFreeBSD:
|
||||
return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
||||
case llvm::Triple::Solaris:
|
||||
diff --git a/lib/Basic/Targets/OSTargets.h b/lib/Basic/Targets/OSTargets.h
|
||||
index 09867d82c..f67151a13 100644
|
||||
--- a/lib/Basic/Targets/OSTargets.h
|
||||
+++ b/lib/Basic/Targets/OSTargets.h
|
||||
@@ -760,6 +760,26 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
+// Genode Target
|
||||
+template <typename Target>
|
||||
+class LLVM_LIBRARY_VISIBILITY GenodeTargetInfo : public OSTargetInfo<Target> {
|
||||
+protected:
|
||||
+ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
|
||||
+ MacroBuilder &Builder) const override {
|
||||
+ Builder.defineMacro("__GENODE__");
|
||||
+ Builder.defineMacro("__ELF__");
|
||||
+ // Required by the libc++ locale support.
|
||||
+ if (Opts.CPlusPlus)
|
||||
+ Builder.defineMacro("_GNU_SOURCE");
|
||||
+ }
|
||||
+
|
||||
+public:
|
||||
+ GenodeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
||||
+ : OSTargetInfo<Target>(Triple, Opts) {
|
||||
+ this->MCountName = "__mcount";
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
// WebAssembly target
|
||||
template <typename Target>
|
||||
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
|
||||
diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt
|
||||
index 4793a1f90..4691b898e 100644
|
||||
--- a/lib/Driver/CMakeLists.txt
|
||||
+++ b/lib/Driver/CMakeLists.txt
|
||||
@@ -44,6 +44,7 @@ add_clang_library(clangDriver
|
||||
ToolChains/DragonFly.cpp
|
||||
ToolChains/FreeBSD.cpp
|
||||
ToolChains/Fuchsia.cpp
|
||||
+ ToolChains/Genode.cpp
|
||||
ToolChains/Gnu.cpp
|
||||
ToolChains/Haiku.cpp
|
||||
ToolChains/HIP.cpp
|
||||
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
|
||||
index a784e218f..881b78abc 100644
|
||||
--- a/lib/Driver/Driver.cpp
|
||||
+++ b/lib/Driver/Driver.cpp
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ToolChains/DragonFly.h"
|
||||
#include "ToolChains/FreeBSD.h"
|
||||
#include "ToolChains/Fuchsia.h"
|
||||
+#include "ToolChains/Genode.h"
|
||||
#include "ToolChains/Gnu.h"
|
||||
#include "ToolChains/HIP.h"
|
||||
#include "ToolChains/Haiku.h"
|
||||
@@ -4570,6 +4571,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
|
||||
case llvm::Triple::Solaris:
|
||||
TC = llvm::make_unique<toolchains::Solaris>(*this, Target, Args);
|
||||
break;
|
||||
+ case llvm::Triple::Genode:
|
||||
+ TC = llvm::make_unique<toolchains::Genode>(*this, Target, Args);
|
||||
+ break;
|
||||
case llvm::Triple::AMDHSA:
|
||||
TC = llvm::make_unique<toolchains::AMDGPUToolChain>(*this, Target, Args);
|
||||
break;
|
||||
diff --git a/lib/Driver/SanitizerArgs.cpp b/lib/Driver/SanitizerArgs.cpp
|
||||
index 1a46073aa..72b6f7389 100644
|
||||
--- a/lib/Driver/SanitizerArgs.cpp
|
||||
+++ b/lib/Driver/SanitizerArgs.cpp
|
||||
@@ -693,7 +693,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
|
||||
ImplicitCfiRuntime = TC.getTriple().isAndroid();
|
||||
|
||||
if (AllAddedKinds & Address) {
|
||||
- NeedPIE |= TC.getTriple().isOSFuchsia();
|
||||
+ NeedPIE |= TC.getTriple().isOSFuchsia() | TC.getTriple().isOSGenode();
|
||||
if (Arg *A =
|
||||
Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
|
||||
StringRef S = A->getValue();
|
||||
diff --git a/lib/Driver/ToolChains/Genode.cpp b/lib/Driver/ToolChains/Genode.cpp
|
||||
new file mode 100644
|
||||
index 000000000..488863cb4
|
||||
--- /dev/null
|
||||
+++ b/lib/Driver/ToolChains/Genode.cpp
|
||||
@@ -0,0 +1,147 @@
|
||||
+//===--- Genode.cpp - Genode ToolChain Implementations ----------*- C++ -*-===//
|
||||
+//
|
||||
+// The LLVM Compiler Infrastructure
|
||||
+//
|
||||
+// This file is distributed under the University of Illinois Open Source
|
||||
+// License. See LICENSE.TXT for details.
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+
|
||||
+#include "Genode.h"
|
||||
+#include "InputInfo.h"
|
||||
+#include "CommonArgs.h"
|
||||
+#include "clang/Driver/Compilation.h"
|
||||
+#include "clang/Driver/Driver.h"
|
||||
+#include "clang/Driver/Options.h"
|
||||
+#include "llvm/ADT/SmallString.h"
|
||||
+#include "llvm/Option/ArgList.h"
|
||||
+#include "llvm/Support/Path.h"
|
||||
+
|
||||
+using namespace clang::driver;
|
||||
+using namespace clang::driver::tools;
|
||||
+using namespace clang::driver::toolchains;
|
||||
+using namespace clang;
|
||||
+using namespace llvm::opt;
|
||||
+
|
||||
+void genode::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
+ const InputInfo &Output,
|
||||
+ const InputInfoList &Inputs,
|
||||
+ const llvm::opt::ArgList &Args,
|
||||
+ const char *LinkingOutput) const {
|
||||
+ const toolchains::Genode &ToolChain =
|
||||
+ static_cast<const toolchains::Genode &>(getToolChain());
|
||||
+ const Driver &D = ToolChain.getDriver();
|
||||
+ const llvm::Triple::ArchType Arch = ToolChain.getArch();
|
||||
+ ArgStringList CmdArgs;
|
||||
+
|
||||
+ if (!D.SysRoot.empty())
|
||||
+ CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
|
||||
+
|
||||
+ // Explicitly set the linker emulation for platforms that might not
|
||||
+ // be the default emulation for the linker.
|
||||
+ switch (Arch) {
|
||||
+ case llvm::Triple::x86:
|
||||
+ CmdArgs.push_back("-melf_i386");
|
||||
+ break;
|
||||
+ case llvm::Triple::x86_64:
|
||||
+ CmdArgs.push_back("-melf_x86_64");
|
||||
+ break;
|
||||
+ case llvm::Triple::riscv32:
|
||||
+ CmdArgs.push_back("-melf32lriscv");
|
||||
+ break;
|
||||
+ case llvm::Triple::riscv64:
|
||||
+ CmdArgs.push_back("-melf64lriscv");
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ CmdArgs.push_back("--eh-frame-hdr");
|
||||
+ CmdArgs.push_back("--gc-sections");
|
||||
+ CmdArgs.push_back("-zmax-page-size=0x1000");
|
||||
+
|
||||
+ CmdArgs.push_back("-Ttext=0x01000000");
|
||||
+
|
||||
+ Args.AddAllArgs(CmdArgs, options::OPT_L);
|
||||
+ ToolChain.AddFilePathLibArgs(Args, CmdArgs);
|
||||
+ Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
|
||||
+ Args.AddAllArgs(CmdArgs, options::OPT_e);
|
||||
+ Args.AddAllArgs(CmdArgs, options::OPT_s);
|
||||
+ Args.AddAllArgs(CmdArgs, options::OPT_t);
|
||||
+ Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
|
||||
+
|
||||
+ if (Args.hasArg(options::OPT_static)) {
|
||||
+ CmdArgs.push_back("-Bstatic");
|
||||
+ } else {
|
||||
+ if (Args.hasArg(options::OPT_shared)) {
|
||||
+ CmdArgs.push_back(Args.MakeArgString("-shared"));
|
||||
+ CmdArgs.push_back(Args.MakeArgString("-T" + D.SysRoot + "/ld/genode_rel.ld"));
|
||||
+ } else {
|
||||
+ CmdArgs.push_back(Args.MakeArgString("-T" + D.SysRoot + "/ld/genode_dyn.ld"));
|
||||
+ CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + D.SysRoot + "/ld/genode_dyn.dl"));
|
||||
+ CmdArgs.push_back("--dynamic-linker=ld.lib.so");
|
||||
+ }
|
||||
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
|
||||
+ CmdArgs.push_back("-l:ld.lib.so");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (Output.isFilename()) {
|
||||
+ CmdArgs.push_back("-o");
|
||||
+ CmdArgs.push_back(Output.getFilename());
|
||||
+ } else {
|
||||
+ assert(Output.isNothing() && "Invalid output.");
|
||||
+ }
|
||||
+
|
||||
+ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
|
||||
+
|
||||
+ AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
|
||||
+
|
||||
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, options::OPT_noposix)) {
|
||||
+ CmdArgs.push_back("-lc");
|
||||
+ if (!Args.hasArg(options::OPT_shared)) {
|
||||
+ CmdArgs.push_back("-lposix");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
|
||||
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
|
||||
+}
|
||||
+
|
||||
+Genode::Genode(const Driver &D, const llvm::Triple &Triple,
|
||||
+ const llvm::opt::ArgList &Args)
|
||||
+ : Generic_ELF(D, Triple, Args) {
|
||||
+ SmallString<128> P(getDriver().Dir);
|
||||
+ llvm::sys::path::append(P, "..", getTriple().str(), "lib");
|
||||
+ getFilePaths().push_back(P.str());
|
||||
+}
|
||||
+
|
||||
+void Genode::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
|
||||
+ llvm::opt::ArgStringList &CC1Args) const {
|
||||
+ SmallString<128> P(getDriver().Dir);
|
||||
+ llvm::sys::path::append(P, "..", getTriple().str(), "include/c++/v1");
|
||||
+ addSystemInclude(DriverArgs, CC1Args, P.str());
|
||||
+}
|
||||
+
|
||||
+bool Genode::isPIEDefault() const {
|
||||
+ switch (getTriple().getArch()) {
|
||||
+ case llvm::Triple::aarch64:
|
||||
+ case llvm::Triple::x86_64:
|
||||
+ return true;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+SanitizerMask Genode::getSupportedSanitizers() const {
|
||||
+ return Generic_ELF::getSupportedSanitizers();
|
||||
+}
|
||||
+
|
||||
+SanitizerMask Genode::getDefaultSanitizers() const {
|
||||
+ return Generic_ELF::getDefaultSanitizers();
|
||||
+}
|
||||
+
|
||||
+Tool *Genode::buildLinker() const {
|
||||
+ return new tools::genode::Linker(*this);
|
||||
+}
|
||||
diff --git a/lib/Driver/ToolChains/Genode.h b/lib/Driver/ToolChains/Genode.h
|
||||
new file mode 100644
|
||||
index 000000000..144f4f99a
|
||||
--- /dev/null
|
||||
+++ b/lib/Driver/ToolChains/Genode.h
|
||||
@@ -0,0 +1,69 @@
|
||||
+//===----- Genode.h - Genode ToolChain Implementations ----------*- C++ -*-===//
|
||||
+//
|
||||
+// The LLVM Compiler Infrastructure
|
||||
+//
|
||||
+// This file is distributed under the University of Illinois Open Source
|
||||
+// License. See LICENSE.TXT for details.
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+
|
||||
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
|
||||
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
|
||||
+
|
||||
+#include "Gnu.h"
|
||||
+#include "clang/Driver/Tool.h"
|
||||
+#include "clang/Driver/ToolChain.h"
|
||||
+
|
||||
+namespace clang {
|
||||
+namespace driver {
|
||||
+namespace tools {
|
||||
+
|
||||
+//// genode -- Directly call GNU Binutils linker
|
||||
+namespace genode {
|
||||
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
|
||||
+public:
|
||||
+ Linker(const ToolChain &TC) : GnuTool("genode::Linker", "linker", TC) {}
|
||||
+
|
||||
+ bool hasIntegratedCPP() const override { return false; }
|
||||
+ bool isLinkJob() const override { return true; }
|
||||
+
|
||||
+ void ConstructJob(Compilation &C, const JobAction &JA,
|
||||
+ const InputInfo &Output, const InputInfoList &Inputss,
|
||||
+ const llvm::opt::ArgList &Args,
|
||||
+ const char *LinkingOutput) const override;
|
||||
+};
|
||||
+} // end namespace genode
|
||||
+} // end namespace tools
|
||||
+
|
||||
+namespace toolchains {
|
||||
+
|
||||
+class LLVM_LIBRARY_VISIBILITY Genode : public Generic_ELF {
|
||||
+public:
|
||||
+ Genode(const Driver &D, const llvm::Triple &Triple,
|
||||
+ const llvm::opt::ArgList &Args);
|
||||
+ bool HasNativeLLVMSupport() const override { return true; }
|
||||
+
|
||||
+ bool IsMathErrnoDefault() const override { return true; }
|
||||
+
|
||||
+ CXXStdlibType
|
||||
+ GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
|
||||
+ return ToolChain::CST_Libcxx;
|
||||
+ }
|
||||
+ void addLibCxxIncludePaths(
|
||||
+ const llvm::opt::ArgList &DriverArgs,
|
||||
+ llvm::opt::ArgStringList &CC1Args) const override;
|
||||
+
|
||||
+ bool isPIEDefault() const override;
|
||||
+ SanitizerMask getSupportedSanitizers() const override;
|
||||
+ SanitizerMask getDefaultSanitizers() const override;
|
||||
+
|
||||
+protected:
|
||||
+ Tool *buildLinker() const override;
|
||||
+};
|
||||
+
|
||||
+} // end namespace toolchains
|
||||
+} // end namespace driver
|
||||
+} // end namespace clang
|
||||
+
|
||||
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
|
||||
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
|
||||
index 67842b5dc..26a2c65fe 100644
|
||||
--- a/lib/Frontend/InitHeaderSearch.cpp
|
||||
+++ b/lib/Frontend/InitHeaderSearch.cpp
|
||||
@@ -221,6 +221,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
|
||||
case llvm::Triple::PS4:
|
||||
case llvm::Triple::ELFIAMCU:
|
||||
case llvm::Triple::Fuchsia:
|
||||
+ case llvm::Triple::Genode:
|
||||
break;
|
||||
case llvm::Triple::Win32:
|
||||
if (triple.getEnvironment() != llvm::Triple::Cygnus)
|
||||
@@ -329,6 +330,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
|
||||
case llvm::Triple::NaCl:
|
||||
case llvm::Triple::ELFIAMCU:
|
||||
case llvm::Triple::Fuchsia:
|
||||
+ case llvm::Triple::Genode:
|
||||
break;
|
||||
case llvm::Triple::PS4: {
|
||||
// <isysroot> gets prepended later in AddPath().
|
||||
diff --git a/test/Driver/genode.c b/test/Driver/genode.c
|
||||
new file mode 100644
|
||||
index 000000000..e69de29bb
|
||||
diff --git a/test/Driver/genode.cpp b/test/Driver/genode.cpp
|
||||
new file mode 100644
|
||||
index 000000000..e69de29bb
|
|
@ -1,30 +0,0 @@
|
|||
From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
|
||||
From: Will Dietz <w@wdtz.org>
|
||||
Date: Thu, 18 May 2017 11:56:12 -0500
|
||||
Subject: [PATCH] "purity" patch for 5.0
|
||||
|
||||
---
|
||||
lib/Driver/ToolChains/Gnu.cpp | 7 -------
|
||||
1 file changed, 7 deletions(-)
|
||||
|
||||
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
|
||||
index fe3c0191bb..c6a482bece 100644
|
||||
--- a/lib/Driver/ToolChains/Gnu.cpp
|
||||
+++ b/lib/Driver/ToolChains/Gnu.cpp
|
||||
@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
if (!Args.hasArg(options::OPT_static)) {
|
||||
if (Args.hasArg(options::OPT_rdynamic))
|
||||
CmdArgs.push_back("-export-dynamic");
|
||||
-
|
||||
- if (!Args.hasArg(options::OPT_shared)) {
|
||||
- const std::string Loader =
|
||||
- D.DyldPrefix + ToolChain.getDynamicLinker(Args);
|
||||
- CmdArgs.push_back("-dynamic-linker");
|
||||
- CmdArgs.push_back(Args.MakeArgString(Loader));
|
||||
- }
|
||||
}
|
||||
|
||||
CmdArgs.push_back("-o");
|
||||
--
|
||||
2.11.0
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
commit 7a9842bc92921e79b84630045276861be90b2d47
|
||||
Author: Siva Chandra <sivachandra@google.com>
|
||||
Date: Wed Feb 20 19:07:04 2019 +0000
|
||||
|
||||
[Clang Driver] Add support for "-static-pie" argument to the Clang driver.
|
||||
|
||||
Summary: This change mimics GCC's support for the "-static-pie" argument.
|
||||
|
||||
Subscribers: cfe-commits
|
||||
|
||||
Tags: #clang
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D58307
|
||||
|
||||
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354502 91177308-0d34-0410-b5e6-96231b3b80d8
|
||||
(cherry picked from commit 7d6cd7825e6883f8650e32b07f3750824c2cef62)
|
||||
|
||||
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
|
||||
index d02d9744d7..75a21e66c7 100644
|
||||
--- a/include/clang/Driver/Options.td
|
||||
+++ b/include/clang/Driver/Options.td
|
||||
@@ -2502,6 +2502,7 @@ def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,
|
||||
def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>;
|
||||
def p : Flag<["-"], "p">;
|
||||
def pie : Flag<["-"], "pie">;
|
||||
+def static_pie : Flag<["-"], "static-pie">;
|
||||
def read__only__relocs : Separate<["-"], "read_only_relocs">;
|
||||
def remap : Flag<["-"], "remap">;
|
||||
def rewrite_objc : Flag<["-"], "rewrite-objc">, Flags<[DriverOption,CC1Option]>,
|
||||
diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
index d7e316befa..85ffc1618d 100644
|
||||
--- a/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
@@ -1138,19 +1138,22 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
|
||||
bool isCygMing = Triple.isOSCygMing();
|
||||
bool IsIAMCU = Triple.isOSIAMCU();
|
||||
bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
|
||||
- Args.hasArg(options::OPT_static);
|
||||
+ Args.hasArg(options::OPT_static) ||
|
||||
+ Args.hasArg(options::OPT_static_pie);
|
||||
|
||||
bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc);
|
||||
bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc;
|
||||
|
||||
// Gcc adds libgcc arguments in various ways:
|
||||
//
|
||||
- // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
|
||||
- // g++ <none>: -lgcc_s -lgcc
|
||||
- // gcc shared: -lgcc_s -lgcc
|
||||
- // g++ shared: -lgcc_s -lgcc
|
||||
- // gcc static: -lgcc -lgcc_eh
|
||||
- // g++ static: -lgcc -lgcc_eh
|
||||
+ // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
|
||||
+ // g++ <none>: -lgcc_s -lgcc
|
||||
+ // gcc shared: -lgcc_s -lgcc
|
||||
+ // g++ shared: -lgcc_s -lgcc
|
||||
+ // gcc static: -lgcc -lgcc_eh
|
||||
+ // g++ static: -lgcc -lgcc_eh
|
||||
+ // gcc static-pie: -lgcc -lgcc_eh
|
||||
+ // g++ static-pie: -lgcc -lgcc_eh
|
||||
//
|
||||
// Also, certain targets need additional adjustments.
|
||||
|
||||
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
|
||||
index 69dba8fec8..0faa0bb473 100644
|
||||
--- a/lib/Driver/ToolChains/Gnu.cpp
|
||||
+++ b/lib/Driver/ToolChains/Gnu.cpp
|
||||
@@ -334,6 +334,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
const bool isAndroid = ToolChain.getTriple().isAndroid();
|
||||
const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
|
||||
const bool IsPIE = getPIE(Args, ToolChain);
|
||||
+ const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
|
||||
const bool HasCRTBeginEndFiles =
|
||||
ToolChain.getTriple().hasEnvironment() ||
|
||||
(ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);
|
||||
@@ -354,6 +355,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
if (IsPIE)
|
||||
CmdArgs.push_back("-pie");
|
||||
|
||||
+ if (IsStaticPIE) {
|
||||
+ CmdArgs.push_back("-static");
|
||||
+ CmdArgs.push_back("-pie");
|
||||
+ CmdArgs.push_back("--no-dynamic-linker");
|
||||
+ }
|
||||
+
|
||||
if (Args.hasArg(options::OPT_rdynamic))
|
||||
CmdArgs.push_back("-export-dynamic");
|
||||
|
||||
@@ -415,6 +422,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
crt1 = "gcrt1.o";
|
||||
else if (IsPIE)
|
||||
crt1 = "Scrt1.o";
|
||||
+ else if (IsStaticPIE)
|
||||
+ crt1 = "rcrt1.o";
|
||||
else
|
||||
crt1 = "crt1.o";
|
||||
}
|
||||
@@ -432,7 +441,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
|
||||
else if (Args.hasArg(options::OPT_shared))
|
||||
crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
|
||||
- else if (IsPIE)
|
||||
+ else if (IsPIE || IsStaticPIE)
|
||||
crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
|
||||
else
|
||||
crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
|
||||
@@ -483,7 +492,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
|
||||
if (!Args.hasArg(options::OPT_nostdlib)) {
|
||||
if (!Args.hasArg(options::OPT_nodefaultlibs)) {
|
||||
- if (Args.hasArg(options::OPT_static))
|
||||
+ if (Args.hasArg(options::OPT_static) || IsStaticPIE)
|
||||
CmdArgs.push_back("--start-group");
|
||||
|
||||
if (NeedsSanitizerDeps)
|
||||
@@ -518,7 +527,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
if (IsIAMCU)
|
||||
CmdArgs.push_back("-lgloss");
|
||||
|
||||
- if (Args.hasArg(options::OPT_static))
|
||||
+ if (Args.hasArg(options::OPT_static) || IsStaticPIE)
|
||||
CmdArgs.push_back("--end-group");
|
||||
else
|
||||
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
|
||||
@@ -535,7 +544,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
const char *crtend;
|
||||
if (Args.hasArg(options::OPT_shared))
|
||||
crtend = isAndroid ? "crtend_so.o" : "crtendS.o";
|
||||
- else if (IsPIE)
|
||||
+ else if (IsPIE || IsStaticPIE)
|
||||
crtend = isAndroid ? "crtend_android.o" : "crtendS.o";
|
||||
else
|
||||
crtend = isAndroid ? "crtend_android.o" : "crtend.o";
|
||||
diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
|
||||
index 3ab81be490..800f782523 100644
|
||||
--- a/test/Driver/linux-ld.c
|
||||
+++ b/test/Driver/linux-ld.c
|
||||
@@ -176,6 +176,19 @@
|
||||
// CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
|
||||
// CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
|
||||
//
|
||||
+// RUN: %clang -static-pie -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
|
||||
+// RUN: --gcc-toolchain="" \
|
||||
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
|
||||
+// RUN: | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE %s
|
||||
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
|
||||
+// CHECK-CLANG-LD-STATIC-PIE: "-static"
|
||||
+// CHECK-CLANG-LD-STATIC-PIE: "-pie"
|
||||
+// CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
|
||||
+// CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
|
||||
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
|
||||
+// CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
|
||||
+//
|
||||
// RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
// RUN: --target=x86_64-unknown-linux -rtlib=platform \
|
||||
// RUN: --gcc-toolchain="" \
|
|
@ -1,372 +0,0 @@
|
|||
commit cd5603a4767277a29d3e67a9c3f2a5d2129cd973
|
||||
Author: Sterling Augustine <saugustine@google.com>
|
||||
Date: Tue Mar 19 20:01:59 2019 +0000
|
||||
|
||||
Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]
|
||||
|
||||
"clang++ hello.cc --rtlib=compiler-rt"
|
||||
|
||||
now can works without specifying additional unwind or exception
|
||||
handling libraries.
|
||||
|
||||
This reworked version of the feature no longer modifies today's default
|
||||
unwind library for compiler-rt: which is nothing. Rather, a user
|
||||
can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring
|
||||
the compiler.
|
||||
|
||||
This should address the issues from the previous version.
|
||||
|
||||
Update tests for new --unwindlib semantics.
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D59109
|
||||
|
||||
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356508 91177308-0d34-0410-b5e6-96231b3b80d8
|
||||
(cherry picked from commit 344aa82a52f2fae527f58284567ae305a314f7a8)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index c2016a45ca..edeb2b66a1 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -261,6 +261,24 @@ if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR
|
||||
"Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE)
|
||||
endif()
|
||||
|
||||
+set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
|
||||
+ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)")
|
||||
+if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
|
||||
+ if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
|
||||
+ set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
|
||||
+ elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind")
|
||||
+ set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
|
||||
+ endif()
|
||||
+endif()
|
||||
+
|
||||
+if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR
|
||||
+ CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR
|
||||
+ CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
|
||||
+ message(WARNING "Resetting default unwindlib to use platform default")
|
||||
+ set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
|
||||
+ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE)
|
||||
+endif()
|
||||
+
|
||||
set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
|
||||
"Default objcopy executable to use.")
|
||||
|
||||
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
index 5475e28ed7..15971210e4 100644
|
||||
--- a/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
+++ b/include/clang/Basic/DiagnosticDriverKinds.td
|
||||
@@ -52,6 +52,10 @@ def err_drv_invalid_rtlib_name : Error<
|
||||
"invalid runtime library name in argument '%0'">;
|
||||
def err_drv_unsupported_rtlib_for_platform : Error<
|
||||
"unsupported runtime library '%0' for platform '%1'">;
|
||||
+def err_drv_invalid_unwindlib_name : Error<
|
||||
+ "invalid unwind library name in argument '%0'">;
|
||||
+def err_drv_incompatible_unwindlib : Error<
|
||||
+ "--rtlib=libgcc requires --unwindlib=libgcc">;
|
||||
def err_drv_invalid_stdlib_name : Error<
|
||||
"invalid library name in argument '%0'">;
|
||||
def err_drv_invalid_output_with_multiple_archs : Error<
|
||||
diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake
|
||||
index 1d624450b9..2d4cb747e8 100644
|
||||
--- a/include/clang/Config/config.h.cmake
|
||||
+++ b/include/clang/Config/config.h.cmake
|
||||
@@ -23,6 +23,9 @@
|
||||
/* Default runtime library to use. */
|
||||
#define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
|
||||
|
||||
+/* Default unwind library to use. */
|
||||
+#define CLANG_DEFAULT_UNWINDLIB "${CLANG_DEFAULT_UNWINDLIB}"
|
||||
+
|
||||
/* Default objcopy to use */
|
||||
#define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}"
|
||||
|
||||
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
|
||||
index 75a21e66c7..4da0e54965 100644
|
||||
--- a/include/clang/Driver/Options.td
|
||||
+++ b/include/clang/Driver/Options.td
|
||||
@@ -2570,6 +2570,8 @@ def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
|
||||
}]>;
|
||||
def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
|
||||
HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
|
||||
+def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
|
||||
+ HelpText<"Unwind library to use">, Values<"libgcc,unwindlib,platform">;
|
||||
def sub__library : JoinedOrSeparate<["-"], "sub_library">;
|
||||
def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">;
|
||||
def system_header_prefix : Joined<["--"], "system-header-prefix=">,
|
||||
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h
|
||||
index d5f75b8271..4bedf760eb 100644
|
||||
--- a/include/clang/Driver/ToolChain.h
|
||||
+++ b/include/clang/Driver/ToolChain.h
|
||||
@@ -100,6 +100,12 @@ public:
|
||||
RLT_Libgcc
|
||||
};
|
||||
|
||||
+ enum UnwindLibType {
|
||||
+ UNW_None,
|
||||
+ UNW_CompilerRT,
|
||||
+ UNW_Libgcc
|
||||
+ };
|
||||
+
|
||||
enum RTTIMode {
|
||||
RM_Enabled,
|
||||
RM_Disabled,
|
||||
@@ -368,6 +374,10 @@ public:
|
||||
return ToolChain::CST_Libstdcxx;
|
||||
}
|
||||
|
||||
+ virtual UnwindLibType GetDefaultUnwindLibType() const {
|
||||
+ return ToolChain::UNW_None;
|
||||
+ }
|
||||
+
|
||||
virtual std::string getCompilerRTPath() const;
|
||||
|
||||
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
|
||||
@@ -512,6 +522,10 @@ public:
|
||||
// given compilation arguments.
|
||||
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
|
||||
|
||||
+ // GetUnwindLibType - Determine the unwind library type to use with the
|
||||
+ // given compilation arguments.
|
||||
+ virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const;
|
||||
+
|
||||
/// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
|
||||
/// the include paths to use for the given C++ standard library type.
|
||||
virtual void
|
||||
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
|
||||
index 88a627eab6..d82423f4a8 100644
|
||||
--- a/lib/Driver/ToolChain.cpp
|
||||
+++ b/lib/Driver/ToolChain.cpp
|
||||
@@ -680,6 +680,33 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
|
||||
return GetDefaultRuntimeLibType();
|
||||
}
|
||||
|
||||
+ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
|
||||
+ const ArgList &Args) const {
|
||||
+ const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
|
||||
+ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;
|
||||
+
|
||||
+ if (LibName == "none")
|
||||
+ return ToolChain::UNW_None;
|
||||
+ else if (LibName == "platform" || LibName == "") {
|
||||
+ ToolChain::RuntimeLibType RtLibType = GetRuntimeLibType(Args);
|
||||
+ if (RtLibType == ToolChain::RLT_CompilerRT)
|
||||
+ return ToolChain::UNW_None;
|
||||
+ else if (RtLibType == ToolChain::RLT_Libgcc)
|
||||
+ return ToolChain::UNW_Libgcc;
|
||||
+ } else if (LibName == "libunwind") {
|
||||
+ if (GetRuntimeLibType(Args) == RLT_Libgcc)
|
||||
+ getDriver().Diag(diag::err_drv_incompatible_unwindlib);
|
||||
+ return ToolChain::UNW_CompilerRT;
|
||||
+ } else if (LibName == "libgcc")
|
||||
+ return ToolChain::UNW_Libgcc;
|
||||
+
|
||||
+ if (A)
|
||||
+ getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
|
||||
+ << A->getAsString(Args);
|
||||
+
|
||||
+ return GetDefaultUnwindLibType();
|
||||
+}
|
||||
+
|
||||
ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
|
||||
const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
|
||||
StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
|
||||
diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
index 85ffc1618d..9fd29726a4 100644
|
||||
--- a/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
|
||||
@@ -1132,47 +1132,80 @@ bool tools::isObjCAutoRefCount(const ArgList &Args) {
|
||||
return Args.hasFlag(options::OPT_fobjc_arc, options::OPT_fno_objc_arc, false);
|
||||
}
|
||||
|
||||
-static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
|
||||
- ArgStringList &CmdArgs, const ArgList &Args) {
|
||||
- bool isAndroid = Triple.isAndroid();
|
||||
- bool isCygMing = Triple.isOSCygMing();
|
||||
- bool IsIAMCU = Triple.isOSIAMCU();
|
||||
- bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
|
||||
- Args.hasArg(options::OPT_static) ||
|
||||
- Args.hasArg(options::OPT_static_pie);
|
||||
-
|
||||
- bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc);
|
||||
- bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc;
|
||||
-
|
||||
- // Gcc adds libgcc arguments in various ways:
|
||||
- //
|
||||
- // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
|
||||
- // g++ <none>: -lgcc_s -lgcc
|
||||
- // gcc shared: -lgcc_s -lgcc
|
||||
- // g++ shared: -lgcc_s -lgcc
|
||||
- // gcc static: -lgcc -lgcc_eh
|
||||
- // g++ static: -lgcc -lgcc_eh
|
||||
- // gcc static-pie: -lgcc -lgcc_eh
|
||||
- // g++ static-pie: -lgcc -lgcc_eh
|
||||
- //
|
||||
- // Also, certain targets need additional adjustments.
|
||||
+enum class LibGccType { UnspecifiedLibGcc, StaticLibGcc, SharedLibGcc };
|
||||
+
|
||||
+static LibGccType getLibGccType(const ArgList &Args) {
|
||||
+ bool Static = Args.hasArg(options::OPT_static_libgcc) ||
|
||||
+ Args.hasArg(options::OPT_static) ||
|
||||
+ Args.hasArg(options::OPT_static_pie);
|
||||
+
|
||||
+ bool Shared = Args.hasArg(options::OPT_shared_libgcc);
|
||||
+ if (Shared)
|
||||
+ return LibGccType::SharedLibGcc;
|
||||
+ if (Static)
|
||||
+ return LibGccType::StaticLibGcc;
|
||||
+ return LibGccType::UnspecifiedLibGcc;
|
||||
+}
|
||||
|
||||
- bool LibGccFirst = (D.CCCIsCC() && UnspecifiedLibgcc) || StaticLibgcc;
|
||||
- if (LibGccFirst)
|
||||
- CmdArgs.push_back("-lgcc");
|
||||
+// Gcc adds libgcc arguments in various ways:
|
||||
+//
|
||||
+// gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
|
||||
+// g++ <none>: -lgcc_s -lgcc
|
||||
+// gcc shared: -lgcc_s -lgcc
|
||||
+// g++ shared: -lgcc_s -lgcc
|
||||
+// gcc static: -lgcc -lgcc_eh
|
||||
+// g++ static: -lgcc -lgcc_eh
|
||||
+// gcc static-pie: -lgcc -lgcc_eh
|
||||
+// g++ static-pie: -lgcc -lgcc_eh
|
||||
+//
|
||||
+// Also, certain targets need additional adjustments.
|
||||
+
|
||||
+static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
|
||||
+ ArgStringList &CmdArgs, const ArgList &Args) {
|
||||
+ ToolChain::UnwindLibType UNW = TC.GetUnwindLibType(Args);
|
||||
+ // Targets that don't use unwind libraries.
|
||||
+ if (TC.getTriple().isAndroid() || TC.getTriple().isOSIAMCU() ||
|
||||
+ TC.getTriple().isOSBinFormatWasm() ||
|
||||
+ UNW == ToolChain::UNW_None)
|
||||
+ return;
|
||||
|
||||
- bool AsNeeded = D.CCCIsCC() && UnspecifiedLibgcc && !isAndroid && !isCygMing;
|
||||
+ LibGccType LGT = getLibGccType(Args);
|
||||
+ bool AsNeeded = D.CCCIsCC() && LGT == LibGccType::UnspecifiedLibGcc &&
|
||||
+ !TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing();
|
||||
if (AsNeeded)
|
||||
CmdArgs.push_back("--as-needed");
|
||||
|
||||
- if ((UnspecifiedLibgcc || SharedLibgcc) && !isAndroid)
|
||||
- CmdArgs.push_back("-lgcc_s");
|
||||
-
|
||||
- else if (StaticLibgcc && !isAndroid && !IsIAMCU)
|
||||
- CmdArgs.push_back("-lgcc_eh");
|
||||
+ switch (UNW) {
|
||||
+ case ToolChain::UNW_None:
|
||||
+ return;
|
||||
+ case ToolChain::UNW_Libgcc: {
|
||||
+ LibGccType LGT = getLibGccType(Args);
|
||||
+ if (LGT == LibGccType::UnspecifiedLibGcc || LGT == LibGccType::SharedLibGcc)
|
||||
+ CmdArgs.push_back("-lgcc_s");
|
||||
+ else if (LGT == LibGccType::StaticLibGcc)
|
||||
+ CmdArgs.push_back("-lgcc_eh");
|
||||
+ break;
|
||||
+ }
|
||||
+ case ToolChain::UNW_CompilerRT:
|
||||
+ CmdArgs.push_back("-lunwind");
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
if (AsNeeded)
|
||||
CmdArgs.push_back("--no-as-needed");
|
||||
+}
|
||||
+
|
||||
+static void AddLibgcc(const ToolChain &TC, const Driver &D,
|
||||
+ ArgStringList &CmdArgs, const ArgList &Args) {
|
||||
+ bool isAndroid = TC.getTriple().isAndroid();
|
||||
+
|
||||
+ LibGccType LGT = getLibGccType(Args);
|
||||
+ bool LibGccFirst = (D.CCCIsCC() && LGT == LibGccType::UnspecifiedLibGcc) ||
|
||||
+ LGT == LibGccType::StaticLibGcc;
|
||||
+ if (LibGccFirst)
|
||||
+ CmdArgs.push_back("-lgcc");
|
||||
+
|
||||
+ AddUnwindLibrary(TC, D, CmdArgs, Args);
|
||||
|
||||
if (!LibGccFirst)
|
||||
CmdArgs.push_back("-lgcc");
|
||||
@@ -1182,7 +1215,7 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
|
||||
//
|
||||
// NOTE: This fixes a link error on Android MIPS as well. The non-static
|
||||
// libgcc for MIPS relies on _Unwind_Find_FDE and dl_iterate_phdr from libdl.
|
||||
- if (isAndroid && !StaticLibgcc)
|
||||
+ if (isAndroid && getLibGccType(Args) != LibGccType::StaticLibGcc)
|
||||
CmdArgs.push_back("-ldl");
|
||||
}
|
||||
|
||||
@@ -1194,6 +1227,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
|
||||
switch (RLT) {
|
||||
case ToolChain::RLT_CompilerRT:
|
||||
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
|
||||
+ AddUnwindLibrary(TC, D, CmdArgs, Args);
|
||||
break;
|
||||
case ToolChain::RLT_Libgcc:
|
||||
// Make sure libgcc is not used under MSVC environment by default
|
||||
@@ -1205,7 +1239,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
|
||||
<< Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "MSVC";
|
||||
}
|
||||
} else
|
||||
- AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
|
||||
+ AddLibgcc(TC, D, CmdArgs, Args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
diff --git a/test/Driver/compiler-rt-unwind.c b/test/Driver/compiler-rt-unwind.c
|
||||
new file mode 100644
|
||||
index 0000000000..00024dfa7e
|
||||
--- /dev/null
|
||||
+++ b/test/Driver/compiler-rt-unwind.c
|
||||
@@ -0,0 +1,49 @@
|
||||
+// General tests that the driver handles combinations of --rtlib=XXX and
|
||||
+// --unwindlib=XXX properly.
|
||||
+//
|
||||
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
+// RUN: --target=x86_64-unknown-linux \
|
||||
+// RUN: --gcc-toolchain="" \
|
||||
+// RUN: | FileCheck --check-prefix=RTLIB-EMPTY %s
|
||||
+// RTLIB-EMPTY: "{{.*}}lgcc"
|
||||
+// RTLIB-EMPTY: "{{.*}}-lgcc_s"
|
||||
+//
|
||||
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc \
|
||||
+// RUN: --gcc-toolchain="" \
|
||||
+// RUN: | FileCheck --check-prefix=RTLIB-GCC %s
|
||||
+// RTLIB-GCC: "{{.*}}lgcc"
|
||||
+// RTLIB-GCC: "{{.*}}lgcc_s"
|
||||
+//
|
||||
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
|
||||
+// RUN: --gcc-toolchain="" \
|
||||
+// RUN: | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s
|
||||
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
|
||||
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
|
||||
+//
|
||||
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt \
|
||||
+// RUN: --gcc-toolchain="" \
|
||||
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT %s
|
||||
+// RTLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
|
||||
+//
|
||||
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \
|
||||
+// RUN: --gcc-toolchain="" \
|
||||
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC %s
|
||||
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}libclang_rt.builtins-x86_64.a"
|
||||
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}lgcc_s"
|
||||
+//
|
||||
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
||||
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \
|
||||
+// RUN: -static --gcc-toolchain="" \
|
||||
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC %s
|
||||
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}libclang_rt.builtins-x86_64.a"
|
||||
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}lgcc_eh"
|
||||
+//
|
||||
+// RUN: not %clang -no-canonical-prefixes %s -o %t.o 2> %t.err \
|
||||
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
|
||||
+// RUN: --gcc-toolchain="" \
|
||||
+// RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
|
||||
+// RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc"
|
|
@ -1,33 +0,0 @@
|
|||
From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001
|
||||
From: Will Dietz <w@wdtz.org>
|
||||
Date: Tue, 19 Sep 2017 13:13:06 -0500
|
||||
Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that
|
||||
needs it
|
||||
|
||||
---
|
||||
cmake/Modules/AddCompilerRT.cmake | 8 ------
|
||||
test/asan/CMakeLists.txt | 52 ---------------------------------------
|
||||
test/tsan/CMakeLists.txt | 47 -----------------------------------
|
||||
3 files changed, 107 deletions(-)
|
||||
|
||||
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
|
||||
index bc5fb9ff7..b64eb4246 100644
|
||||
--- a/cmake/Modules/AddCompilerRT.cmake
|
||||
+++ b/cmake/Modules/AddCompilerRT.cmake
|
||||
@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type)
|
||||
set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
|
||||
set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
|
||||
endif()
|
||||
- if(APPLE)
|
||||
- # Ad-hoc sign the dylibs
|
||||
- add_custom_command(TARGET ${libname}
|
||||
- POST_BUILD
|
||||
- COMMAND codesign --sign - $<TARGET_FILE:${libname}>
|
||||
- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
|
||||
- )
|
||||
- endif()
|
||||
endif()
|
||||
install(TARGETS ${libname}
|
||||
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
|
||||
2.14.1
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
diff --git a/lib/builtins/assembly.h b/lib/builtins/assembly.h
|
||||
index 3f5e59b2544..97d06d6ccd1 100644
|
||||
--- a/lib/builtins/assembly.h
|
||||
+++ b/lib/builtins/assembly.h
|
||||
@@ -45,7 +45,7 @@
|
||||
#define CONST_SECTION .section .rodata
|
||||
|
||||
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
|
||||
- defined(__linux__)
|
||||
+ defined(__linux__) || defined(__GENODE__)
|
||||
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
|
||||
#else
|
||||
#define NO_EXEC_STACK_DIRECTIVE
|
|
@ -1,75 +0,0 @@
|
|||
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
|
||||
stdenv.mkDerivation {
|
||||
pname = "compiler-rt";
|
||||
inherit version;
|
||||
src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi";
|
||||
|
||||
nativeBuildInputs = [ cmake python llvm ];
|
||||
buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
|
||||
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
||||
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
||||
] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||
] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
|
||||
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||
] ++ stdenv.lib.optionals (stdenv.hostPlatform.parsed.kernel.name == "none") [
|
||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||
"-DCOMPILER_RT_OS_DIR=baremetal"
|
||||
];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
patches = [
|
||||
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
|
||||
./compiler-rt-genode.patch
|
||||
]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
||||
++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch;
|
||||
|
||||
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
||||
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
||||
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
||||
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
|
||||
# a flag and turn the flag off during the stdenv build.
|
||||
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
|
||||
substituteInPlace cmake/config-ix.cmake \
|
||||
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
|
||||
'' + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
||||
substituteInPlace lib/builtins/int_util.c \
|
||||
--replace "#include <stdlib.h>" ""
|
||||
substituteInPlace lib/builtins/clear_cache.c \
|
||||
--replace "#include <assert.h>" ""
|
||||
substituteInPlace lib/builtins/cpu_model.c \
|
||||
--replace "#include <assert.h>" ""
|
||||
'';
|
||||
|
||||
# Hack around weird upsream RPATH bug
|
||||
postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
|
||||
ln -s "$out/lib"/*/* "$out/lib"
|
||||
'' + stdenv.lib.optionalString (stdenv.hostPlatform.useLLVM or false) ''
|
||||
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
|
||||
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
|
||||
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
||||
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
diff --git a/lib/builtins/assembly.h b/lib/builtins/assembly.h
|
||||
index 3f5e59b2544..97d06d6ccd1 100644
|
||||
--- a/lib/builtins/assembly.h
|
||||
+++ b/lib/builtins/assembly.h
|
||||
@@ -45,7 +45,7 @@
|
||||
#define CONST_SECTION .section .rodata
|
||||
|
||||
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
|
||||
- defined(__linux__)
|
||||
+ defined(__linux__) || defined(__GENODE__)
|
||||
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
|
||||
#else
|
||||
#define NO_EXEC_STACK_DIRECTIVE
|
|
@ -1,595 +0,0 @@
|
|||
Get crtbegin and crtend without compiler GCC! PR is at https://reviews.llvm.org/D28791
|
||||
|
||||
Index: compiler-rt/CMakeLists.txt
|
||||
===================================================================
|
||||
--- compiler-rt/CMakeLists.txt
|
||||
+++ compiler-rt/CMakeLists.txt
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
|
||||
mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
|
||||
+option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_CRT)
|
||||
option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
|
||||
mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
|
||||
option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
|
||||
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
|
||||
===================================================================
|
||||
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
|
||||
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
|
||||
@@ -132,7 +132,7 @@
|
||||
# Adds static or shared runtime for a list of architectures and operating
|
||||
# systems and puts it in the proper directory in the build and install trees.
|
||||
# add_compiler_rt_runtime(<name>
|
||||
-# {STATIC|SHARED}
|
||||
+# {OBJECT|STATIC|SHARED}
|
||||
# ARCHS <architectures>
|
||||
# OS <os list>
|
||||
# SOURCES <source files>
|
||||
@@ -144,8 +144,8 @@
|
||||
# PARENT_TARGET <convenience parent target>
|
||||
# ADDITIONAL_HEADERS <header files>)
|
||||
function(add_compiler_rt_runtime name type)
|
||||
- if(NOT type MATCHES "^(STATIC|SHARED)$")
|
||||
- message(FATAL_ERROR "type argument must be STATIC or SHARED")
|
||||
+ if(NOT type MATCHES "^(OBJECT|STATIC|SHARED)$")
|
||||
+ message(FATAL_ERROR "type argument must be OBJECT, STATIC or SHARED")
|
||||
return()
|
||||
endif()
|
||||
cmake_parse_arguments(LIB
|
||||
@@ -204,7 +204,10 @@
|
||||
message(FATAL_ERROR "Architecture ${arch} can't be targeted")
|
||||
return()
|
||||
endif()
|
||||
- if(type STREQUAL "STATIC")
|
||||
+ if(type STREQUAL "OBJECT")
|
||||
+ set(libname "${name}-${arch}")
|
||||
+ set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX})
|
||||
+ elseif(type STREQUAL "STATIC")
|
||||
set(libname "${name}-${arch}")
|
||||
set_output_name(output_name_${libname} ${name} ${arch})
|
||||
else()
|
||||
@@ -270,12 +273,34 @@
|
||||
set(COMPONENT_OPTION COMPONENT ${libname})
|
||||
endif()
|
||||
|
||||
- add_library(${libname} ${type} ${sources_${libname}})
|
||||
- set_target_compile_flags(${libname} ${extra_cflags_${libname}})
|
||||
- set_target_link_flags(${libname} ${extra_link_flags_${libname}})
|
||||
- set_property(TARGET ${libname} APPEND PROPERTY
|
||||
- COMPILE_DEFINITIONS ${LIB_DEFS})
|
||||
- set_target_output_directories(${libname} ${output_dir_${libname}})
|
||||
+ if(type STREQUAL "OBJECT")
|
||||
+ string(TOUPPER ${CMAKE_BUILD_TYPE} config)
|
||||
+ get_property(cflags SOURCE ${sources_${libname}} PROPERTY COMPILE_FLAGS)
|
||||
+ separate_arguments(cflags)
|
||||
+ add_custom_command(
|
||||
+ OUTPUT ${output_dir_${libname}}/${libname}.o
|
||||
+ COMMAND ${CMAKE_C_COMPILER} ${sources_${libname}} ${cflags} ${extra_cflags_${libname}} -c -o ${output_dir_${libname}}/${libname}.o
|
||||
+ DEPENDS ${sources_${libname}}
|
||||
+ COMMENT "Building C object ${libname}.o")
|
||||
+ add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${libname}.o)
|
||||
+ install(FILES ${output_dir_${libname}}/${libname}.o
|
||||
+ DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION})
|
||||
+ else()
|
||||
+ add_library(${libname} ${type} ${sources_${libname}})
|
||||
+ set_target_compile_flags(${libname} ${extra_cflags_${libname}})
|
||||
+ set_target_link_flags(${libname} ${extra_link_flags_${libname}})
|
||||
+ set_property(TARGET ${libname} APPEND PROPERTY
|
||||
+ COMPILE_DEFINITIONS ${LIB_DEFS})
|
||||
+ set_target_output_directories(${libname} ${output_dir_${libname}})
|
||||
+ install(TARGETS ${libname}
|
||||
+ ARCHIVE DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION}
|
||||
+ LIBRARY DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION}
|
||||
+ RUNTIME DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION})
|
||||
+ endif()
|
||||
set_target_properties(${libname} PROPERTIES
|
||||
OUTPUT_NAME ${output_name_${libname}})
|
||||
set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime")
|
||||
@@ -299,13 +324,6 @@
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
- install(TARGETS ${libname}
|
||||
- ARCHIVE DESTINATION ${install_dir_${libname}}
|
||||
- ${COMPONENT_OPTION}
|
||||
- LIBRARY DESTINATION ${install_dir_${libname}}
|
||||
- ${COMPONENT_OPTION}
|
||||
- RUNTIME DESTINATION ${install_dir_${libname}}
|
||||
- ${COMPONENT_OPTION})
|
||||
|
||||
# We only want to generate per-library install targets if you aren't using
|
||||
# an IDE because the extra targets get cluttered in IDEs.
|
||||
Index: compiler-rt/cmake/config-ix.cmake
|
||||
===================================================================
|
||||
--- compiler-rt/cmake/config-ix.cmake
|
||||
+++ compiler-rt/cmake/config-ix.cmake
|
||||
@@ -227,6 +227,7 @@
|
||||
${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X})
|
||||
set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
|
||||
${MIPS32} ${MIPS64} ${PPC64} ${S390X})
|
||||
+set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64})
|
||||
set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
|
||||
set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64})
|
||||
|
||||
@@ -474,6 +475,7 @@
|
||||
SANITIZER_COMMON_SUPPORTED_ARCH)
|
||||
|
||||
else()
|
||||
+ filter_available_targets(CRT_SUPPORTED_ARCH ${ALL_CRT_SUPPORTED_ARCH})
|
||||
# Architectures supported by compiler-rt libraries.
|
||||
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
|
||||
${ALL_SANITIZER_COMMON_SUPPORTED_ARCH})
|
||||
@@ -563,6 +565,12 @@
|
||||
|
||||
# TODO: Add builtins support.
|
||||
|
||||
+if (CRT_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux")
|
||||
+ set(COMPILER_RT_HAS_CRT TRUE)
|
||||
+else()
|
||||
+ set(COMPILER_RT_HAS_CRT FALSE)
|
||||
+endif()
|
||||
+
|
||||
if (COMPILER_RT_HAS_SANITIZER_COMMON AND DFSAN_SUPPORTED_ARCH AND
|
||||
OS_NAME MATCHES "Linux")
|
||||
set(COMPILER_RT_HAS_DFSAN TRUE)
|
||||
Index: compiler-rt/lib/CMakeLists.txt
|
||||
===================================================================
|
||||
--- compiler-rt/lib/CMakeLists.txt
|
||||
+++ compiler-rt/lib/CMakeLists.txt
|
||||
@@ -17,6 +17,10 @@
|
||||
add_subdirectory(builtins)
|
||||
endif()
|
||||
|
||||
+if(COMPILER_RT_BUILD_CRT)
|
||||
+ add_subdirectory(crt)
|
||||
+endif()
|
||||
+
|
||||
function(compiler_rt_build_runtime runtime)
|
||||
string(TOUPPER ${runtime} runtime_uppercase)
|
||||
if(COMPILER_RT_HAS_${runtime_uppercase})
|
||||
Index: compiler-rt/lib/crt/CMakeLists.txt
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ compiler-rt/lib/crt/CMakeLists.txt
|
||||
@@ -0,0 +1,102 @@
|
||||
+add_compiler_rt_component(crt)
|
||||
+
|
||||
+function(check_cxx_section_exists section output)
|
||||
+ cmake_parse_arguments(ARG "" "" "SOURCE;FLAGS" ${ARGN})
|
||||
+ if(NOT ARG_SOURCE)
|
||||
+ set(ARG_SOURCE "int main() { return 0; }\n")
|
||||
+ endif()
|
||||
+
|
||||
+ string(RANDOM TARGET_NAME)
|
||||
+ set(TARGET_NAME "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cmTC_${TARGET_NAME}.dir")
|
||||
+ file(MAKE_DIRECTORY ${TARGET_NAME})
|
||||
+
|
||||
+ file(WRITE "${TARGET_NAME}/CheckSectionExists.c" "${ARG_SOURCE}\n")
|
||||
+
|
||||
+ string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions
|
||||
+ ${CMAKE_C_COMPILE_OBJECT})
|
||||
+
|
||||
+ set(try_compile_flags "${ARG_FLAGS}")
|
||||
+ if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET)
|
||||
+ list(APPEND try_compile_flags "-target ${CMAKE_C_COMPILER_TARGET}")
|
||||
+ endif()
|
||||
+
|
||||
+ string(REPLACE ";" " " extra_flags "${try_compile_flags}")
|
||||
+
|
||||
+ set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}")
|
||||
+ foreach(substitution ${substitutions})
|
||||
+ if(substitution STREQUAL "<CMAKE_C_COMPILER>")
|
||||
+ string(REPLACE "<CMAKE_C_COMPILER>"
|
||||
+ "${CMAKE_C_COMPILER}" test_compile_command ${test_compile_command})
|
||||
+ elseif(substitution STREQUAL "<OBJECT>")
|
||||
+ string(REPLACE "<OBJECT>" "${TARGET_NAME}/CheckSectionExists.o"
|
||||
+ test_compile_command ${test_compile_command})
|
||||
+ elseif(substitution STREQUAL "<SOURCE>")
|
||||
+ string(REPLACE "<SOURCE>" "${TARGET_NAME}/CheckSectionExists.c"
|
||||
+ test_compile_command ${test_compile_command})
|
||||
+ elseif(substitution STREQUAL "<FLAGS>")
|
||||
+ string(REPLACE "<FLAGS>" "${CMAKE_C_FLAGS} ${extra_flags}"
|
||||
+ test_compile_command ${test_compile_command})
|
||||
+ else()
|
||||
+ string(REPLACE "${substitution}" "" test_compile_command
|
||||
+ ${test_compile_command})
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+
|
||||
+ string(REPLACE " " ";" test_compile_command "${test_compile_command}")
|
||||
+
|
||||
+ execute_process(
|
||||
+ COMMAND ${test_compile_command}
|
||||
+ RESULT_VARIABLE TEST_RESULT
|
||||
+ OUTPUT_VARIABLE TEST_OUTPUT
|
||||
+ ERROR_VARIABLE TEST_ERROR
|
||||
+ )
|
||||
+
|
||||
+ execute_process(
|
||||
+ COMMAND ${CMAKE_OBJDUMP} -h "${TARGET_NAME}/CheckSectionExists.o"
|
||||
+ RESULT_VARIABLE CHECK_RESULT
|
||||
+ OUTPUT_VARIABLE CHECK_OUTPUT
|
||||
+ ERROR_VARIABLE CHECK_ERROR
|
||||
+ )
|
||||
+ string(FIND "${CHECK_OUTPUT}" "${section}" SECTION_FOUND)
|
||||
+
|
||||
+ if(NOT SECTION_FOUND EQUAL -1)
|
||||
+ set(${output} TRUE PARENT_SCOPE)
|
||||
+ else()
|
||||
+ set(${output} FALSE PARENT_SCOPE)
|
||||
+ endif()
|
||||
+
|
||||
+ file(REMOVE_RECURSE ${TARGET_NAME})
|
||||
+endfunction()
|
||||
+
|
||||
+check_cxx_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY
|
||||
+ SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n")
|
||||
+
|
||||
+append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS)
|
||||
+append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS)
|
||||
+
|
||||
+foreach(arch ${CRT_SUPPORTED_ARCH})
|
||||
+ add_compiler_rt_runtime(clang_rt.crtbegin
|
||||
+ OBJECT
|
||||
+ ARCHS ${arch}
|
||||
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c
|
||||
+ CFLAGS ${CRT_CFLAGS}
|
||||
+ PARENT_TARGET crt)
|
||||
+ add_compiler_rt_runtime(clang_rt.crtbegin_shared
|
||||
+ OBJECT
|
||||
+ ARCHS ${arch}
|
||||
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c
|
||||
+ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED
|
||||
+ PARENT_TARGET crt)
|
||||
+ add_compiler_rt_runtime(clang_rt.crtend
|
||||
+ OBJECT
|
||||
+ ARCHS ${arch}
|
||||
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c
|
||||
+ CFLAGS ${CRT_CFLAGS}
|
||||