forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#56645 from matthewbauer/llvm-8
llvm8: init
- Loading branch information
Showing
18 changed files
with
1,911 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ runCommand, stdenv, llvm, lld, version }: | ||
|
||
let | ||
prefix = | ||
if stdenv.hostPlatform != stdenv.targetPlatform | ||
then "${stdenv.targetPlatform.config}-" | ||
else ""; | ||
in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' | ||
mkdir -p $out/bin | ||
for prog in ${lld}/bin/*; do | ||
ln -s $prog $out/bin/${prefix}$(basename $prog) | ||
done | ||
for prog in ${llvm}/bin/*; do | ||
ln -s $prog $out/bin/${prefix}$(echo $(basename $prog) | sed -e "s|llvm-||") | ||
ln -sf $prog $out/bin/${prefix}$(basename $prog) | ||
done | ||
rm -f $out/bin/${prefix}cat | ||
ln -s ${lld}/bin/lld $out/bin/${prefix}ld | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python | ||
, fixDarwinDylibNames | ||
, enableManpages ? false | ||
, enablePolly ? false # TODO: get this info from llvm (passthru?) | ||
}: | ||
|
||
let | ||
self = stdenv.mkDerivation ({ | ||
name = "clang-${version}"; | ||
|
||
unpackPhase = '' | ||
unpackFile ${fetch "cfe" "0z5si83w0i3l445c7624204mxsv82naps96icnv7v20s6njbsbsi"} | ||
mv cfe-${version}* clang | ||
sourceRoot=$PWD/clang | ||
unpackFile ${clang-tools-extra_src} | ||
mv clang-tools-extra-* $sourceRoot/tools/extra | ||
''; | ||
|
||
nativeBuildInputs = [ cmake python ] | ||
++ stdenv.lib.optional enableManpages python.pkgs.sphinx; | ||
|
||
buildInputs = [ libxml2 llvm ] | ||
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; | ||
|
||
cmakeFlags = [ | ||
"-DCMAKE_CXX_FLAGS=-std=c++11" | ||
] ++ stdenv.lib.optionals enableManpages [ | ||
"-DCLANG_INCLUDE_DOCS=ON" | ||
"-DLLVM_ENABLE_SPHINX=ON" | ||
"-DSPHINX_OUTPUT_MAN=ON" | ||
"-DSPHINX_OUTPUT_HTML=OFF" | ||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF" | ||
] ++ stdenv.lib.optionals enablePolly [ | ||
"-DWITH_POLLY=ON" | ||
"-DLINK_POLLY_INTO_TOOLS=ON" | ||
]; | ||
|
||
patches = [ ./purity.patch ]; | ||
|
||
postPatch = '' | ||
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ | ||
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ | ||
lib/Driver/ToolChains/*.cpp | ||
# Patch for standalone doc building | ||
sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt | ||
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' | ||
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp | ||
'' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
substituteInPlace tools/extra/clangd/CMakeLists.txt \ | ||
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE | ||
''; | ||
|
||
outputs = [ "out" "lib" "python" ]; | ||
|
||
# Clang expects to find LLVMgold in its own prefix | ||
postInstall = '' | ||
if [ -e ${llvm}/lib/LLVMgold.so ]; then | ||
ln -sv ${llvm}/lib/LLVMgold.so $out/lib | ||
fi | ||
ln -sv $out/bin/clang $out/bin/cpp | ||
# Move libclang to 'lib' output | ||
moveToOutput "lib/libclang.*" "$lib" | ||
substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ | ||
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." | ||
mkdir -p $python/bin $python/share/clang/ | ||
mv $out/bin/{git-clang-format,scan-view} $python/bin | ||
if [ -e $out/bin/set-xcode-analyzer ]; then | ||
mv $out/bin/set-xcode-analyzer $python/bin | ||
fi | ||
mv $out/share/clang/*.py $python/share/clang | ||
rm $out/bin/c-index-test | ||
''; | ||
|
||
enableParallelBuilding = true; | ||
|
||
passthru = { | ||
isClang = true; | ||
inherit llvm; | ||
} // stdenv.lib.optionalAttrs (stdenv.targetPlatform.isLinux || (stdenv.cc.isGNU && stdenv.cc.cc ? gcc)) { | ||
gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; | ||
}; | ||
|
||
meta = { | ||
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; | ||
homepage = http://llvm.org/; | ||
license = stdenv.lib.licenses.ncsa; | ||
platforms = stdenv.lib.platforms.all; | ||
}; | ||
} // stdenv.lib.optionalAttrs enableManpages { | ||
name = "clang-manpages-${version}"; | ||
|
||
buildPhase = '' | ||
make docs-clang-man | ||
''; | ||
|
||
installPhase = '' | ||
mkdir -p $out/share/man/man1 | ||
# Manually install clang manpage | ||
cp docs/man/*.1 $out/share/man/man1/ | ||
''; | ||
|
||
outputs = [ "out" ]; | ||
|
||
doCheck = false; | ||
|
||
meta.description = "man page for Clang ${version}"; | ||
}); | ||
in self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 | ||
From: Will Dietz <w@wdtz.org> | ||
Date: Thu, 18 May 2017 11:56:12 -0500 | ||
Subject: [PATCH] "purity" patch for 5.0 | ||
|
||
--- | ||
lib/Driver/ToolChains/Gnu.cpp | 7 ------- | ||
1 file changed, 7 deletions(-) | ||
|
||
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp | ||
index fe3c0191bb..c6a482bece 100644 | ||
--- a/lib/Driver/ToolChains/Gnu.cpp | ||
+++ b/lib/Driver/ToolChains/Gnu.cpp | ||
@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, | ||
if (!Args.hasArg(options::OPT_static)) { | ||
if (Args.hasArg(options::OPT_rdynamic)) | ||
CmdArgs.push_back("-export-dynamic"); | ||
- | ||
- if (!Args.hasArg(options::OPT_shared)) { | ||
- const std::string Loader = | ||
- D.DyldPrefix + ToolChain.getDynamicLinker(Args); | ||
- CmdArgs.push_back("-dynamic-linker"); | ||
- CmdArgs.push_back(Args.MakeArgString(Loader)); | ||
- } | ||
} | ||
|
||
CmdArgs.push_back("-o"); | ||
-- | ||
2.11.0 | ||
|
74 changes: 74 additions & 0 deletions
74
pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
commit f00c7bccf7955b7dfbb4859fd9019e9eb3349f2d | ||
Author: Tobias Mayer <tobim@fastmail.fm> | ||
Date: Wed Feb 13 12:44:17 2019 +0100 | ||
|
||
Provide clock_gettime for xray on macos < 10.12 | ||
|
||
diff --git a/lib/xray/xray_basic_logging.cc b/lib/xray/xray_basic_logging.cc | ||
index a46c151af..38aea6932 100644 | ||
--- a/lib/xray/xray_basic_logging.cc | ||
+++ b/lib/xray/xray_basic_logging.cc | ||
@@ -36,6 +36,29 @@ | ||
#include "xray_tsc.h" | ||
#include "xray_utils.h" | ||
|
||
+#if __MACH__ | ||
+#include <mach/clock.h> | ||
+#include <mach/mach.h> | ||
+enum clockid_t { | ||
+ CLOCK_MONOTONIC = REALTIME_CLOCK, | ||
+ CLOCK_REALTIME = REALTIME_CLOCK | ||
+}; | ||
+ | ||
+int clock_gettime(clockid_t clock_id, struct timespec *ts) { | ||
+ if (ts != NULL) { | ||
+ clock_serv_t cclock; | ||
+ mach_timespec_t mts; | ||
+ host_get_clock_service(mach_host_self(), clock_id, &cclock); | ||
+ clock_get_time(cclock, &mts); | ||
+ mach_port_deallocate(mach_task_self(), cclock); | ||
+ ts->tv_sec = mts.tv_sec; | ||
+ ts->tv_nsec = mts.tv_nsec; | ||
+ return 0; | ||
+ } | ||
+ return -1; | ||
+} | ||
+#endif | ||
+ | ||
namespace __xray { | ||
|
||
SpinMutex LogMutex; | ||
diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc | ||
index 4b308b27f..1d044c8fd 100644 | ||
--- a/lib/xray/xray_fdr_logging.cc | ||
+++ b/lib/xray/xray_fdr_logging.cc | ||
@@ -38,6 +38,29 @@ | ||
#include "xray_tsc.h" | ||
#include "xray_utils.h" | ||
|
||
+#if __MACH__ | ||
+#include <mach/clock.h> | ||
+#include <mach/mach.h> | ||
+enum clockid_t { | ||
+ CLOCK_MONOTONIC = REALTIME_CLOCK, | ||
+ CLOCK_REALTIME = REALTIME_CLOCK | ||
+}; | ||
+ | ||
+int clock_gettime(clockid_t clock_id, struct timespec *ts) { | ||
+ if (ts != NULL) { | ||
+ clock_serv_t cclock; | ||
+ mach_timespec_t mts; | ||
+ host_get_clock_service(mach_host_self(), clock_id, &cclock); | ||
+ clock_get_time(cclock, &mts); | ||
+ mach_port_deallocate(mach_task_self(), cclock); | ||
+ ts->tv_sec = mts.tv_sec; | ||
+ ts->tv_nsec = mts.tv_nsec; | ||
+ return 0; | ||
+ } | ||
+ return -1; | ||
+} | ||
+#endif | ||
+ | ||
namespace __xray { | ||
|
||
atomic_sint32_t LoggingStatus = {XRayLogInitStatus::XRAY_LOG_UNINITIALIZED}; |
33 changes: 33 additions & 0 deletions
33
pkgs/development/compilers/llvm/8/compiler-rt-codesign.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }: | ||
stdenv.mkDerivation rec { | ||
name = "compiler-rt-${version}"; | ||
inherit version; | ||
src = fetch "compiler-rt" "1rxa1rcn7r3yfn9cj0sx5gd90kslbd13q080rdyqb6jr9a9i1avb"; | ||
|
||
nativeBuildInputs = [ cmake python llvm ]; | ||
buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi; | ||
|
||
cmakeFlags = [ | ||
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" | ||
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" | ||
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" | ||
] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ | ||
"-DCMAKE_C_FLAGS=-nodefaultlibs" | ||
"-DCMAKE_CXX_COMPILER_WORKS=ON" | ||
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF" | ||
"-DCOMPILER_RT_BUILD_XRAY=OFF" | ||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" | ||
"-DCOMPILER_RT_BUILD_PROFILE=OFF" | ||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON" | ||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" | ||
]; | ||
|
||
outputs = [ "out" "dev" ]; | ||
|
||
patches = [ | ||
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory | ||
] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch | ||
++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch | ||
++ stdenv.lib.optional stdenv.hostPlatform.isDarwin ./compiler-rt-clock_gettime.patch; | ||
|
||
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks | ||
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra | ||
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd | ||
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by | ||
# a flag and turn the flag off during the stdenv build. | ||
postPatch = stdenv.lib.optionalString stdenv.isDarwin '' | ||
substituteInPlace cmake/config-ix.cmake \ | ||
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' | ||
'' + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' | ||
substituteInPlace lib/builtins/int_util.c \ | ||
--replace "#include <stdlib.h>" "" | ||
substituteInPlace lib/builtins/clear_cache.c \ | ||
--replace "#include <assert.h>" "" | ||
substituteInPlace lib/builtins/cpu_model.c \ | ||
--replace "#include <assert.h>" "" | ||
''; | ||
|
||
# Hack around weird upsream RPATH bug | ||
postInstall = stdenv.lib.optionalString stdenv.isDarwin '' | ||
ln -s "$out/lib"/*/* "$out/lib" | ||
'' + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' | ||
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o | ||
ln -s $out/lib/*/cclang_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; | ||
} |
Oops, something went wrong.