overlay: LLVM 8 -> 11
This commit is contained in:
parent
c0537a3671
commit
477807c0ac
|
@ -18,11 +18,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1604174028,
|
"lastModified": 1605706415,
|
||||||
"narHash": "sha256-b/AMdA8G3JIgErvqNJD0QwiqeD2LWw+aVFLlL9VQK7Y=",
|
"narHash": "sha256-TNMK7m95qrHyauJAz5b6FonwMFZvMl75GL/Zpk7FMSE=",
|
||||||
"owner": "ehmry",
|
"owner": "ehmry",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "098487ccb89e3771f4a63a3b2faf500c4002f65e",
|
"rev": "1f87da9eaa90afacc256f842e05e1111aa03ffa1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -103,6 +103,15 @@ in {
|
||||||
targetLlvmLibraries = targetPackages.llvmPackages_8.libraries;
|
targetLlvmLibraries = targetPackages.llvmPackages_8.libraries;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
llvmPackages_11 = callPackage ./llvm-11 ({
|
||||||
|
inherit (stdenvAdapters) overrideCC;
|
||||||
|
buildLlvmTools = buildPackages.llvmPackages_11.tools;
|
||||||
|
targetLlvmLibraries = targetPackages.llvmPackages_11.libraries;
|
||||||
|
inherit (final.genodePackages.genodeSources) genodeBase;
|
||||||
|
} // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && buildPackages.stdenv.cc.isGNU) {
|
||||||
|
stdenv = gcc7Stdenv;
|
||||||
|
});
|
||||||
|
|
||||||
openssl = overrideHostAttrs openssl (attrs: {
|
openssl = overrideHostAttrs openssl (attrs: {
|
||||||
outputs = [ "out" ]
|
outputs = [ "out" ]
|
||||||
++ builtins.filter (x: x != "bin" && x != "out") attrs.outputs;
|
++ builtins.filter (x: x != "bin" && x != "out") attrs.outputs;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
{ 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 -sf $prog $out/bin/${prefix}$(basename $prog)
|
||||||
|
done
|
||||||
|
|
||||||
|
ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}ar
|
||||||
|
ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as
|
||||||
|
ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp
|
||||||
|
ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm
|
||||||
|
ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy
|
||||||
|
ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump
|
||||||
|
ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib
|
||||||
|
ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf
|
||||||
|
ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size
|
||||||
|
ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip
|
||||||
|
|
||||||
|
ln -s ${lld}/bin/lld $out/bin/${prefix}ld
|
||||||
|
''
|
|
@ -0,0 +1,117 @@
|
||||||
|
{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
|
||||||
|
, fixDarwinDylibNames
|
||||||
|
, enableManpages ? false
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
self = stdenv.mkDerivation ({
|
||||||
|
pname = "clang";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch "clang" "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg";
|
||||||
|
inherit clang-tools-extra_src;
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
unpackFile $src
|
||||||
|
mv clang-${version}* clang
|
||||||
|
sourceRoot=$PWD/clang
|
||||||
|
unpackFile ${clang-tools-extra_src}
|
||||||
|
mv clang-tools-extra-* $sourceRoot/tools/extra
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake python3 lld ]
|
||||||
|
++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
|
||||||
|
++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
|
||||||
|
|
||||||
|
buildInputs = [ libxml2 llvm ];
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
"-DCMAKE_CXX_FLAGS=-std=c++14"
|
||||||
|
"-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"
|
||||||
|
];
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./purity.patch
|
||||||
|
# https://reviews.llvm.org/D51899
|
||||||
|
./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"
|
||||||
|
moveToOutput "lib/libclang-cpp.*" "$lib"
|
||||||
|
substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
|
||||||
|
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
|
||||||
|
--replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
|
||||||
|
homepage = "https://llvm.org/";
|
||||||
|
license = stdenv.lib.licenses.ncsa;
|
||||||
|
platforms = stdenv.lib.platforms.all;
|
||||||
|
};
|
||||||
|
} // stdenv.lib.optionalAttrs enableManpages {
|
||||||
|
pname = "clang-manpages";
|
||||||
|
|
||||||
|
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
|
|
@ -0,0 +1,539 @@
|
||||||
|
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
|
||||||
|
index 966cb907b7e2..5bcd5093be7d 100644
|
||||||
|
--- a/include/clang/Driver/Options.td
|
||||||
|
+++ b/include/clang/Driver/Options.td
|
||||||
|
@@ -2709,6 +2709,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 noprofilelib : Flag<["-"], "noprofilelib">;
|
||||||
|
def noseglinkedit : Flag<["-"], "noseglinkedit">;
|
||||||
|
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
|
||||||
|
index 965f273892bd..7a22f90d3652 100644
|
||||||
|
--- a/lib/Basic/Targets.cpp
|
||||||
|
+++ b/lib/Basic/Targets.cpp
|
||||||
|
@@ -142,6 +142,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:
|
||||||
|
@@ -186,6 +188,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||||
|
return new LinuxTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
||||||
|
case llvm::Triple::FreeBSD:
|
||||||
|
return new FreeBSDTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
||||||
|
+ case llvm::Triple::Genode:
|
||||||
|
+ return new GenodeTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
||||||
|
case llvm::Triple::NetBSD:
|
||||||
|
return new NetBSDTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
||||||
|
case llvm::Triple::OpenBSD:
|
||||||
|
@@ -485,6 +489,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||||
|
return new FreeBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
||||||
|
case llvm::Triple::Fuchsia:
|
||||||
|
return new FuchsiaTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
||||||
|
+ case llvm::Triple::Genode:
|
||||||
|
+ return new GenodeI386TargetInfo(Triple, Opts);
|
||||||
|
case llvm::Triple::KFreeBSD:
|
||||||
|
return new KFreeBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
||||||
|
case llvm::Triple::Minix:
|
||||||
|
@@ -544,6 +550,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/AArch64.cpp b/lib/Basic/Targets/AArch64.cpp
|
||||||
|
index 25c02cb888c1..8b9a622865cd 100644
|
||||||
|
--- a/lib/Basic/Targets/AArch64.cpp
|
||||||
|
+++ b/lib/Basic/Targets/AArch64.cpp
|
||||||
|
@@ -43,7 +43,7 @@ const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = {
|
||||||
|
AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
|
||||||
|
const TargetOptions &Opts)
|
||||||
|
: TargetInfo(Triple), ABI("aapcs") {
|
||||||
|
- if (getTriple().isOSOpenBSD()) {
|
||||||
|
+ if (getTriple().isOSOpenBSD() || getTriple().isOSGenode()) {
|
||||||
|
Int64Type = SignedLongLong;
|
||||||
|
IntMaxType = SignedLongLong;
|
||||||
|
} else {
|
||||||
|
diff --git a/lib/Basic/Targets/ARM.cpp b/lib/Basic/Targets/ARM.cpp
|
||||||
|
index 21cfe0107bbb..b02ef0aa0f2f 100644
|
||||||
|
--- a/lib/Basic/Targets/ARM.cpp
|
||||||
|
+++ b/lib/Basic/Targets/ARM.cpp
|
||||||
|
@@ -238,18 +238,19 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
|
||||||
|
HW_FP(0) {
|
||||||
|
bool IsOpenBSD = Triple.isOSOpenBSD();
|
||||||
|
bool IsNetBSD = Triple.isOSNetBSD();
|
||||||
|
+ bool IsGenode = Triple.isOSGenode();
|
||||||
|
|
||||||
|
// FIXME: the isOSBinFormatMachO is a workaround for identifying a Darwin-like
|
||||||
|
// environment where size_t is `unsigned long` rather than `unsigned int`
|
||||||
|
|
||||||
|
PtrDiffType = IntPtrType =
|
||||||
|
(Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD ||
|
||||||
|
- IsNetBSD)
|
||||||
|
+ IsNetBSD || IsGenode)
|
||||||
|
? SignedLong
|
||||||
|
: SignedInt;
|
||||||
|
|
||||||
|
SizeType = (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD ||
|
||||||
|
- IsNetBSD)
|
||||||
|
+ IsNetBSD || IsGenode)
|
||||||
|
? UnsignedLong
|
||||||
|
: UnsignedInt;
|
||||||
|
|
||||||
|
diff --git a/lib/Basic/Targets/OSTargets.h b/lib/Basic/Targets/OSTargets.h
|
||||||
|
index 2a9e4f91d478..e453358027f0 100644
|
||||||
|
--- a/lib/Basic/Targets/OSTargets.h
|
||||||
|
+++ b/lib/Basic/Targets/OSTargets.h
|
||||||
|
@@ -296,7 +296,7 @@ protected:
|
||||||
|
Builder.defineMacro("__HAIKU__");
|
||||||
|
Builder.defineMacro("__ELF__");
|
||||||
|
DefineStd(Builder, "unix", Opts);
|
||||||
|
- if (this->HasFloat128)
|
||||||
|
+ if (this->HasFloat128)
|
||||||
|
Builder.defineMacro("__FLOAT128__");
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -820,6 +820,40 @@ 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__");
|
||||||
|
+ DefineStd(Builder, "unix", Opts);
|
||||||
|
+ Builder.defineMacro("__ELF__");
|
||||||
|
+ if (Opts.POSIXThreads)
|
||||||
|
+ Builder.defineMacro("_REENTRANT");
|
||||||
|
+ if (this->HasFloat128)
|
||||||
|
+ Builder.defineMacro("__FLOAT128__");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+public:
|
||||||
|
+ GenodeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
||||||
|
+ : OSTargetInfo<Target>(Triple, Opts) {
|
||||||
|
+ this->IntMaxType = TargetInfo::SignedLongLong;
|
||||||
|
+ this->Int64Type = TargetInfo::SignedLongLong;
|
||||||
|
+ this->SizeType = TargetInfo::UnsignedLong;
|
||||||
|
+ this->TLSSupported = false;
|
||||||
|
+ switch (Triple.getArch()) {
|
||||||
|
+ default:
|
||||||
|
+ break;
|
||||||
|
+ case llvm::Triple::x86:
|
||||||
|
+ case llvm::Triple::x86_64:
|
||||||
|
+ this->HasFloat128 = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
// WebAssembly target
|
||||||
|
template <typename Target>
|
||||||
|
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
|
||||||
|
diff --git a/lib/Basic/Targets/X86.h b/lib/Basic/Targets/X86.h
|
||||||
|
index 72a01d2514c2..ae7b01b0d9a7 100644
|
||||||
|
--- a/lib/Basic/Targets/X86.h
|
||||||
|
+++ b/lib/Basic/Targets/X86.h
|
||||||
|
@@ -447,6 +447,18 @@ public:
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
+class LLVM_LIBRARY_VISIBILITY GenodeI386TargetInfo
|
||||||
|
+ : public GenodeTargetInfo<X86_32TargetInfo> {
|
||||||
|
+public:
|
||||||
|
+ GenodeI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
||||||
|
+ : GenodeTargetInfo<X86_32TargetInfo>(Triple, Opts) {
|
||||||
|
+ SizeType = UnsignedLong;
|
||||||
|
+ IntPtrType = SignedLong;
|
||||||
|
+ PtrDiffType = SignedLong;
|
||||||
|
+ }
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+
|
||||||
|
class LLVM_LIBRARY_VISIBILITY DarwinI386TargetInfo
|
||||||
|
: public DarwinTargetInfo<X86_32TargetInfo> {
|
||||||
|
public:
|
||||||
|
diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt
|
||||||
|
index 9463ca5c109d..5ae757f99e2f 100644
|
||||||
|
--- a/lib/Driver/CMakeLists.txt
|
||||||
|
+++ b/lib/Driver/CMakeLists.txt
|
||||||
|
@@ -49,6 +49,7 @@ add_clang_library(clangDriver
|
||||||
|
ToolChains/Flang.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 ece8222dcf24..4ca793af6c81 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"
|
||||||
|
@@ -4951,6 +4952,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
|
||||||
|
case llvm::Triple::Solaris:
|
||||||
|
TC = std::make_unique<toolchains::Solaris>(*this, Target, Args);
|
||||||
|
break;
|
||||||
|
+ case llvm::Triple::Genode:
|
||||||
|
+ TC = std::make_unique<toolchains::Genode>(*this, Target, Args);
|
||||||
|
+ break;
|
||||||
|
case llvm::Triple::AMDHSA:
|
||||||
|
TC = std::make_unique<toolchains::ROCMToolChain>(*this, Target, Args);
|
||||||
|
break;
|
||||||
|
diff --git a/lib/Driver/ToolChains/Arch/AArch64.cpp b/lib/Driver/ToolChains/Arch/AArch64.cpp
|
||||||
|
index dd4545d6c48f..22ec56518046 100644
|
||||||
|
--- a/lib/Driver/ToolChains/Arch/AArch64.cpp
|
||||||
|
+++ b/lib/Driver/ToolChains/Arch/AArch64.cpp
|
||||||
|
@@ -373,7 +373,7 @@ fp16_fml_fallthrough:
|
||||||
|
options::OPT_munaligned_access)) {
|
||||||
|
if (A->getOption().matches(options::OPT_mno_unaligned_access))
|
||||||
|
Features.push_back("+strict-align");
|
||||||
|
- } else if (Triple.isOSOpenBSD())
|
||||||
|
+ } else if (Triple.isOSOpenBSD() || Triple.isOSGenode())
|
||||||
|
Features.push_back("+strict-align");
|
||||||
|
|
||||||
|
if (Args.hasArg(options::OPT_ffixed_x1))
|
||||||
|
diff --git a/lib/Driver/ToolChains/Arch/ARM.cpp b/lib/Driver/ToolChains/Arch/ARM.cpp
|
||||||
|
index afe896b4a65b..f93dd30beb98 100644
|
||||||
|
--- a/lib/Driver/ToolChains/Arch/ARM.cpp
|
||||||
|
+++ b/lib/Driver/ToolChains/Arch/ARM.cpp
|
||||||
|
@@ -587,7 +587,7 @@ fp16_fml_fallthrough:
|
||||||
|
if (VersionNum < 6 ||
|
||||||
|
Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
|
||||||
|
Features.push_back("+strict-align");
|
||||||
|
- } else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
|
||||||
|
+ } else if (Triple.isOSLinux() || Triple.isOSNaCl() || Triple.isOSGenode()) {
|
||||||
|
if (VersionNum < 7)
|
||||||
|
Features.push_back("+strict-align");
|
||||||
|
} else
|
||||||
|
diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp
|
||||||
|
index af4bcf951e6c..c96b192c7e09 100644
|
||||||
|
--- a/lib/Driver/ToolChains/Clang.cpp
|
||||||
|
+++ b/lib/Driver/ToolChains/Clang.cpp
|
||||||
|
@@ -538,7 +538,7 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (Triple.isOSNetBSD()) {
|
||||||
|
+ if (Triple.isOSNetBSD() || Triple.isOSGenode()) {
|
||||||
|
return !areOptimizationsEnabled(Args);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/lib/Driver/ToolChains/Genode.cpp b/lib/Driver/ToolChains/Genode.cpp
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000000..37151999b7bf
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/lib/Driver/ToolChains/Genode.cpp
|
||||||
|
@@ -0,0 +1,191 @@
|
||||||
|
+//===--- Genode.h - Genode ToolChain Implementations ------------*- C++ -*-===//
|
||||||
|
+//
|
||||||
|
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
+// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
+//
|
||||||
|
+//===----------------------------------------------------------------------===//
|
||||||
|
+
|
||||||
|
+#include "Genode.h"
|
||||||
|
+#include "CommonArgs.h"
|
||||||
|
+#include "InputInfo.h"
|
||||||
|
+#include "clang/Driver/Compilation.h"
|
||||||
|
+#include "clang/Driver/Driver.h"
|
||||||
|
+#include "clang/Driver/Options.h"
|
||||||
|
+#include "llvm/Option/ArgList.h"
|
||||||
|
+
|
||||||
|
+using namespace clang::driver;
|
||||||
|
+using namespace clang::driver::toolchains;
|
||||||
|
+using namespace clang::driver::tools;
|
||||||
|
+using namespace clang;
|
||||||
|
+using namespace llvm::opt;
|
||||||
|
+
|
||||||
|
+void genode::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
|
+ const InputInfo &Output,
|
||||||
|
+ const InputInfoList &Inputs,
|
||||||
|
+ const ArgList &Args,
|
||||||
|
+ const char *LinkingOutput) const {
|
||||||
|
+ ArgStringList CmdArgs;
|
||||||
|
+
|
||||||
|
+ const auto &TC = static_cast<const toolchains::Genode &>(getToolChain());
|
||||||
|
+ const auto &D = TC.getDriver();
|
||||||
|
+
|
||||||
|
+ 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 (TC.getArch()) {
|
||||||
|
+ 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);
|
||||||
|
+ TC.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(TC, Inputs, Args, CmdArgs, JA);
|
||||||
|
+
|
||||||
|
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, options::OPT_noposix)) {
|
||||||
|
+ AddRunTimeLibs(TC, D, CmdArgs, Args);
|
||||||
|
+
|
||||||
|
+ CmdArgs.push_back("-lc");
|
||||||
|
+ if (!Args.hasArg(options::OPT_shared)) {
|
||||||
|
+ CmdArgs.push_back("-lposix");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
|
||||||
|
+ Args.MakeArgString(TC.GetLinkerPath()),
|
||||||
|
+ CmdArgs, Inputs));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+Genode::Genode(const Driver &D, const llvm::Triple &Triple,
|
||||||
|
+ const ArgList &Args)
|
||||||
|
+ : Generic_ELF(D, Triple, Args) {
|
||||||
|
+
|
||||||
|
+ std::vector<std::string> GenodeExtraTriples;
|
||||||
|
+ switch (Triple.getArch()) {
|
||||||
|
+ case llvm::Triple::arm:
|
||||||
|
+ GenodeExtraTriples.push_back("arm-none-eabi");
|
||||||
|
+ break;
|
||||||
|
+ case llvm::Triple::aarch64:
|
||||||
|
+ GenodeExtraTriples.push_back("aarch64-none-elf");
|
||||||
|
+ break;
|
||||||
|
+ case llvm::Triple::x86:
|
||||||
|
+ case llvm::Triple::x86_64:
|
||||||
|
+ GenodeExtraTriples.push_back("x86_64-pc-elf");
|
||||||
|
+ break;
|
||||||
|
+ case llvm::Triple::riscv64:
|
||||||
|
+ GenodeExtraTriples.push_back("riscv64-unknown-elf");
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ GCCInstallation.init(Triple, Args, GenodeExtraTriples);
|
||||||
|
+
|
||||||
|
+ const std::string MultiarchTriple = getMultiarchTriple(D, Triple, /*SysRoot*/ "");
|
||||||
|
+ if (GCCInstallation.isValid() &&
|
||||||
|
+ (Triple.getArch() == llvm::Triple::x86_64 ||
|
||||||
|
+ Triple.getArch() == llvm::Triple::x86)) {
|
||||||
|
+
|
||||||
|
+ path_list MultilibPaths;
|
||||||
|
+ Generic_GCC::AddMultilibPaths(D, /*SysRoot*/ "", "lib",
|
||||||
|
+ MultiarchTriple, MultilibPaths);
|
||||||
|
+
|
||||||
|
+ auto Suffix = GCCInstallation.getMultilib().gccSuffix();
|
||||||
|
+ for (auto path: MultilibPaths)
|
||||||
|
+ addPathIfExists(D, path + Suffix, getFilePaths());
|
||||||
|
+ } else {
|
||||||
|
+ Generic_GCC::AddMultilibPaths(D, /*SysRoot*/ "", "lib",
|
||||||
|
+ MultiarchTriple, getFilePaths());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ToolChain::path_list &PPaths = getProgramPaths();
|
||||||
|
+
|
||||||
|
+ Generic_GCC::PushPPaths(PPaths);
|
||||||
|
+
|
||||||
|
+#ifdef ENABLE_LINKER_BUILD_ID
|
||||||
|
+ ExtraOpts.push_back("--build-id");
|
||||||
|
+#endif
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+Genode::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
|
||||||
|
+ llvm::opt::ArgStringList &CC1Args) const {
|
||||||
|
+ // Try generic GCC detection first.
|
||||||
|
+ if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ if (!GCCInstallation.isValid())
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ StringRef LibDir = GCCInstallation.getParentLibPath();
|
||||||
|
+ StringRef TripleStr = GCCInstallation.getTriple().str();
|
||||||
|
+ const Multilib &Multilib = GCCInstallation.getMultilib();
|
||||||
|
+ const GCCVersion &Version = GCCInstallation.getVersion();
|
||||||
|
+
|
||||||
|
+ const std::string IncludePath = {
|
||||||
|
+ LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr,
|
||||||
|
+ /*GCCMultiarchTriple*/ "",
|
||||||
|
+ /*TargetMultiarchTriple*/ "",
|
||||||
|
+ Multilib.includeSuffix(), DriverArgs, CC1Args);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void Genode::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {
|
||||||
|
+ for (const auto &Opt : ExtraOpts)
|
||||||
|
+ CmdArgs.push_back(Opt.c_str());
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+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 000000000000..27e51ca45d9e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/lib/Driver/ToolChains/Genode.h
|
||||||
|
@@ -0,0 +1,69 @@
|
||||||
|
+//===--- Genode.h - Genode ToolChain Implementations ------------*- C++ -*-===//
|
||||||
|
+//
|
||||||
|
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
+// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
+//
|
||||||
|
+//===----------------------------------------------------------------------===//
|
||||||
|
+
|
||||||
|
+#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 {
|
||||||
|
+namespace genode {
|
||||||
|
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
|
||||||
|
+public:
|
||||||
|
+ Linker(const ToolChain &TC) : Tool("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 &Inputs,
|
||||||
|
+ const llvm::opt::ArgList &TCArgs,
|
||||||
|
+ 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 IsMathErrnoDefault() const override { return false; }
|
||||||
|
+ bool HasNativeLLVMSupport() const override { return true; }
|
||||||
|
+ bool isPICDefault() const override { return false; }
|
||||||
|
+ bool isPIEDefault() const override { return false; }
|
||||||
|
+ bool isPICDefaultForced() const override { return false; }
|
||||||
|
+ bool IsIntegratedAssemblerDefault() const override { return true; }
|
||||||
|
+
|
||||||
|
+ void
|
||||||
|
+ addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
|
||||||
|
+ llvm::opt::ArgStringList &CC1Args) const final;
|
||||||
|
+
|
||||||
|
+ bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;
|
||||||
|
+
|
||||||
|
+ std::vector<std::string> ExtraOpts;
|
||||||
|
+
|
||||||
|
+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 bc31445d6d08..364942eff068 100644
|
||||||
|
--- a/lib/Frontend/InitHeaderSearch.cpp
|
||||||
|
+++ b/lib/Frontend/InitHeaderSearch.cpp
|
||||||
|
@@ -229,6 +229,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)
|
||||||
|
@@ -338,6 +339,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 000000000000..e69de29bb2d1
|
||||||
|
diff --git a/test/Driver/genode.cpp b/test/Driver/genode.cpp
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000000..e69de29bb2d1
|
|
@ -0,0 +1,28 @@
|
||||||
|
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
|
||||||
|
@@ -487,12 +487,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
|
if (!IsStatic) {
|
||||||
|
if (Args.hasArg(options::OPT_rdynamic))
|
||||||
|
CmdArgs.push_back("-export-dynamic");
|
||||||
|
-
|
||||||
|
- if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
|
||||||
|
- CmdArgs.push_back("-dynamic-linker");
|
||||||
|
- CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) +
|
||||||
|
- ToolChain.getDynamicLinker(Args)));
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdArgs.push_back("-o");
|
||||||
|
--
|
||||||
|
2.11.0
|
|
@ -0,0 +1,23 @@
|
||||||
|
diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt
|
||||||
|
index 3a66dd9c3fb..7efc85d9f9f 100644
|
||||||
|
--- a/lib/builtins/CMakeLists.txt
|
||||||
|
+++ b/lib/builtins/CMakeLists.txt
|
||||||
|
@@ -301,6 +301,10 @@ if (NOT MSVC)
|
||||||
|
i386/umoddi3.S
|
||||||
|
)
|
||||||
|
|
||||||
|
+ set(i486_SOURCES ${i386_SOURCES})
|
||||||
|
+ set(i586_SOURCES ${i386_SOURCES})
|
||||||
|
+ set(i686_SOURCES ${i386_SOURCES})
|
||||||
|
+
|
||||||
|
if (WIN32)
|
||||||
|
set(i386_SOURCES
|
||||||
|
${i386_SOURCES}
|
||||||
|
@@ -608,6 +612,7 @@ else ()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach (arch ${BUILTIN_SUPPORTED_ARCH})
|
||||||
|
+ message("arch: ${arch}")
|
||||||
|
if (CAN_TARGET_${arch})
|
||||||
|
# For ARM archs, exclude any VFP builtins if VFP is not supported
|
||||||
|
if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
|
|
@ -0,0 +1,32 @@
|
||||||
|
diff -ur compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake
|
||||||
|
--- compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake 2020-03-24 00:01:02.000000000 +0900
|
||||||
|
+++ compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-10 03:42:00.883450706 +0900
|
||||||
|
@@ -24,7 +24,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
set(ARM64 aarch64)
|
||||||
|
-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k)
|
||||||
|
+set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l)
|
||||||
|
set(HEXAGON hexagon)
|
||||||
|
set(X86 i386)
|
||||||
|
set(X86_64 x86_64)
|
||||||
|
diff -ur compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt
|
||||||
|
--- compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt 2020-03-24 00:01:02.000000000 +0900
|
||||||
|
+++ compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-10 03:44:49.468579650 +0900
|
||||||
|
@@ -474,6 +474,7 @@
|
||||||
|
set(armv7_SOURCES ${arm_SOURCES})
|
||||||
|
set(armv7s_SOURCES ${arm_SOURCES})
|
||||||
|
set(armv7k_SOURCES ${arm_SOURCES})
|
||||||
|
+set(armv7l_SOURCES ${arm_SOURCES})
|
||||||
|
set(arm64_SOURCES ${aarch64_SOURCES})
|
||||||
|
|
||||||
|
# macho_embedded archs
|
||||||
|
@@ -595,7 +596,7 @@
|
||||||
|
foreach (arch ${BUILTIN_SUPPORTED_ARCH})
|
||||||
|
if (CAN_TARGET_${arch})
|
||||||
|
# For ARM archs, exclude any VFP builtins if VFP is not supported
|
||||||
|
- if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
|
||||||
|
+ if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$")
|
||||||
|
string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")
|
||||||
|
check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP)
|
||||||
|
if(NOT COMPILER_RT_HAS_${arch}_VFP)
|
|
@ -0,0 +1,33 @@
|
||||||
|
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
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
|
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
||||||
|
inherit (stdenv.hostPlatform) isMusl;
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "compiler-rt";
|
||||||
|
inherit version;
|
||||||
|
src = fetch pname "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake python3 llvm ];
|
||||||
|
buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
||||||
|
|
||||||
|
NIX_CFLAGS_COMPILE = [
|
||||||
|
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
|
||||||
|
];
|
||||||
|
|
||||||
|
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.isDarwin) [
|
||||||
|
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
|
||||||
|
] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
|
||||||
|
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
||||||
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||||
|
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||||
|
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||||
|
] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
|
||||||
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
|
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||||
|
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||||
|
] ++ stdenv.lib.optionals (useLLVM) [
|
||||||
|
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||||
|
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||||
|
#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"
|
||||||
|
] ++ stdenv.lib.optionals (bareMetal) [
|
||||||
|
"-DCOMPILER_RT_OS_DIR=baremetal"
|
||||||
|
];
|
||||||
|
|
||||||
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
|
||||||
|
./compiler-rt-X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||||
|
]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
||||||
|
++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.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/builtin-config-ix.cmake \
|
||||||
|
--replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
|
||||||
|
'' + stdenv.lib.optionalString stdenv.isDarwin ''
|
||||||
|
substituteInPlace cmake/builtin-config-ix.cmake \
|
||||||
|
--replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)'
|
||||||
|
substituteInPlace cmake/config-ix.cmake \
|
||||||
|
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
|
||||||
|
'' + stdenv.lib.optionalString (useLLVM) ''
|
||||||
|
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 (useLLVM) ''
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
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
|
|
@ -0,0 +1,595 @@
|
||||||
|
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}
|
||||||
|
+ PARENT_TARGET crt)
|
||||||
|
+ add_compiler_rt_runtime(clang_rt.crtend_shared
|
||||||
|
+ OBJECT
|
||||||
|
+ ARCHS ${arch}
|
||||||
|
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c
|
||||||
|
+ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED
|
||||||
|
+ PARENT_TARGET crt)
|
||||||
|
+endforeach()
|
||||||
|
Index: compiler-rt/lib/crt/crtbegin.c
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ compiler-rt/lib/crt/crtbegin.c
|
||||||
|
@@ -0,0 +1,108 @@
|
||||||
|
+/* ===-- crtbegin.c - Start of constructors and destructors ----------------===
|
||||||
|
+ *
|
||||||
|
+ * The LLVM Compiler Infrastructure
|
||||||
|
+ *
|
||||||
|
+ * This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
+ * Source Licenses. See LICENSE.TXT for details.
|
||||||
|
+ *
|
||||||
|
+ * ===----------------------------------------------------------------------===
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <stddef.h>
|
||||||
|
+
|
||||||
|
+__attribute__((visibility("hidden")))
|
||||||
|
+#ifdef CRT_SHARED
|
||||||
|
+void *__dso_handle = &__dso_handle;
|
||||||
|
+#else
|
||||||
|
+void *__dso_handle = (void *)0;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+static long __EH_FRAME_LIST__[]
|
||||||
|
+ __attribute__((section(".eh_frame"), aligned(sizeof(void *)))) = {};
|
||||||
|
+
|
||||||
|
+extern void __register_frame_info(const void *, void *) __attribute__((weak));
|
||||||
|
+extern void *__deregister_frame_info(const void *) __attribute__((weak));
|
||||||
|
+
|
||||||
|
+#ifndef CRT_HAS_INITFINI_ARRAY
|
||||||
|
+typedef void (*fp)(void);
|
||||||
|
+
|
||||||
|
+static fp __CTOR_LIST__[]
|
||||||
|
+ __attribute__((section(".ctors"), aligned(sizeof(fp)), used)) = {(fp)-1};
|
||||||
|
+extern fp __CTOR_LIST_END__[];
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#ifdef CRT_SHARED
|
||||||
|
+extern void __cxa_finalize(void *) __attribute__((weak));
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+static void __attribute__((used)) __do_init() {
|
||||||
|
+ static _Bool __initialized;
|
||||||
|
+ if (__builtin_expect(__initialized, 0))
|
||||||
|
+ return;
|
||||||
|
+ __initialized = 1;
|
||||||
|
+
|
||||||
|
+ static struct { void *p[8]; } __object;
|
||||||
|
+ if (__register_frame_info)
|
||||||
|
+ __register_frame_info(__EH_FRAME_LIST__, &__object);
|
||||||
|
+
|
||||||
|
+#ifndef CRT_HAS_INITFINI_ARRAY
|
||||||
|
+ const size_t n = __CTOR_LIST_END__ - __CTOR_LIST__ - 1;
|
||||||
|
+ for (size_t i = n; i >= 1; i--) __CTOR_LIST__[i]();
|
||||||
|
+#endif
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#ifdef CRT_HAS_INITFINI_ARRAY
|
||||||
|
+__attribute__((section(".init_array"),
|
||||||
|
+ used)) static void (*__init)(void) = __do_init;
|
||||||
|
+#else // CRT_HAS_INITFINI_ARRAY
|
||||||
|
+#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
+asm(".pushsection .init,\"ax\",@progbits\n\t"
|
||||||
|
+ "call " __USER_LABEL_PREFIX__ "__do_init\n\t"
|
||||||
|
+ ".popsection");
|
||||||
|
+#elif defined(__arm__)
|
||||||
|
+asm(".pushsection .init,\"ax\",%progbits\n\t"
|
||||||
|
+ "bl " __USER_LABEL_PREFIX__ "__do_init\n\t"
|
||||||
|
+ ".popsection");
|
||||||
|
+#endif // CRT_HAS_INITFINI_ARRAY
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#ifndef CRT_HAS_INITFINI_ARRAY
|
||||||
|
+static fp __DTOR_LIST__[]
|
||||||
|
+ __attribute__((section(".dtors"), aligned(sizeof(fp)), used)) = {(fp)-1};
|
||||||
|
+extern fp __DTOR_LIST_END__[];
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+static void __attribute__((used)) __do_fini() {
|
||||||
|
+ static _Bool __finalized;
|
||||||
|
+ if (__builtin_expect(__finalized, 0))
|
||||||
|
+ return;
|
||||||
|
+ __finalized = 1;
|
||||||
|
+
|
||||||
|
+#ifdef CRT_SHARED
|
||||||
|
+ if (__cxa_finalize)
|
||||||
|
+ __cxa_finalize(__dso_handle);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#ifndef CRT_HAS_INITFINI_ARRAY
|
||||||
|
+ if (__deregister_frame_info)
|
||||||
|
+ __deregister_frame_info(__EH_FRAME_LIST__);
|
||||||
|
+
|
||||||
|
+ const size_t n = __DTOR_LIST_END__ - __DTOR_LIST__ - 1;
|
||||||
|
+ for (size_t i = 1; i < n; i++) __DTOR_LIST__[i]();
|
||||||
|
+#endif
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#ifdef CRT_HAS_INITFINI_ARRAY
|
||||||
|
+__attribute__((section(".fini_array"),
|
||||||
|
+ used)) static void (*__fini)(void) = __do_fini;
|
||||||
|
+#else // CRT_HAS_INITFINI_ARRAY
|
||||||
|
+#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
+asm(".pushsection .fini,\"ax\",@progbits\n\t"
|
||||||
|
+ "call " __USER_LABEL_PREFIX__ "__do_fini\n\t"
|
||||||
|
+ ".popsection");
|
||||||
|
+#elif defined(__arm__)
|
||||||
|
+asm(".pushsection .fini,\"ax\",%progbits\n\t"
|
||||||
|
+ "bl " __USER_LABEL_PREFIX__ "__do_fini\n\t"
|
||||||
|
+ ".popsection");
|
||||||
|
+#endif
|
||||||
|
+#endif // CRT_HAS_INIT_FINI_ARRAY
|
||||||
|
Index: compiler-rt/lib/crt/crtend.c
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ compiler-rt/lib/crt/crtend.c
|
||||||
|
@@ -0,0 +1,24 @@
|
||||||
|
+/* ===-- crtend.c - End of constructors and destructors --------------------===
|
||||||
|
+ *
|
||||||
|
+ * The LLVM Compiler Infrastructure
|
||||||
|
+ *
|
||||||
|
+ * This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
+ * Source Licenses. See LICENSE.TXT for details.
|
||||||
|
+ *
|
||||||
|
+ * ===----------------------------------------------------------------------===
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <stdint.h>
|
||||||
|
+
|
||||||
|
+// Put 4-byte zero which is the length field in FDE at the end as a terminator.
|
||||||
|
+const int32_t __EH_FRAME_LIST_END__[]
|
||||||
|
+ __attribute__((section(".eh_frame"), aligned(sizeof(int32_t)),
|
||||||
|
+ visibility("hidden"), used)) = {0};
|
||||||
|
+
|
||||||
|
+#ifndef CRT_HAS_INITFINI_ARRAY
|
||||||
|
+typedef void (*fp)(void);
|
||||||
|
+fp __CTOR_LIST_END__[]
|
||||||
|
+ __attribute__((section(".ctors"), visibility("hidden"), used)) = {0};
|
||||||
|
+fp __DTOR_LIST_END__[]
|
||||||
|
+ __attribute__((section(".dtors"), visibility("hidden"), used)) = {0};
|
||||||
|
+#endif
|
||||||
|
Index: compiler-rt/test/CMakeLists.txt
|
||||||
|
===================================================================
|
||||||
|
--- compiler-rt/test/CMakeLists.txt
|
||||||
|
+++ compiler-rt/test/CMakeLists.txt
|
||||||
|
@@ -73,6 +73,9 @@
|
||||||
|
if(COMPILER_RT_BUILD_XRAY)
|
||||||
|
compiler_rt_test_runtime(xray)
|
||||||
|
endif()
|
||||||
|
+ if(COMPILER_RT_HAS_CRT)
|
||||||
|
+ add_subdirectory(crt)
|
||||||
|
+ endif()
|
||||||
|
# ShadowCallStack does not yet provide a runtime with compiler-rt, the tests
|
||||||
|
# include their own minimal runtime
|
||||||
|
add_subdirectory(shadowcallstack)
|
||||||
|
Index: compiler-rt/test/crt/CMakeLists.txt
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ compiler-rt/test/crt/CMakeLists.txt
|
||||||
|
@@ -0,0 +1,31 @@
|
||||||
|
+set(CRT_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
+
|
||||||
|
+set(CRT_TESTSUITES)
|
||||||
|
+
|
||||||
|
+set(CRT_TEST_DEPS "")
|
||||||
|
+
|
||||||
|
+if(NOT COMPILER_RT_STANDALONE_BUILD AND COMPILER_RT_BUILD_CRT AND
|
||||||
|
+ COMPILER_RT_HAS_CRT)
|
||||||
|
+ list(APPEND CRT_TEST_DEPS crt)
|
||||||
|
+endif()
|
||||||
|
+
|
||||||
|
+set(CRT_TEST_ARCH ${CRT_SUPPORTED_ARCH})
|
||||||
|
+if (COMPILER_RT_BUILD_CRT AND COMPILER_RT_HAS_CRT)
|
||||||
|
+ foreach(arch ${CRT_TEST_ARCH})
|
||||||
|
+ set(CRT_TEST_TARGET_ARCH ${arch})
|
||||||
|
+ string(TOLOWER "-${arch}-${OS_NAME}" CRT_TEST_CONFIG_SUFFIX)
|
||||||
|
+ get_test_cc_for_arch(${arch} CRT_TEST_TARGET_CC CRT_TEST_TARGET_CFLAGS)
|
||||||
|
+ string(TOUPPER ${arch} ARCH_UPPER_CASE)
|
||||||
|
+ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
|
||||||
|
+
|
||||||
|
+ configure_lit_site_cfg(
|
||||||
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
||||||
|
+ ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
|
||||||
|
+ list(APPEND CRT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
|
||||||
|
+ endforeach()
|
||||||
|
+endif()
|
||||||
|
+
|
||||||
|
+add_lit_testsuite(check-crt "Running the CRT tests"
|
||||||
|
+ ${CRT_TESTSUITES}
|
||||||
|
+ DEPENDS ${CRT_TEST_DEPS})
|
||||||
|
+set_target_properties(check-crt PROPERTIES FOLDER "Compiler-RT Misc")
|
||||||
|
Index: compiler-rt/test/crt/dso_handle.cpp
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ compiler-rt/test/crt/dso_handle.cpp
|
||||||
|
@@ -0,0 +1,33 @@
|
||||||
|
+// RUN: %clangxx -g -DCRT_SHARED -c %s -fPIC -o %tshared.o
|
||||||
|
+// RUN: %clangxx -g -c %s -fPIC -o %t.o
|
||||||
|
+// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %shared_crtbegin %tshared.o %libstdcxx -lc -lm -lgcc_s %shared_crtend %crtn
|
||||||
|
+// RUN: %clangxx -g -o %t -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn
|
||||||
|
+// RUN: %run %t 2>&1 | FileCheck %s
|
||||||
|
+
|
||||||
|
+#include <stdio.h>
|
||||||
|
+
|
||||||
|
+// CHECK: 1
|
||||||
|
+// CHECK-NEXT: ~A()
|
||||||
|
+
|
||||||
|
+#ifdef CRT_SHARED
|
||||||
|
+bool G;
|
||||||
|
+void C() {
|
||||||
|
+ printf("%d\n", G);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+struct A {
|
||||||
|
+ A() { G = true; }
|
||||||
|
+ ~A() {
|
||||||
|
+ printf("~A()\n");
|
||||||
|
+ }
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+A a;
|
||||||
|
+#else
|
||||||
|
+void C();
|
||||||
|
+
|
||||||
|
+int main() {
|
||||||
|
+ C();
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+#endif
|
||||||
|
Index: compiler-rt/test/crt/lit.cfg
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ compiler-rt/test/crt/lit.cfg
|
||||||
|
@@ -0,0 +1,80 @@
|
||||||
|
+# -*- Python -*-
|
||||||
|
+
|
||||||
|
+import os
|
||||||
|
+import subprocess
|
||||||
|
+
|
||||||
|
+# Setup config name.
|
||||||
|
+config.name = 'CRT' + config.name_suffix
|
||||||
|
+
|
||||||
|
+# Setup source root.
|
||||||
|
+config.test_source_root = os.path.dirname(__file__)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def get_library_path(file):
|
||||||
|
+ cmd = subprocess.Popen([config.clang.strip(),
|
||||||
|
+ config.target_cflags.strip(),
|
||||||
|
+ '-print-file-name=%s' % file],
|
||||||
|
+ stdout=subprocess.PIPE,
|
||||||
|
+ env=config.environment)
|
||||||
|
+ if not cmd.stdout:
|
||||||
|
+ lit_config.fatal("Couldn't find the library path for '%s'" % file)
|
||||||
|
+ dir = cmd.stdout.read().strip()
|
||||||
|
+ if sys.platform in ['win32'] and execute_external:
|
||||||
|
+ # Don't pass dosish path separator to msys bash.exe.
|
||||||
|
+ dir = dir.replace('\\', '/')
|
||||||
|
+ # Ensure the result is an ascii string, across Python2.5+ - Python3.
|
||||||
|
+ return str(dir.decode('ascii'))
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def get_libgcc_file_name():
|
||||||
|
+ cmd = subprocess.Popen([config.clang.strip(),
|
||||||
|
+ config.target_cflags.strip(),
|
||||||
|
+ '-print-libgcc-file-name'],
|
||||||
|
+ stdout=subprocess.PIPE,
|
||||||
|
+ env=config.environment)
|
||||||
|
+ if not cmd.stdout:
|
||||||
|
+ lit_config.fatal("Couldn't find the library path for '%s'" % file)
|
||||||
|
+ dir = cmd.stdout.read().strip()
|
||||||
|
+ if sys.platform in ['win32'] and execute_external:
|
||||||
|
+ # Don't pass dosish path separator to msys bash.exe.
|
||||||
|
+ dir = dir.replace('\\', '/')
|
||||||
|
+ # Ensure the result is an ascii string, across Python2.5+ - Python3.
|
||||||
|
+ return str(dir.decode('ascii'))
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def build_invocation(compile_flags):
|
||||||
|
+ return ' ' + ' '.join([config.clang] + compile_flags) + ' '
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+# Setup substitutions.
|
||||||
|
+config.substitutions.append(
|
||||||
|
+ ('%clang ', build_invocation([config.target_cflags])))
|
||||||
|
+config.substitutions.append(
|
||||||
|
+ ('%clangxx ',
|
||||||
|
+ build_invocation(config.cxx_mode_flags + [config.target_cflags])))
|
||||||
|
+
|
||||||
|
+base_lib = os.path.join(
|
||||||
|
+ config.compiler_rt_libdir, "clang_rt.%%s-%s.o" % config.target_arch)
|
||||||
|
+config.substitutions.append(('%crtbegin', base_lib % "crtbegin"))
|
||||||
|
+config.substitutions.append(('%shared_crtbegin', base_lib % "crtbegin_shared"))
|
||||||
|
+config.substitutions.append(('%crtend', base_lib % "crtend"))
|
||||||
|
+config.substitutions.append(('%shared_crtend', base_lib % "crtend_shared"))
|
||||||
|
+
|
||||||
|
+config.substitutions.append(
|
||||||
|
+ ('%crt1', get_library_path('crt1.o')))
|
||||||
|
+config.substitutions.append(
|
||||||
|
+ ('%crti', get_library_path('crti.o')))
|
||||||
|
+config.substitutions.append(
|
||||||
|
+ ('%crtn', get_library_path('crtn.o')))
|
||||||
|
+
|
||||||
|
+config.substitutions.append(
|
||||||
|
+ ('%libgcc', get_libgcc_file_name()))
|
||||||
|
+
|
||||||
|
+config.substitutions.append(
|
||||||
|
+ ('%libstdcxx', '-l' + config.sanitizer_cxx_lib.lstrip('lib')))
|
||||||
|
+
|
||||||
|
+# Default test suffixes.
|
||||||
|
+config.suffixes = ['.c', '.cc', '.cpp']
|
||||||
|
+
|
||||||
|
+if config.host_os not in ['Linux']:
|
||||||
|
+ config.unsupported = True
|
||||||
|
Index: compiler-rt/test/crt/lit.site.cfg.in
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ compiler-rt/test/crt/lit.site.cfg.in
|
||||||
|
@@ -0,0 +1,14 @@
|
||||||
|
+@LIT_SITE_CFG_IN_HEADER@
|
||||||
|
+
|
||||||
|
+# Tool-specific config options.
|
||||||
|
+config.name_suffix = "@CRT_TEST_CONFIG_SUFFIX@"
|
||||||
|
+config.crt_lit_source_dir = "@CRT_LIT_SOURCE_DIR@"
|
||||||
|
+config.target_cflags = "@CRT_TEST_TARGET_CFLAGS@"
|
||||||
|
+config.target_arch = "@CRT_TEST_TARGET_ARCH@"
|
||||||
|
+config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@"
|
||||||
|
+
|
||||||
|
+# Load common config for all compiler-rt lit tests
|
||||||
|
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
|
||||||
|
+
|
||||||
|
+# Load tool-specific config that would do the real work.
|
||||||
|
+lit_config.load_config(config, "@CRT_LIT_SOURCE_DIR@/lit.cfg")
|
|
@ -0,0 +1,207 @@
|
||||||
|
{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
|
||||||
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||||
|
, buildPackages
|
||||||
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||||
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||||
|
, genodeBase ? null
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
release_version = "11.0.0";
|
||||||
|
version = release_version; # differentiating these (variables) is important for RCs
|
||||||
|
targetConfig = stdenv.targetPlatform.config;
|
||||||
|
|
||||||
|
fetch = name: sha256: fetchurl {
|
||||||
|
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${release_version}/${name}-${version}.src.tar.xz";
|
||||||
|
inherit sha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
clang-tools-extra_src = fetch "clang-tools-extra" "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy";
|
||||||
|
|
||||||
|
tools = stdenv.lib.makeExtensible (tools: let
|
||||||
|
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
|
mkExtraBuildCommands = cc: ''
|
||||||
|
rsrc="$out/resource-root"
|
||||||
|
mkdir "$rsrc"
|
||||||
|
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
|
||||||
|
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||||
|
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||||
|
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||||
|
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
|
||||||
|
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
|
||||||
|
llvm = callPackage ./llvm.nix { };
|
||||||
|
|
||||||
|
clang-unwrapped = callPackage ./clang {
|
||||||
|
inherit (tools) lld;
|
||||||
|
inherit clang-tools-extra_src;
|
||||||
|
};
|
||||||
|
|
||||||
|
# disabled until recommonmark supports sphinx 3
|
||||||
|
#Llvm-manpages = lowPrio (tools.llvm.override {
|
||||||
|
# enableManpages = true;
|
||||||
|
# python3 = pkgs.python3; # don't use python-boot
|
||||||
|
#});
|
||||||
|
|
||||||
|
clang-manpages = lowPrio (tools.clang-unwrapped.override {
|
||||||
|
enableManpages = true;
|
||||||
|
python3 = pkgs.python3; # don't use python-boot
|
||||||
|
});
|
||||||
|
|
||||||
|
# disabled until recommonmark supports sphinx 3
|
||||||
|
# lldb-manpages = lowPrio (tools.lldb.override {
|
||||||
|
# enableManpages = true;
|
||||||
|
# python3 = pkgs.python3; # don't use python-boot
|
||||||
|
# });
|
||||||
|
|
||||||
|
libclang = tools.clang-unwrapped.lib;
|
||||||
|
|
||||||
|
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||||
|
|
||||||
|
libstdcxxClang = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||||
|
libcxx = null;
|
||||||
|
extraPackages = [
|
||||||
|
targetLlvmLibraries.compiler-rt
|
||||||
|
];
|
||||||
|
extraBuildCommands = mkExtraBuildCommands cc;
|
||||||
|
};
|
||||||
|
|
||||||
|
libcxxClang = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = targetLlvmLibraries.libcxx;
|
||||||
|
extraPackages = [
|
||||||
|
targetLlvmLibraries.libcxxabi
|
||||||
|
targetLlvmLibraries.compiler-rt
|
||||||
|
];
|
||||||
|
extraBuildCommands = mkExtraBuildCommands cc;
|
||||||
|
};
|
||||||
|
|
||||||
|
lld = callPackage ./lld.nix {};
|
||||||
|
|
||||||
|
lldb = callPackage ./lldb.nix {};
|
||||||
|
|
||||||
|
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||||
|
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||||
|
# pulled in. As a consequence, it is very quick to build different
|
||||||
|
# targets provided by LLVM and we can also build for what GCC
|
||||||
|
# doesn’t support like LLVM. Probably we should move to some other
|
||||||
|
# file.
|
||||||
|
|
||||||
|
bintools = callPackage ./bintools.nix {};
|
||||||
|
|
||||||
|
lldClang = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = targetLlvmLibraries.libcxx;
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
inherit (tools) bintools;
|
||||||
|
};
|
||||||
|
extraPackages = [
|
||||||
|
targetLlvmLibraries.libcxxabi
|
||||||
|
targetLlvmLibraries.compiler-rt
|
||||||
|
] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||||
|
targetLlvmLibraries.libunwind
|
||||||
|
];
|
||||||
|
extraBuildCommands = ''
|
||||||
|
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
|
||||||
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
|
'' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||||
|
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||||
|
'' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||||
|
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||||
|
'' + stdenv.lib.optionalString stdenv.targetPlatform.isGenode ''
|
||||||
|
echo "-I${genodeBase}/include" >> $out/nix-support/cc-cflags
|
||||||
|
echo "--sysroot=${genodeBase}" >> $out/nix-support/cc-cflags
|
||||||
|
echo "-L ${genodeBase}" >> $out/nix-support/cc-cflags
|
||||||
|
'' + mkExtraBuildCommands cc;
|
||||||
|
};
|
||||||
|
|
||||||
|
lldClangNoLibcxx = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
inherit (tools) bintools;
|
||||||
|
};
|
||||||
|
extraPackages = [
|
||||||
|
targetLlvmLibraries.compiler-rt
|
||||||
|
];
|
||||||
|
extraBuildCommands = ''
|
||||||
|
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||||
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
|
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
||||||
|
'' + stdenv.lib.optionalString stdenv.targetPlatform.isGenode ''
|
||||||
|
echo "-I${genodeBase}/include" >> $out/nix-support/cc-cflags
|
||||||
|
echo "--sysroot=${genodeBase}" >> $out/nix-support/cc-cflags
|
||||||
|
echo "-L${genodeBase}" >> $out/nix-support/cc-cflags
|
||||||
|
echo "-noposix" >> $out/nix-support/cc-cflags
|
||||||
|
'' + mkExtraBuildCommands cc;
|
||||||
|
};
|
||||||
|
|
||||||
|
lldClangNoLibc = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
inherit (tools) bintools;
|
||||||
|
libc = null;
|
||||||
|
};
|
||||||
|
extraPackages = [
|
||||||
|
targetLlvmLibraries.compiler-rt
|
||||||
|
];
|
||||||
|
extraBuildCommands = ''
|
||||||
|
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||||
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
|
'' + mkExtraBuildCommands cc;
|
||||||
|
};
|
||||||
|
|
||||||
|
lldClangNoCompilerRt = wrapCCWith {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
inherit (tools) bintools;
|
||||||
|
libc = null;
|
||||||
|
};
|
||||||
|
extraPackages = [ ];
|
||||||
|
extraBuildCommands = ''
|
||||||
|
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
libraries = stdenv.lib.makeExtensible (libraries: let
|
||||||
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
|
in {
|
||||||
|
|
||||||
|
compiler-rt = callPackage ./compiler-rt.nix ({} //
|
||||||
|
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
||||||
|
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
|
||||||
|
}));
|
||||||
|
|
||||||
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||||
|
|
||||||
|
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||||
|
|
||||||
|
libcxx = callPackage ./libc++ ({} //
|
||||||
|
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
||||||
|
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
|
||||||
|
}));
|
||||||
|
|
||||||
|
libcxxabi = callPackage ./libc++abi.nix ({} //
|
||||||
|
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
||||||
|
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
|
||||||
|
libunwind = libraries.libunwind;
|
||||||
|
}));
|
||||||
|
|
||||||
|
openmp = callPackage ./openmp.nix {};
|
||||||
|
|
||||||
|
libunwind = callPackage ./libunwind.nix ({} //
|
||||||
|
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
||||||
|
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
in { inherit tools libraries; } // libraries // tools
|
|
@ -0,0 +1,53 @@
|
||||||
|
{ lib, stdenv, fetch, cmake, python3, libcxxabi, llvm, fixDarwinDylibNames, version
|
||||||
|
, enableShared ? true }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "libc++";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch "libcxx" "0ylbkcd38zrrz9xmkq9na3d9s8d96hc286dwfwd73wi205lyc7kc";
|
||||||
|
|
||||||
|
postUnpack = ''
|
||||||
|
unpackFile ${libcxxabi.src}
|
||||||
|
mv libcxxabi-* libcxxabi
|
||||||
|
unpackFile ${llvm.src}
|
||||||
|
mv llvm-* llvm
|
||||||
|
'';
|
||||||
|
|
||||||
|
patches =
|
||||||
|
stdenv.lib.optionals stdenv.targetPlatform.isGenode [
|
||||||
|
./genode.patch ./genode-locale.patch
|
||||||
|
];
|
||||||
|
|
||||||
|
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
|
||||||
|
patchShebangs utils/cat_files.py
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake python3 ]
|
||||||
|
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
|
||||||
|
|
||||||
|
buildInputs = [ libcxxabi ];
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
"-DLIBCXX_CXX_ABI=libcxxabi"
|
||||||
|
] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
|
||||||
|
++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
|
||||||
|
++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
|
||||||
|
"-DLIBCXX_ENABLE_THREADS=OFF"
|
||||||
|
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
|
||||||
|
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
|
||||||
|
] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
isLLVM = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = "https://libcxx.llvm.org/";
|
||||||
|
description = "A new implementation of the C++ standard library, targeting C++11";
|
||||||
|
license = with stdenv.lib.licenses; [ ncsa mit ];
|
||||||
|
platforms = stdenv.lib.platforms.all;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
diff --git a/include/locale b/include/locale
|
||||||
|
index 2043892fa2d..6e5c285a7c9 100644
|
||||||
|
--- a/include/locale
|
||||||
|
+++ b/include/locale
|
||||||
|
@@ -737,7 +737,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
|
||||||
|
typename remove_reference<decltype(errno)>::type __save_errno = errno;
|
||||||
|
errno = 0;
|
||||||
|
char *__p2;
|
||||||
|
- long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
|
||||||
|
+ long long __ll = strtoll(__a, &__p2, __base);
|
||||||
|
typename remove_reference<decltype(errno)>::type __current_errno = errno;
|
||||||
|
if (__current_errno == 0)
|
||||||
|
errno = __save_errno;
|
||||||
|
@@ -777,7 +777,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
|
||||||
|
typename remove_reference<decltype(errno)>::type __save_errno = errno;
|
||||||
|
errno = 0;
|
||||||
|
char *__p2;
|
||||||
|
- unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
|
||||||
|
+ unsigned long long __ll = strtoull(__a, &__p2, __base);
|
||||||
|
typename remove_reference<decltype(errno)>::type __current_errno = errno;
|
||||||
|
if (__current_errno == 0)
|
||||||
|
errno = __save_errno;
|
||||||
|
@@ -806,19 +806,19 @@ _Tp __do_strtod(const char* __a, char** __p2);
|
||||||
|
template <>
|
||||||
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
|
float __do_strtod<float>(const char* __a, char** __p2) {
|
||||||
|
- return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
|
||||||
|
+ return strtof(__a, __p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
|
double __do_strtod<double>(const char* __a, char** __p2) {
|
||||||
|
- return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
|
||||||
|
+ return strtod(__a, __p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
|
long double __do_strtod<long double>(const char* __a, char** __p2) {
|
||||||
|
- return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
|
||||||
|
+ return strtold(__a, __p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class _Tp>
|
||||||
|
@@ -1197,13 +1197,13 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
|
||||||
|
*__oe++ = __ct.widen(*__nf++);
|
||||||
|
*__oe++ = __ct.widen(*__nf++);
|
||||||
|
for (__ns = __nf; __ns < __ne; ++__ns)
|
||||||
|
- if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
|
||||||
|
+ if (!isxdigit(*__ns))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (__ns = __nf; __ns < __ne; ++__ns)
|
||||||
|
- if (!isdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
|
||||||
|
+ if (!isdigit(*__ns))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (__grouping.empty())
|
|
@ -0,0 +1,34 @@
|
||||||
|
diff --git a/include/__config b/include/__config
|
||||||
|
index 575147cead42..8f0bb7248113 100644
|
||||||
|
--- a/include/__config
|
||||||
|
+++ b/include/__config
|
||||||
|
@@ -921,7 +921,7 @@ typedef unsigned int char32_t;
|
||||||
|
|
||||||
|
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
|
// Most unix variants have catopen. These are the specific ones that don't.
|
||||||
|
-# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
|
||||||
|
+# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__GENODE__)
|
||||||
|
# define _LIBCPP_HAS_CATOPEN 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
@@ -1130,6 +1130,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||||
|
defined(__APPLE__) || \
|
||||||
|
defined(__CloudABI__) || \
|
||||||
|
defined(__sun__) || \
|
||||||
|
+ defined(__GENODE__) || \
|
||||||
|
(defined(__MINGW32__) && __has_include(<pthread.h>))
|
||||||
|
# define _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||||
|
# elif defined(__Fuchsia__)
|
||||||
|
diff --git a/utils/google-benchmark/src/internal_macros.h b/utils/google-benchmark/src/internal_macros.h
|
||||||
|
index 5dbf4fd27521..4699c5ed9139 100644
|
||||||
|
--- a/utils/google-benchmark/src/internal_macros.h
|
||||||
|
+++ b/utils/google-benchmark/src/internal_macros.h
|
||||||
|
@@ -70,6 +70,8 @@
|
||||||
|
#define BENCHMARK_OS_FUCHSIA 1
|
||||||
|
#elif defined (__SVR4) && defined (__sun)
|
||||||
|
#define BENCHMARK_OS_SOLARIS 1
|
||||||
|
+#elif defined(__GENODE__)
|
||||||
|
+ #define BENCHMARK_OS_GENODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__ANDROID__) && defined(__GLIBCXX__)
|
|
@ -0,0 +1,70 @@
|
||||||
|
{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
|
||||||
|
, enableShared ? true }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "libc++abi";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch "libcxxabi" "05ac7rkjbla03bc0lf92f901dfjgxdvp8cr9fpn59a5p4x27ssaq";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake ];
|
||||||
|
buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
|
||||||
|
|
||||||
|
cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
|
||||||
|
"-DLLVM_ENABLE_LIBCXX=ON"
|
||||||
|
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
|
||||||
|
] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
|
||||||
|
"-DLIBCXXABI_ENABLE_THREADS=OFF"
|
||||||
|
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
|
||||||
|
] ++ stdenv.lib.optionals (!enableShared) [
|
||||||
|
"-DLIBCXXABI_ENABLE_SHARED=OFF"
|
||||||
|
];
|
||||||
|
|
||||||
|
patches = [ ./libcxxabi-no-threads.patch ];
|
||||||
|
|
||||||
|
postUnpack = ''
|
||||||
|
unpackFile ${libcxx.src}
|
||||||
|
mv libcxx-* libcxx
|
||||||
|
unpackFile ${llvm.src}
|
||||||
|
mv llvm-* llvm
|
||||||
|
'' + stdenv.lib.optionalString stdenv.isDarwin ''
|
||||||
|
export TRIPLE=x86_64-apple-darwin
|
||||||
|
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
|
||||||
|
patch -p1 -d libcxx -i ${../libcxx-0001-musl-hacks.patch}
|
||||||
|
'' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
|
||||||
|
patch -p1 -d llvm -i ${./libcxxabi-wasm.patch}
|
||||||
|
'' + stdenv.lib.optionalString stdenv.targetPlatform.isGenode ''
|
||||||
|
patch -p1 -d libcxx -i ${./libc++/genode.patch}
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = if stdenv.isDarwin
|
||||||
|
then ''
|
||||||
|
for file in lib/*.dylib; do
|
||||||
|
# this should be done in CMake, but having trouble figuring out
|
||||||
|
# the magic combination of necessary CMake variables
|
||||||
|
# if you fancy a try, take a look at
|
||||||
|
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
|
||||||
|
install_name_tool -id $out/$file $file
|
||||||
|
done
|
||||||
|
make install
|
||||||
|
install -d 755 $out/include
|
||||||
|
install -m 644 ../include/*.h $out/include
|
||||||
|
''
|
||||||
|
else ''
|
||||||
|
install -d -m 755 $out/include $out/lib
|
||||||
|
install -m 644 lib/libc++abi.a $out/lib
|
||||||
|
install -m 644 ../include/cxxabi.h $out/include
|
||||||
|
'' + stdenv.lib.optionalString enableShared ''
|
||||||
|
install -m 644 lib/libc++abi.so.1.0 $out/lib
|
||||||
|
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
|
||||||
|
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = "https://libcxxabi.llvm.org/";
|
||||||
|
description = "A new implementation of low level support for a standard C++ library";
|
||||||
|
license = with stdenv.lib.licenses; [ ncsa mit ];
|
||||||
|
maintainers = with stdenv.lib.maintainers; [ vlstill ];
|
||||||
|
platforms = stdenv.lib.platforms.all;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 4138acf..41b4763 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -362,6 +362,7 @@ if (NOT LIBCXXABI_ENABLE_THREADS)
|
||||||
|
" is also set to ON.")
|
||||||
|
endif()
|
||||||
|
add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
|
||||||
|
+ add_definitions(-D_LIBCPP_HAS_NO_THREADS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
|
|
@ -0,0 +1,16 @@
|
||||||
|
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
|
||||||
|
index 15497d405e0..33f7f18193a 100644
|
||||||
|
--- a/cmake/modules/HandleLLVMOptions.cmake
|
||||||
|
+++ b/cmake/modules/HandleLLVMOptions.cmake
|
||||||
|
@@ -127,7 +127,10 @@ else(WIN32)
|
||||||
|
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
|
||||||
|
endif()
|
||||||
|
else(FUCHSIA OR UNIX)
|
||||||
|
- MESSAGE(SEND_ERROR "Unable to determine platform")
|
||||||
|
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Wasi")
|
||||||
|
+ else()
|
||||||
|
+ MESSAGE(SEND_ERROR "Unable to determine platform")
|
||||||
|
+ endif()
|
||||||
|
endif(FUCHSIA OR UNIX)
|
||||||
|
endif(WIN32)
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
{ stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "libunwind";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch pname "0bwjd2xf51r2apn8p0f9shb6nc8hnqzq1n9gggjvyjmi6cf02mc4";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake ];
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp
|
||||||
|
index 4637a3b306da..b472f5c2b453 100644
|
||||||
|
--- a/ELF/Driver.cpp
|
||||||
|
+++ b/ELF/Driver.cpp
|
||||||
|
@@ -254,12 +254,8 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
|
||||||
|
// file has a DT_SONAME or not because we haven't parsed it yet.
|
||||||
|
// Here, we set the default soname for the file because we might
|
||||||
|
// need it later.
|
||||||
|
- //
|
||||||
|
- // If a file was specified by -lfoo, the directory part is not
|
||||||
|
- // significant, as a user did not specify it. This behavior is
|
||||||
|
- // compatible with GNU.
|
||||||
|
files.push_back(
|
||||||
|
- make<SharedFile>(mbref, withLOption ? path::filename(path) : path));
|
||||||
|
+ make<SharedFile>(mbref, path));
|
||||||
|
return;
|
||||||
|
case file_magic::bitcode:
|
||||||
|
case file_magic::elf_relocatable:
|
||||||
|
diff --git a/ELF/DriverUtils.cpp b/ELF/DriverUtils.cpp
|
||||||
|
index e33b07c0c9c9..e8d4e4f4497f 100644
|
||||||
|
--- a/ELF/DriverUtils.cpp
|
||||||
|
+++ b/ELF/DriverUtils.cpp
|
||||||
|
@@ -205,14 +205,16 @@ std::string elf::createResponseFile(const opt::InputArgList &args) {
|
||||||
|
// Find a file by concatenating given paths. If a resulting path
|
||||||
|
// starts with "=", the character is replaced with a --sysroot value.
|
||||||
|
static Optional<std::string> findFile(StringRef path1, const Twine &path2) {
|
||||||
|
- SmallString<128> s;
|
||||||
|
+ SmallString<256> s;
|
||||||
|
if (path1.startswith("="))
|
||||||
|
path::append(s, config->sysroot, path1.substr(1), path2);
|
||||||
|
else
|
||||||
|
path::append(s, path1, path2);
|
||||||
|
|
||||||
|
- if (fs::exists(s))
|
||||||
|
- return std::string(s);
|
||||||
|
+ SmallString<256> RealPath;
|
||||||
|
+ fs::real_path(s, RealPath);
|
||||||
|
+ if (fs::exists(RealPath))
|
||||||
|
+ return RealPath.str().str();
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -226,10 +228,22 @@ Optional<std::string> elf::findFromSearchPaths(StringRef path) {
|
||||||
|
// This is for -l<basename>. We'll look for lib<basename>.so or lib<basename>.a from
|
||||||
|
// search paths.
|
||||||
|
Optional<std::string> elf::searchLibraryBaseName(StringRef name) {
|
||||||
|
+
|
||||||
|
for (StringRef dir : config->searchPaths) {
|
||||||
|
if (!config->isStatic)
|
||||||
|
- if (Optional<std::string> s = findFile(dir, "lib" + name + ".so"))
|
||||||
|
- return s;
|
||||||
|
+ if (name.size() == 1) {
|
||||||
|
+ if (Optional<std::string> s = findFile(dir, "lib" + name + ".lib.so"))
|
||||||
|
+ return s;
|
||||||
|
+ if (Optional<std::string> s = findFile(dir, "lib" + name + ".so"))
|
||||||
|
+ return s;
|
||||||
|
+ } else {
|
||||||
|
+ if (Optional<std::string> s = findFile(dir, name + ".lib.so"))
|
||||||
|
+ return s;
|
||||||
|
+ if (Optional<std::string> s = findFile(dir, "lib" + name + ".so"))
|
||||||
|
+ return s;
|
||||||
|
+ }
|
||||||
|
+ if (Optional<std::string> s = findFile(dir, name + ".lib.a"))
|
||||||
|
+ return s;
|
||||||
|
if (Optional<std::string> s = findFile(dir, "lib" + name + ".a"))
|
||||||
|
return s;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
{ stdenv
|
||||||
|
, fetch
|
||||||
|
, cmake
|
||||||
|
, libxml2
|
||||||
|
, llvm
|
||||||
|
, version
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "lld";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch pname "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake ];
|
||||||
|
buildInputs = [ llvm libxml2 ];
|
||||||
|
|
||||||
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
patches = [ ./lld-genode.patch ];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
moveToOutput include "$dev"
|
||||||
|
moveToOutput lib "$dev"
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "The LLVM Linker";
|
||||||
|
homepage = "https://lld.llvm.org/";
|
||||||
|
license = stdenv.lib.licenses.ncsa;
|
||||||
|
platforms = stdenv.lib.platforms.all;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
--- a/source/Plugins/Process/Linux/Procfs.h
|
||||||
|
+++ b/source/Plugins/Process/Linux/Procfs.h
|
||||||
|
@@ -11,21 +11,12 @@
|
||||||
|
// sys/procfs.h on Android/Linux for all supported architectures.
|
||||||
|
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
+#include <asm/ptrace.h>
|
||||||
|
|
||||||
|
-#ifdef __ANDROID__
|
||||||
|
-#if defined(__arm64__) || defined(__aarch64__)
|
||||||
|
-typedef unsigned long elf_greg_t;
|
||||||
|
-typedef elf_greg_t
|
||||||
|
- elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
|
||||||
|
-typedef struct user_fpsimd_state elf_fpregset_t;
|
||||||
|
-#ifndef NT_FPREGSET
|
||||||
|
-#define NT_FPREGSET NT_PRFPREG
|
||||||
|
-#endif // NT_FPREGSET
|
||||||
|
-#elif defined(__mips__)
|
||||||
|
-#ifndef NT_FPREGSET
|
||||||
|
-#define NT_FPREGSET NT_PRFPREG
|
||||||
|
-#endif // NT_FPREGSET
|
||||||
|
-#endif
|
||||||
|
-#else // __ANDROID__
|
||||||
|
+#if !defined(__GLIBC__) && defined(__powerpc__)
|
||||||
|
+#define pt_regs musl_pt_regs
|
||||||
|
+#include <sys/procfs.h>
|
||||||
|
+#undef pt_regs
|
||||||
|
+#else
|
||||||
|
#include <sys/procfs.h>
|
||||||
|
-#endif // __ANDROID__
|
||||||
|
+#endif
|
|
@ -0,0 +1,101 @@
|
||||||
|
{ stdenv
|
||||||
|
, fetch
|
||||||
|
, cmake
|
||||||
|
, zlib
|
||||||
|
, ncurses
|
||||||
|
, swig
|
||||||
|
, which
|
||||||
|
, libedit
|
||||||
|
, libxml2
|
||||||
|
, llvm
|
||||||
|
, clang-unwrapped
|
||||||
|
, python3
|
||||||
|
, version
|
||||||
|
, darwin
|
||||||
|
, lit
|
||||||
|
, enableManpages ? false
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation (rec {
|
||||||
|
pname = "lldb";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch pname "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45";
|
||||||
|
|
||||||
|
patches = [ ./lldb-procfs.patch ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake python3 which swig lit ]
|
||||||
|
++ stdenv.lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
ncurses
|
||||||
|
zlib
|
||||||
|
libedit
|
||||||
|
libxml2
|
||||||
|
llvm
|
||||||
|
]
|
||||||
|
++ stdenv.lib.optionals stdenv.isDarwin [
|
||||||
|
darwin.libobjc
|
||||||
|
darwin.apple_sdk.libs.xpc
|
||||||
|
darwin.apple_sdk.frameworks.Foundation
|
||||||
|
darwin.bootstrap_cmds
|
||||||
|
darwin.apple_sdk.frameworks.Carbon
|
||||||
|
darwin.apple_sdk.frameworks.Cocoa
|
||||||
|
];
|
||||||
|
|
||||||
|
hardeningDisable = [ "format" ];
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
"-DLLVM_ENABLE_RTTI=OFF"
|
||||||
|
"-DClang_DIR=${clang-unwrapped}/lib/cmake"
|
||||||
|
"-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
|
||||||
|
] ++ stdenv.lib.optionals stdenv.isDarwin [
|
||||||
|
"-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
|
||||||
|
] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
|
||||||
|
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
|
||||||
|
] ++ stdenv.lib.optionals enableManpages [
|
||||||
|
"-DLLVM_ENABLE_SPHINX=ON"
|
||||||
|
"-DSPHINX_OUTPUT_MAN=ON"
|
||||||
|
"-DSPHINX_OUTPUT_HTML=OFF"
|
||||||
|
];
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
# Editor support
|
||||||
|
# vscode:
|
||||||
|
install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
|
||||||
|
mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
|
||||||
|
ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
description = "A next-generation high-performance debugger";
|
||||||
|
homepage = "https://lldb.llvm.org";
|
||||||
|
license = licenses.ncsa;
|
||||||
|
platforms = platforms.all;
|
||||||
|
};
|
||||||
|
} // stdenv.lib.optionalAttrs enableManpages {
|
||||||
|
pname = "lldb-manpages";
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
make docs-lldb-man
|
||||||
|
'';
|
||||||
|
|
||||||
|
propagatedBuildInputs = [];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
# manually install lldb man page
|
||||||
|
mkdir -p $out/share/man/man1
|
||||||
|
install docs/man/lldb.1 -t $out/share/man/man1/
|
||||||
|
'';
|
||||||
|
|
||||||
|
postPatch = null;
|
||||||
|
postInstall = null;
|
||||||
|
|
||||||
|
outputs = [ "out" ];
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta.description = "man pages for LLDB ${version}";
|
||||||
|
})
|
|
@ -0,0 +1,157 @@
|
||||||
|
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
|
||||||
|
index 5ef22eb493ba..f40625c7eed2 100644
|
||||||
|
--- a/cmake/modules/HandleLLVMOptions.cmake
|
||||||
|
+++ b/cmake/modules/HandleLLVMOptions.cmake
|
||||||
|
@@ -132,7 +132,7 @@ if(WIN32)
|
||||||
|
set(LLVM_ON_UNIX 0)
|
||||||
|
endif(CYGWIN)
|
||||||
|
else(WIN32)
|
||||||
|
- if(FUCHSIA OR UNIX)
|
||||||
|
+ if(FUCHSIA OR GENODE OR UNIX)
|
||||||
|
set(LLVM_ON_WIN32 0)
|
||||||
|
set(LLVM_ON_UNIX 1)
|
||||||
|
if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
||||||
|
@@ -140,9 +140,9 @@ else(WIN32)
|
||||||
|
else()
|
||||||
|
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
|
||||||
|
endif()
|
||||||
|
- else(FUCHSIA OR UNIX)
|
||||||
|
+ else(FUCHSIA OR GENODE OR UNIX)
|
||||||
|
MESSAGE(SEND_ERROR "Unable to determine platform")
|
||||||
|
- endif(FUCHSIA OR UNIX)
|
||||||
|
+ endif(FUCHSIA OR GENODE OR UNIX)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
|
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
|
||||||
|
index 6bad18f19244..95459ca997c5 100644
|
||||||
|
--- a/include/llvm/ADT/Triple.h
|
||||||
|
+++ b/include/llvm/ADT/Triple.h
|
||||||
|
@@ -166,6 +166,7 @@ public:
|
||||||
|
DragonFly,
|
||||||
|
FreeBSD,
|
||||||
|
Fuchsia,
|
||||||
|
+ Genode,
|
||||||
|
IOS,
|
||||||
|
KFreeBSD,
|
||||||
|
Linux,
|
||||||
|
@@ -502,6 +503,8 @@ public:
|
||||||
|
|
||||||
|
bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
|
||||||
|
|
||||||
|
+ bool isOSGenode() const { return getOS() == Triple::Genode; }
|
||||||
|
+
|
||||||
|
bool isOSSolaris() const {
|
||||||
|
return getOS() == Triple::Solaris;
|
||||||
|
}
|
||||||
|
diff --git a/include/llvm/BinaryFormat/ELF.h b/include/llvm/BinaryFormat/ELF.h
|
||||||
|
index bdcf10fd1640..46ed8e56cc31 100644
|
||||||
|
--- a/include/llvm/BinaryFormat/ELF.h
|
||||||
|
+++ b/include/llvm/BinaryFormat/ELF.h
|
||||||
|
@@ -348,6 +348,7 @@ enum {
|
||||||
|
ELFOSABI_AROS = 15, // AROS
|
||||||
|
ELFOSABI_FENIXOS = 16, // FenixOS
|
||||||
|
ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
|
||||||
|
+ ELFOSABI_GENODE = 18, // Genode
|
||||||
|
ELFOSABI_FIRST_ARCH = 64, // First architecture-specific OS ABI
|
||||||
|
ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
|
||||||
|
ELFOSABI_AMDGPU_PAL = 65, // AMD PAL runtime
|
||||||
|
diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h
|
||||||
|
index 8f78b99d3794..7a1d1981f60d 100644
|
||||||
|
--- a/include/llvm/MC/MCELFObjectWriter.h
|
||||||
|
+++ b/include/llvm/MC/MCELFObjectWriter.h
|
||||||
|
@@ -74,6 +74,8 @@ public:
|
||||||
|
switch (OSType) {
|
||||||
|
case Triple::CloudABI:
|
||||||
|
return ELF::ELFOSABI_CLOUDABI;
|
||||||
|
+ case Triple::Genode:
|
||||||
|
+ return ELF::ELFOSABI_GENODE;
|
||||||
|
case Triple::HermitCore:
|
||||||
|
return ELF::ELFOSABI_STANDALONE;
|
||||||
|
case Triple::PS4:
|
||||||
|
diff --git a/lib/ObjectYAML/ELFYAML.cpp b/lib/ObjectYAML/ELFYAML.cpp
|
||||||
|
index 2353b34f188b..e93f53c40888 100644
|
||||||
|
--- a/lib/ObjectYAML/ELFYAML.cpp
|
||||||
|
+++ b/lib/ObjectYAML/ELFYAML.cpp
|
||||||
|
@@ -268,6 +268,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
|
||||||
|
ECase(ELFOSABI_AROS);
|
||||||
|
ECase(ELFOSABI_FENIXOS);
|
||||||
|
ECase(ELFOSABI_CLOUDABI);
|
||||||
|
+ ECase(ELFOSABI_GENODE);
|
||||||
|
ECase(ELFOSABI_AMDGPU_HSA);
|
||||||
|
ECase(ELFOSABI_AMDGPU_PAL);
|
||||||
|
ECase(ELFOSABI_AMDGPU_MESA3D);
|
||||||
|
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
|
||||||
|
index fec1985ccaca..1f3e4f07fb8e 100644
|
||||||
|
--- a/lib/Support/Triple.cpp
|
||||||
|
+++ b/lib/Support/Triple.cpp
|
||||||
|
@@ -197,6 +197,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
|
||||||
|
case Emscripten: return "emscripten";
|
||||||
|
case FreeBSD: return "freebsd";
|
||||||
|
case Fuchsia: return "fuchsia";
|
||||||
|
+ case Genode: return "genode";
|
||||||
|
case Haiku: return "haiku";
|
||||||
|
case HermitCore: return "hermit";
|
||||||
|
case Hurd: return "hurd";
|
||||||
|
@@ -494,6 +495,7 @@ static Triple::OSType parseOS(StringRef OSName) {
|
||||||
|
.StartsWith("dragonfly", Triple::DragonFly)
|
||||||
|
.StartsWith("freebsd", Triple::FreeBSD)
|
||||||
|
.StartsWith("fuchsia", Triple::Fuchsia)
|
||||||
|
+ .StartsWith("genode", Triple::Genode)
|
||||||
|
.StartsWith("ios", Triple::IOS)
|
||||||
|
.StartsWith("kfreebsd", Triple::KFreeBSD)
|
||||||
|
.StartsWith("linux", Triple::Linux)
|
||||||
|
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp
|
||||||
|
index 15076f1f8933..b0636e7eb196 100644
|
||||||
|
--- a/tools/llvm-readobj/ELFDumper.cpp
|
||||||
|
+++ b/tools/llvm-readobj/ELFDumper.cpp
|
||||||
|
@@ -1334,6 +1334,7 @@ static const EnumEntry<unsigned> ElfOSABI[] = {
|
||||||
|
{"AROS", "AROS", ELF::ELFOSABI_AROS},
|
||||||
|
{"FenixOS", "FenixOS", ELF::ELFOSABI_FENIXOS},
|
||||||
|
{"CloudABI", "CloudABI", ELF::ELFOSABI_CLOUDABI},
|
||||||
|
+ {"Genode", "Genode", ELF::ELFOSABI_GENODE},
|
||||||
|
{"Standalone", "Standalone App", ELF::ELFOSABI_STANDALONE}
|
||||||
|
};
|
||||||
|
|
||||||
|
diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp
|
||||||
|
index dc7a28c72f20..eb62772c1dda 100644
|
||||||
|
--- a/unittests/ADT/TripleTest.cpp
|
||||||
|
+++ b/unittests/ADT/TripleTest.cpp
|
||||||
|
@@ -248,6 +248,12 @@ TEST(TripleTest, ParsedIDs) {
|
||||||
|
EXPECT_EQ(Triple::Fuchsia, T.getOS());
|
||||||
|
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
||||||
|
|
||||||
|
+ T = Triple("x86_64-unknown-genode");
|
||||||
|
+ EXPECT_EQ(Triple::x86_64, T.getArch());
|
||||||
|
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
||||||
|
+ EXPECT_EQ(Triple::Genode, T.getOS());
|
||||||
|
+ EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
|
||||||
|
+
|
||||||
|
T = Triple("x86_64-unknown-hermit");
|
||||||
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
||||||
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
||||||
|
diff --git a/utils/benchmark/src/internal_macros.h b/utils/benchmark/src/internal_macros.h
|
||||||
|
index f2d54bfcbd9d..e20f891d435b 100644
|
||||||
|
--- a/utils/benchmark/src/internal_macros.h
|
||||||
|
+++ b/utils/benchmark/src/internal_macros.h
|
||||||
|
@@ -65,6 +65,8 @@
|
||||||
|
#define BENCHMARK_OS_FUCHSIA 1
|
||||||
|
#elif defined (__SVR4) && defined (__sun)
|
||||||
|
#define BENCHMARK_OS_SOLARIS 1
|
||||||
|
+#elif defined(__GENODE__)
|
||||||
|
+ #define BENCHMARK_OS_GENODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \
|
||||||
|
diff --git a/utils/gn/secondary/clang/lib/Driver/BUILD.gn b/utils/gn/secondary/clang/lib/Driver/BUILD.gn
|
||||||
|
index 04d483a12eed..e487a9a9a016 100644
|
||||||
|
--- a/utils/gn/secondary/clang/lib/Driver/BUILD.gn
|
||||||
|
+++ b/utils/gn/secondary/clang/lib/Driver/BUILD.gn
|
||||||
|
@@ -66,6 +66,7 @@ static_library("Driver") {
|
||||||
|
"ToolChains/Flang.cpp",
|
||||||
|
"ToolChains/FreeBSD.cpp",
|
||||||
|
"ToolChains/Fuchsia.cpp",
|
||||||
|
+ "ToolChains/Genode.cpp",
|
||||||
|
"ToolChains/Gnu.cpp",
|
||||||
|
"ToolChains/HIP.cpp",
|
||||||
|
"ToolChains/Haiku.cpp",
|
|
@ -0,0 +1,26 @@
|
||||||
|
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
|
||||||
|
index 94d426b..37f7794 100644
|
||||||
|
--- a/tools/llvm-config/llvm-config.cpp
|
||||||
|
+++ b/tools/llvm-config/llvm-config.cpp
|
||||||
|
@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
|
||||||
|
ActiveIncludeOption = "-I" + ActiveIncludeDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
|
||||||
|
+ if (!IsInDevelopmentTree) {
|
||||||
|
+ bool WantShared = true;
|
||||||
|
+ for (int i = 1; i < argc; ++i) {
|
||||||
|
+ StringRef Arg = argv[i];
|
||||||
|
+ if (Arg == "--link-shared")
|
||||||
|
+ WantShared = true;
|
||||||
|
+ else if (Arg == "--link-static")
|
||||||
|
+ WantShared = false; // the last one wins
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (WantShared)
|
||||||
|
+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/// We only use `shared library` mode in cases where the static library form
|
||||||
|
/// of the components provided are not available; note however that this is
|
||||||
|
/// skipped if we're run from within the build dir. However, once installed,
|
|
@ -0,0 +1,192 @@
|
||||||
|
{ stdenv
|
||||||
|
, fetch
|
||||||
|
, cmake
|
||||||
|
, python3
|
||||||
|
, libffi
|
||||||
|
, libbfd
|
||||||
|
, libpfm
|
||||||
|
, libxml2
|
||||||
|
, ncurses
|
||||||
|
, version
|
||||||
|
, release_version
|
||||||
|
, zlib
|
||||||
|
, buildPackages
|
||||||
|
, debugVersion ? false
|
||||||
|
, enableManpages ? false
|
||||||
|
, enableSharedLibraries ? true
|
||||||
|
, enablePFM ? !(stdenv.isDarwin
|
||||||
|
|| stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
|
||||||
|
|| stdenv.isAarch32 # broken for the armv7l builder
|
||||||
|
)
|
||||||
|
, enablePolly ? false
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (stdenv.lib) optional optionals optionalString;
|
||||||
|
|
||||||
|
# Used when creating a version-suffixed symlink of libLLVM.dylib
|
||||||
|
shortVersion = with stdenv.lib;
|
||||||
|
concatStringsSep "." (take 1 (splitString "." release_version));
|
||||||
|
|
||||||
|
in stdenv.mkDerivation (rec {
|
||||||
|
pname = "llvm";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch pname "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi";
|
||||||
|
polly_src = fetch "polly" "0h442ivcslr3dv3q3g1nw5avh77f8cxsp6zild1hgspj266xpynw";
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
unpackFile $src
|
||||||
|
mv llvm-${version}* llvm
|
||||||
|
sourceRoot=$PWD/llvm
|
||||||
|
'' + optionalString enablePolly ''
|
||||||
|
unpackFile $polly_src
|
||||||
|
mv polly-* $sourceRoot/tools/polly
|
||||||
|
'';
|
||||||
|
|
||||||
|
outputs = [ "out" "python" ]
|
||||||
|
++ optional enableSharedLibraries "lib";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake python3 ]
|
||||||
|
++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
|
||||||
|
|
||||||
|
buildInputs = [ libxml2 libffi ]
|
||||||
|
++ optional enablePFM libpfm; # exegesis
|
||||||
|
|
||||||
|
propagatedBuildInputs = [ ncurses zlib ];
|
||||||
|
|
||||||
|
patches = [ ./llvm-genode.patch ];
|
||||||
|
|
||||||
|
postPatch = optionalString stdenv.isDarwin ''
|
||||||
|
substituteInPlace cmake/modules/AddLLVM.cmake \
|
||||||
|
--replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
|
||||||
|
--replace 'set(_install_rpath "@loader_path/../lib''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
|
||||||
|
''
|
||||||
|
# Patch llvm-config to return correct library path based on --link-{shared,static}.
|
||||||
|
+ optionalString (enableSharedLibraries) ''
|
||||||
|
substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
|
||||||
|
patch -p1 < ./llvm-outputs.patch
|
||||||
|
'' + ''
|
||||||
|
# FileSystem permissions tests fail with various special bits
|
||||||
|
substituteInPlace unittests/Support/CMakeLists.txt \
|
||||||
|
--replace "Path.cpp" ""
|
||||||
|
rm unittests/Support/Path.cpp
|
||||||
|
'' + optionalString stdenv.hostPlatform.isMusl ''
|
||||||
|
patch -p1 -i ${../TLI-musl.patch}
|
||||||
|
substituteInPlace unittests/Support/CMakeLists.txt \
|
||||||
|
--replace "add_subdirectory(DynamicLibrary)" ""
|
||||||
|
rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
|
||||||
|
# valgrind unhappy with musl or glibc, but fails w/musl only
|
||||||
|
rm test/CodeGen/AArch64/wineh4.mir
|
||||||
|
'' + optionalString stdenv.hostPlatform.isAarch32 ''
|
||||||
|
# skip failing X86 test cases on 32-bit ARM
|
||||||
|
rm test/DebugInfo/X86/convert-debugloc.ll
|
||||||
|
rm test/DebugInfo/X86/convert-inlined.ll
|
||||||
|
rm test/DebugInfo/X86/convert-linked.ll
|
||||||
|
rm test/tools/dsymutil/X86/op-convert.test
|
||||||
|
'' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
|
||||||
|
# Seems to require certain floating point hardware (NEON?)
|
||||||
|
rm test/ExecutionEngine/frem.ll
|
||||||
|
'' + ''
|
||||||
|
patchShebangs test/BugPoint/compile-custom.ll.py
|
||||||
|
'';
|
||||||
|
|
||||||
|
# hacky fix: created binaries need to be run before installation
|
||||||
|
preBuild = ''
|
||||||
|
mkdir -p $out/
|
||||||
|
ln -sv $PWD/lib $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
# E.g. mesa.drivers use the build-id as a cache key (see #93946):
|
||||||
|
LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1";
|
||||||
|
|
||||||
|
cmakeFlags = with stdenv; [
|
||||||
|
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
|
||||||
|
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
|
||||||
|
"-DLLVM_BUILD_TESTS=ON"
|
||||||
|
"-DLLVM_ENABLE_FFI=ON"
|
||||||
|
"-DLLVM_ENABLE_RTTI=ON"
|
||||||
|
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
|
||||||
|
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
|
||||||
|
"-DLLVM_ENABLE_DUMP=ON"
|
||||||
|
] ++ optionals enableSharedLibraries [
|
||||||
|
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
||||||
|
] ++ optionals enableManpages [
|
||||||
|
"-DLLVM_BUILD_DOCS=ON"
|
||||||
|
"-DLLVM_ENABLE_SPHINX=ON"
|
||||||
|
"-DSPHINX_OUTPUT_MAN=ON"
|
||||||
|
"-DSPHINX_OUTPUT_HTML=OFF"
|
||||||
|
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
||||||
|
] ++ optionals (!isDarwin) [
|
||||||
|
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
|
||||||
|
] ++ optionals isDarwin [
|
||||||
|
"-DLLVM_ENABLE_LIBCXX=ON"
|
||||||
|
"-DCAN_TARGET_i386=false"
|
||||||
|
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||||
|
"-DCMAKE_CROSSCOMPILING=True"
|
||||||
|
"-DLLVM_TABLEGEN=${buildPackages.llvm_10}/bin/llvm-tblgen"
|
||||||
|
];
|
||||||
|
|
||||||
|
postBuild = ''
|
||||||
|
rm -fR $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
preCheck = ''
|
||||||
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $python/share
|
||||||
|
mv $out/share/opt-viewer $python/share/opt-viewer
|
||||||
|
''
|
||||||
|
+ optionalString enableSharedLibraries ''
|
||||||
|
moveToOutput "lib/libLLVM-*" "$lib"
|
||||||
|
moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
|
||||||
|
''
|
||||||
|
+ optionalString (enableSharedLibraries && (!stdenv.isDarwin)) ''
|
||||||
|
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
|
||||||
|
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
|
||||||
|
''
|
||||||
|
+ optionalString (stdenv.isDarwin && enableSharedLibraries) ''
|
||||||
|
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
|
||||||
|
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
|
||||||
|
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
|
||||||
|
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = stdenv.isLinux && (!stdenv.isx86_32);
|
||||||
|
|
||||||
|
checkTarget = "check-all";
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
requiredSystemFeatures = [ "big-parallel" ];
|
||||||
|
meta = {
|
||||||
|
description = "Collection of modular and reusable compiler and toolchain technologies";
|
||||||
|
homepage = "https://llvm.org/";
|
||||||
|
license = stdenv.lib.licenses.ncsa;
|
||||||
|
maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill primeos ];
|
||||||
|
platforms = stdenv.lib.platforms.all;
|
||||||
|
};
|
||||||
|
} // stdenv.lib.optionalAttrs enableManpages {
|
||||||
|
pname = "llvm-manpages";
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
make docs-llvm-man
|
||||||
|
'';
|
||||||
|
|
||||||
|
propagatedBuildInputs = [];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
make -C docs install
|
||||||
|
'';
|
||||||
|
|
||||||
|
postPatch = null;
|
||||||
|
postInstall = null;
|
||||||
|
|
||||||
|
outputs = [ "out" ];
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta.description = "man pages for LLVM ${version}";
|
||||||
|
})
|
|
@ -0,0 +1,26 @@
|
||||||
|
{ stdenv
|
||||||
|
, fetch
|
||||||
|
, cmake
|
||||||
|
, llvm
|
||||||
|
, perl
|
||||||
|
, version
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "openmp";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetch pname "0k389d0g9zlfyzh1kpb3i5jdawzpn0hrdxzbjinpvdv7rbw4sw1d";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake perl ];
|
||||||
|
buildInputs = [ llvm ];
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Components required to build an executable OpenMP program";
|
||||||
|
homepage = "https://openmp.llvm.org/";
|
||||||
|
license = stdenv.lib.licenses.mit;
|
||||||
|
platforms = stdenv.lib.platforms.all;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,412 @@
|
||||||
|
From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Will Dietz <w@wdtz.org>
|
||||||
|
Date: Mon, 24 Sep 2018 11:17:25 -0500
|
||||||
|
Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project.
|
||||||
|
|
||||||
|
------
|
||||||
|
Ported to compiler-rt-sanitizers-5.0.0. Taken from
|
||||||
|
|
||||||
|
https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
|
||||||
|
Signed-off-by: Jory A. Pratt <anarchy@gentoo.org>
|
||||||
|
|
||||||
|
Taken from gentoo-musl project, with a few additional minor fixes.
|
||||||
|
---
|
||||||
|
lib/asan/asan_linux.cc | 4 +-
|
||||||
|
lib/interception/interception_linux.cc | 2 +-
|
||||||
|
lib/interception/interception_linux.h | 2 +-
|
||||||
|
lib/msan/msan_linux.cc | 2 +-
|
||||||
|
lib/sanitizer_common/sanitizer_allocator.cc | 2 +-
|
||||||
|
.../sanitizer_common_interceptors_ioctl.inc | 4 +-
|
||||||
|
.../sanitizer_common_syscalls.inc | 2 +-
|
||||||
|
lib/sanitizer_common/sanitizer_linux.cc | 8 +++-
|
||||||
|
.../sanitizer_linux_libcdep.cc | 10 ++---
|
||||||
|
lib/sanitizer_common/sanitizer_platform.h | 6 +++
|
||||||
|
.../sanitizer_platform_interceptors.h | 4 +-
|
||||||
|
.../sanitizer_platform_limits_posix.cc | 37 +++++++++++--------
|
||||||
|
lib/tsan/rtl/tsan_platform_linux.cc | 2 +-
|
||||||
|
13 files changed, 51 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
|
||||||
|
index 625f32d40..73cf77aca 100644
|
||||||
|
--- a/lib/asan/asan_linux.cc
|
||||||
|
+++ b/lib/asan/asan_linux.cc
|
||||||
|
@@ -46,7 +46,7 @@
|
||||||
|
#include <link.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
|
||||||
|
+#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
|
||||||
|
#include <ucontext.h>
|
||||||
|
extern "C" void* _DYNAMIC;
|
||||||
|
#elif SANITIZER_NETBSD
|
||||||
|
@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
|
||||||
|
UNIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
|
-#if SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_ANDROID || SANITIZER_NONGNU
|
||||||
|
// FIXME: should we do anything for Android?
|
||||||
|
void AsanCheckDynamicRTPrereqs() {}
|
||||||
|
void AsanCheckIncompatibleRT() {}
|
||||||
|
diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
|
||||||
|
index 26bfcd8f6..529b234f7 100644
|
||||||
|
--- a/lib/interception/interception_linux.cc
|
||||||
|
+++ b/lib/interception/interception_linux.cc
|
||||||
|
@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Android and Solaris do not have dlvsym
|
||||||
|
-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
|
||||||
|
+#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
|
||||||
|
void *GetFuncAddrVer(const char *func_name, const char *ver) {
|
||||||
|
return dlvsym(RTLD_NEXT, func_name, ver);
|
||||||
|
}
|
||||||
|
diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
|
||||||
|
index 942c25609..24a4d5080 100644
|
||||||
|
--- a/lib/interception/interception_linux.h
|
||||||
|
+++ b/lib/interception/interception_linux.h
|
||||||
|
@@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
|
||||||
|
(::__interception::uptr) & WRAP(func))
|
||||||
|
|
||||||
|
// Android, Solaris and OpenBSD do not have dlvsym
|
||||||
|
-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
|
||||||
|
+#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
|
||||||
|
#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
|
||||||
|
(::__interception::real_##func = (func##_f)( \
|
||||||
|
unsigned long)::__interception::GetFuncAddrVer(#func, symver))
|
||||||
|
diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
|
||||||
|
index 385a650c4..6e30a8ce9 100644
|
||||||
|
--- a/lib/msan/msan_linux.cc
|
||||||
|
+++ b/lib/msan/msan_linux.cc
|
||||||
|
@@ -13,7 +13,7 @@
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "sanitizer_common/sanitizer_platform.h"
|
||||||
|
-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
|
||||||
|
+#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD
|
||||||
|
|
||||||
|
#include "msan.h"
|
||||||
|
#include "msan_report.h"
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc
|
||||||
|
index 6bfd5e5ee..048f6154f 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_allocator.cc
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_allocator.cc
|
||||||
|
@@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator";
|
||||||
|
|
||||||
|
// ThreadSanitizer for Go uses libc malloc/free.
|
||||||
|
#if SANITIZER_GO || defined(SANITIZER_USE_MALLOC)
|
||||||
|
-# if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
extern "C" void *__libc_malloc(uptr size);
|
||||||
|
# if !SANITIZER_GO
|
||||||
|
extern "C" void *__libc_memalign(uptr alignment, uptr size);
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
|
||||||
|
index 2d633c173..b6eb23116 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
|
||||||
|
@@ -104,7 +104,7 @@ static void ioctl_table_fill() {
|
||||||
|
_(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_NONGNU
|
||||||
|
// Conflicting request ids.
|
||||||
|
// _(CDROMAUDIOBUFSIZ, NONE, 0);
|
||||||
|
// _(SNDCTL_TMR_CONTINUE, NONE, 0);
|
||||||
|
@@ -365,7 +365,7 @@ static void ioctl_table_fill() {
|
||||||
|
_(VT_WAITACTIVE, NONE, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
// _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
|
||||||
|
_(CYGETDEFTHRESH, WRITE, sizeof(int));
|
||||||
|
_(CYGETDEFTIMEOUT, WRITE, sizeof(int));
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
|
||||||
|
index 469c8eb7e..24f87867d 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
|
||||||
|
@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-#if !SANITIZER_ANDROID
|
||||||
|
+#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
|
||||||
|
void *old_rlim) {
|
||||||
|
if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc
|
||||||
|
index 96d6c1eff..9e2b7fb9d 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_linux.cc
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_linux.cc
|
||||||
|
@@ -541,13 +541,13 @@ const char *GetEnv(const char *name) {
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
-#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD
|
||||||
|
+#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
|
||||||
|
extern "C" {
|
||||||
|
SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \
|
||||||
|
+#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \
|
||||||
|
!SANITIZER_OPENBSD
|
||||||
|
static void ReadNullSepFileToArray(const char *path, char ***arr,
|
||||||
|
int arr_size) {
|
||||||
|
@@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) {
|
||||||
|
#elif SANITIZER_NETBSD
|
||||||
|
*argv = __ps_strings->ps_argvstr;
|
||||||
|
*envp = __ps_strings->ps_envstr;
|
||||||
|
+#elif SANITIZER_NONGNU
|
||||||
|
+ static const int kMaxArgv = 2000, kMaxEnvp = 2000;
|
||||||
|
+ ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv);
|
||||||
|
+ ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp);
|
||||||
|
#else // SANITIZER_FREEBSD
|
||||||
|
#if !SANITIZER_GO
|
||||||
|
if (&__libc_stack_end) {
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
|
||||||
|
index 4962ff832..438f94dbe 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
|
||||||
|
@@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \
|
||||||
|
- !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS
|
||||||
|
+ !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
|
||||||
|
static uptr g_tls_size;
|
||||||
|
|
||||||
|
#ifdef __i386__
|
||||||
|
@@ -261,7 +261,7 @@ void InitTlsSize() { }
|
||||||
|
#if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \
|
||||||
|
defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \
|
||||||
|
defined(__arm__)) && \
|
||||||
|
- SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+ SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
// sizeof(struct pthread) from glibc.
|
||||||
|
static atomic_uintptr_t thread_descriptor_size;
|
||||||
|
|
||||||
|
@@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
|
||||||
|
|
||||||
|
#if !SANITIZER_GO
|
||||||
|
static void GetTls(uptr *addr, uptr *size) {
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
# if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
|
||||||
|
*addr = ThreadSelf();
|
||||||
|
*size = GetTlsSize();
|
||||||
|
@@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) {
|
||||||
|
#elif SANITIZER_OPENBSD
|
||||||
|
*addr = 0;
|
||||||
|
*size = 0;
|
||||||
|
-#elif SANITIZER_ANDROID
|
||||||
|
+#elif SANITIZER_ANDROID || SANITIZER_NONGNU
|
||||||
|
*addr = 0;
|
||||||
|
*size = 0;
|
||||||
|
#elif SANITIZER_SOLARIS
|
||||||
|
@@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) {
|
||||||
|
#if !SANITIZER_GO
|
||||||
|
uptr GetTlsSize() {
|
||||||
|
#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \
|
||||||
|
- SANITIZER_OPENBSD || SANITIZER_SOLARIS
|
||||||
|
+ SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
|
||||||
|
uptr addr, size;
|
||||||
|
GetTls(&addr, &size);
|
||||||
|
return size;
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
|
||||||
|
index d81e25580..e10680ac8 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_platform.h
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_platform.h
|
||||||
|
@@ -208,6 +208,12 @@
|
||||||
|
# define SANITIZER_SOLARIS32 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#if defined(__linux__) && !defined(__GLIBC__)
|
||||||
|
+# define SANITIZER_NONGNU 1
|
||||||
|
+#else
|
||||||
|
+# define SANITIZER_NONGNU 0
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#if defined(__myriad2__)
|
||||||
|
# define SANITIZER_MYRIAD2 1
|
||||||
|
#else
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
|
||||||
|
index f95539a73..6c53b3415 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
|
||||||
|
@@ -39,7 +39,7 @@
|
||||||
|
# include "sanitizer_platform_limits_solaris.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
# define SI_LINUX_NOT_ANDROID 1
|
||||||
|
#else
|
||||||
|
# define SI_LINUX_NOT_ANDROID 0
|
||||||
|
@@ -322,7 +322,7 @@
|
||||||
|
#define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID)
|
||||||
|
#define SANITIZER_INTERCEPT_SHMCTL \
|
||||||
|
(SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \
|
||||||
|
- ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \
|
||||||
|
+ ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \
|
||||||
|
SANITIZER_WORDSIZE == 64)) // NOLINT
|
||||||
|
#define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
|
||||||
|
#define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX
|
||||||
|
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
|
||||||
|
index 54da635d7..2f6ff69c3 100644
|
||||||
|
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
|
||||||
|
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
|
||||||
|
@@ -14,6 +14,9 @@
|
||||||
|
|
||||||
|
#include "sanitizer_platform.h"
|
||||||
|
|
||||||
|
+// Workaround musl <--> linux conflicting definition of 'struct sysinfo'
|
||||||
|
+#define _LINUX_SYSINFO_H
|
||||||
|
+
|
||||||
|
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
|
||||||
|
// Tests in this file assume that off_t-dependent data structures match the
|
||||||
|
// libc ABI. For example, struct dirent here is what readdir() function (as
|
||||||
|
@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
|
||||||
|
|
||||||
|
#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
#include <glob.h>
|
||||||
|
-#include <obstack.h>
|
||||||
|
+# if !SANITIZER_NONGNU
|
||||||
|
+# include <obstack.h>
|
||||||
|
+# endif
|
||||||
|
#include <mqueue.h>
|
||||||
|
-#include <net/if_ppp.h>
|
||||||
|
-#include <netax25/ax25.h>
|
||||||
|
-#include <netipx/ipx.h>
|
||||||
|
-#include <netrom/netrom.h>
|
||||||
|
+#include <linux/if_ppp.h>
|
||||||
|
+#include <linux/ax25.h>
|
||||||
|
+#include <linux/ipx.h>
|
||||||
|
+#include <linux/netrom.h>
|
||||||
|
#if HAVE_RPC_XDR_H
|
||||||
|
# include <rpc/xdr.h>
|
||||||
|
#elif HAVE_TIRPC_RPC_XDR_H
|
||||||
|
@@ -251,7 +256,7 @@ namespace __sanitizer {
|
||||||
|
unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
|
||||||
|
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
// Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
|
||||||
|
// has been removed from glibc 2.28.
|
||||||
|
#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
|
||||||
|
@@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
|
||||||
|
unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
|
||||||
|
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
int glob_nomatch = GLOB_NOMATCH;
|
||||||
|
int glob_altdirfunc = GLOB_ALTDIRFUNC;
|
||||||
|
#endif
|
||||||
|
@@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
|
||||||
|
unsigned struct_termios_sz = sizeof(struct termios);
|
||||||
|
unsigned struct_winsize_sz = sizeof(struct winsize);
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_NONGNU
|
||||||
|
unsigned struct_arpreq_sz = sizeof(struct arpreq);
|
||||||
|
unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
|
||||||
|
unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
|
||||||
|
@@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
|
||||||
|
unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
|
||||||
|
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
|
||||||
|
unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
|
||||||
|
#if EV_VERSION > (0x010000)
|
||||||
|
@@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
|
||||||
|
unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
|
||||||
|
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
|
||||||
|
unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
|
||||||
|
unsigned IOCTL_CYGETMON = CYGETMON;
|
||||||
|
@@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
|
||||||
|
CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
|
||||||
|
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
|
||||||
|
|
||||||
|
-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
|
||||||
|
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
CHECK_TYPE_SIZE(glob_t);
|
||||||
|
CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
|
||||||
|
CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
|
||||||
|
@@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec);
|
||||||
|
CHECK_SIZE_AND_OFFSET(iovec, iov_base);
|
||||||
|
CHECK_SIZE_AND_OFFSET(iovec, iov_len);
|
||||||
|
|
||||||
|
+#if !SANITIZER_NONGNU
|
||||||
|
CHECK_TYPE_SIZE(msghdr);
|
||||||
|
CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
|
||||||
|
CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
|
||||||
|
@@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr);
|
||||||
|
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
|
||||||
|
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
|
||||||
|
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#ifndef __GLIBC_PREREQ
|
||||||
|
#define __GLIBC_PREREQ(x, y) 0
|
||||||
|
@@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
|
||||||
|
|
||||||
|
CHECK_TYPE_SIZE(ether_addr);
|
||||||
|
|
||||||
|
-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
|
||||||
|
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
CHECK_TYPE_SIZE(ipc_perm);
|
||||||
|
# if SANITIZER_FREEBSD
|
||||||
|
CHECK_SIZE_AND_OFFSET(ipc_perm, key);
|
||||||
|
@@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
|
||||||
|
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_NONGNU
|
||||||
|
COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
|
||||||
|
COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
|
||||||
|
CHECK_SIZE_AND_OFFSET(FILE, _flags);
|
||||||
|
CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
|
||||||
|
@@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
|
||||||
|
CHECK_SIZE_AND_OFFSET(FILE, _fileno);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
|
||||||
|
CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
|
||||||
|
CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
|
||||||
|
diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
|
||||||
|
index de989b780..51a97b554 100644
|
||||||
|
--- a/lib/tsan/rtl/tsan_platform_linux.cc
|
||||||
|
+++ b/lib/tsan/rtl/tsan_platform_linux.cc
|
||||||
|
@@ -294,7 +294,7 @@ void InitializePlatform() {
|
||||||
|
// This is required to properly "close" the fds, because we do not see internal
|
||||||
|
// closes within glibc. The code is a pure hack.
|
||||||
|
int ExtractResolvFDs(void *state, int *fds, int nfd) {
|
||||||
|
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
|
||||||
|
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
|
||||||
|
int cnt = 0;
|
||||||
|
struct __res_state *statp = (struct __res_state*)state;
|
||||||
|
for (int i = 0; i < MAXNS && cnt < nfd; i++) {
|
||||||
|
--
|
||||||
|
2.19.0
|
||||||
|
|
Loading…
Reference in New Issue