-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6c1354
commit d6d5c8a
Showing
53 changed files
with
2,524 additions
and
349 deletions.
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,137 @@ | ||
{ lib, stdenv, llvm_meta | ||
, monorepoSrc, runCommand | ||
, cmake, ninja, libxml2, libllvm, version, python3 | ||
, buildLlvmTools | ||
, fixDarwinDylibNames | ||
, enableManpages ? false | ||
}: | ||
|
||
let | ||
self = stdenv.mkDerivation (rec { | ||
pname = "clang"; | ||
inherit version; | ||
|
||
src = runCommand "${pname}-src-${version}" {} '' | ||
mkdir -p "$out" | ||
cp -r ${monorepoSrc}/cmake "$out" | ||
cp -r ${monorepoSrc}/${pname} "$out" | ||
cp -r ${monorepoSrc}/clang-tools-extra "$out" | ||
''; | ||
|
||
sourceRoot = "${src.name}/${pname}"; | ||
|
||
nativeBuildInputs = [ cmake ninja python3 ] | ||
++ lib.optional enableManpages python3.pkgs.sphinx | ||
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; | ||
|
||
buildInputs = [ libxml2 libllvm ]; | ||
|
||
cmakeFlags = [ | ||
"-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" | ||
"-DCLANGD_BUILD_XPC=OFF" | ||
"-DLLVM_ENABLE_RTTI=ON" | ||
"-DLLVM_INCLUDE_TESTS=OFF" | ||
] ++ lib.optionals enableManpages [ | ||
"-DCLANG_INCLUDE_DOCS=ON" | ||
"-DLLVM_ENABLE_SPHINX=ON" | ||
"-DSPHINX_OUTPUT_MAN=ON" | ||
"-DSPHINX_OUTPUT_HTML=OFF" | ||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF" | ||
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ | ||
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" | ||
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" | ||
# Added in LLVM15: | ||
# `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb | ||
# `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7 | ||
"-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen" | ||
"-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen" | ||
]; | ||
|
||
patches = [ | ||
./purity.patch | ||
# https://reviews.llvm.org/D51899 | ||
./gnu-install-dirs.patch | ||
../../common/clang/add-nostdlibinc-flag.patch | ||
# FIMXE: do we need this patch? | ||
# (substituteAll { | ||
# src = ../../clang-11-12-LLVMgold-path.patch; | ||
# libllvmLibdir = "${libllvm.lib}/lib"; | ||
# }) | ||
]; | ||
|
||
postPatch = '' | ||
(cd tools && ln -s ../../clang-tools-extra extra) | ||
'' + lib.optionalString stdenv.hostPlatform.isMusl '' | ||
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp | ||
''; | ||
|
||
outputs = [ "out" "lib" "dev" "python" ]; | ||
|
||
postInstall = '' | ||
ln -sv $out/bin/clang $out/bin/cpp | ||
mkdir -p $lib/lib/clang | ||
mv $lib/lib/17 $lib/lib/clang/17 | ||
# Move libclang to 'lib' output | ||
moveToOutput "lib/libclang.*" "$lib" | ||
moveToOutput "lib/libclang-cpp.*" "$lib" | ||
substituteInPlace $dev/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 | ||
patchShebangs $python/bin | ||
mkdir -p $dev/bin | ||
cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin | ||
''; | ||
|
||
passthru = { | ||
inherit libllvm; | ||
isClang = true; | ||
hardeningUnsupportedFlags = [ "fortify3" ]; | ||
}; | ||
|
||
meta = llvm_meta // { | ||
homepage = "https://clang.llvm.org/"; | ||
description = "A C language family frontend for LLVM"; | ||
longDescription = '' | ||
The Clang project provides a language front-end and tooling | ||
infrastructure for languages in the C language family (C, C++, Objective | ||
C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. | ||
It aims to deliver amazingly fast compiles, extremely useful error and | ||
warning messages and to provide a platform for building great source | ||
level tools. The Clang Static Analyzer and clang-tidy are tools that | ||
automatically find bugs in your code, and are great examples of the sort | ||
of tools that can be built using the Clang frontend as a library to | ||
parse C/C++ code. | ||
''; | ||
mainProgram = "clang"; | ||
}; | ||
} // lib.optionalAttrs enableManpages { | ||
pname = "clang-manpages"; | ||
|
||
ninjaFlags = [ "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 = llvm_meta // { | ||
description = "man page for Clang ${version}"; | ||
}; | ||
}); | ||
in self |
98 changes: 98 additions & 0 deletions
98
pkgs/development/compilers/llvm/17/clang/gnu-install-dirs.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,98 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index f7936d72e088..a362fa49b534 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -31,7 +31,21 @@ if(CLANG_BUILT_STANDALONE) | ||
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") | ||
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") | ||
|
||
- # Turn into CACHE PATHs for overwritting | ||
+ # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets | ||
+ # LLVM_CONFIG. | ||
+ if (NOT LLVM_CONFIG_FOUND) | ||
+ # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config | ||
+ # path is removed. | ||
+ set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) | ||
+ set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") | ||
+ # N.B. this is just a default value, the CACHE PATHs below can be overriden. | ||
+ set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") | ||
+ set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") | ||
+ set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") | ||
+ else() | ||
+ set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") | ||
+ endif() | ||
+ | ||
set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") | ||
set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree") | ||
set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") | ||
diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake | ||
index 75b0080f6715..c895b884cd27 100644 | ||
--- a/cmake/modules/AddClang.cmake | ||
+++ b/cmake/modules/AddClang.cmake | ||
@@ -119,8 +119,8 @@ macro(add_clang_library name) | ||
install(TARGETS ${lib} | ||
COMPONENT ${lib} | ||
${export_to_clangtargets} | ||
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} | ||
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} | ||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" | ||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") | ||
|
||
if (NOT LLVM_ENABLE_IDE) | ||
diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt | ||
index f2b0c5cddcbb..52f37fc368ce 100644 | ||
--- a/lib/Headers/CMakeLists.txt | ||
+++ b/lib/Headers/CMakeLists.txt | ||
@@ -473,6 +473,7 @@ add_header_target("windows-resource-headers" ${windows_only_files}) | ||
add_header_target("utility-resource-headers" ${utility_files}) | ||
|
||
get_clang_resource_dir(header_install_dir SUBDIR include) | ||
+set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${CLANG_VERSION_MAJOR}/include) | ||
|
||
############################################################# | ||
# Install rules for the catch-all clang-resource-headers target | ||
diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt | ||
index 4f23065a2472..6a0f55991e24 100644 | ||
--- a/tools/libclang/CMakeLists.txt | ||
+++ b/tools/libclang/CMakeLists.txt | ||
@@ -234,7 +234,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) | ||
COMPONENT | ||
libclang-python-bindings | ||
DESTINATION | ||
- "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") | ||
+ "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") | ||
endforeach() | ||
if(NOT LLVM_ENABLE_IDE) | ||
add_custom_target(libclang-python-bindings) | ||
diff --git a/tools/scan-build-py/CMakeLists.txt b/tools/scan-build-py/CMakeLists.txt | ||
index 3aca22c0b0a8..3115353e3fe3 100644 | ||
--- a/tools/scan-build-py/CMakeLists.txt | ||
+++ b/tools/scan-build-py/CMakeLists.txt | ||
@@ -88,7 +88,7 @@ foreach(lib ${LibScanbuild}) | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib}) | ||
list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib}) | ||
install(FILES lib/libscanbuild/${lib} | ||
- DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild | ||
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild" | ||
COMPONENT scan-build-py) | ||
endforeach() | ||
|
||
@@ -106,7 +106,7 @@ foreach(resource ${LibScanbuildResources}) | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource}) | ||
list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource}) | ||
install(FILES lib/libscanbuild/resources/${resource} | ||
- DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild/resources | ||
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild/resources" | ||
COMPONENT scan-build-py) | ||
endforeach() | ||
|
||
@@ -122,7 +122,7 @@ foreach(lib ${LibEar}) | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib}) | ||
list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib}) | ||
install(FILES lib/libear/${lib} | ||
- DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libear | ||
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/libear" | ||
COMPONENT scan-build-py) | ||
endforeach() | ||
|
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,29 @@ | ||
From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 | ||
From: Will Dietz <[email protected]> | ||
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,13 +487,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, | ||
} else { | ||
if (Args.hasArg(options::OPT_rdynamic)) | ||
CmdArgs.push_back("-export-dynamic"); | ||
|
||
- if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE && | ||
- !Args.hasArg(options::OPT_r)) { | ||
- CmdArgs.push_back("-dynamic-linker"); | ||
- CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) + | ||
- ToolChain.getDynamicLinker(Args))); | ||
- } | ||
} | ||
|
||
CmdArgs.push_back("-o"); | ||
-- | ||
2.11.0 |
21 changes: 21 additions & 0 deletions
21
pkgs/development/compilers/llvm/17/compiler-rt/X86-support-extension.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,21 @@ | ||
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 | ||
@@ -348,4 +348,8 @@ if (NOT MSVC) | ||
|
||
+ set(i486_SOURCES ${i386_SOURCES}) | ||
+ set(i586_SOURCES ${i386_SOURCES}) | ||
+ set(i686_SOURCES ${i386_SOURCES}) | ||
+ | ||
if (WIN32) | ||
set(i386_SOURCES | ||
${i386_SOURCES} | ||
@@ -723,6 +723,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)$") |
71 changes: 71 additions & 0 deletions
71
pkgs/development/compilers/llvm/17/compiler-rt/darwin-targetconditionals.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,71 @@ | ||
diff --git a/lib/sanitizer_common/sanitizer_mac.cpp b/lib/sanitizer_common/sanitizer_mac.cpp | ||
--- a/lib/sanitizer_common/sanitizer_mac.cpp | ||
+++ b/lib/sanitizer_common/sanitizer_mac.cpp | ||
@@ -613,9 +613,15 @@ HandleSignalMode GetHandleSignalMode(int signum) { | ||
// Offset example: | ||
// XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4 | ||
constexpr u16 GetOSMajorKernelOffset() { | ||
- if (TARGET_OS_OSX) return 4; | ||
- if (TARGET_OS_IOS || TARGET_OS_TV) return 6; | ||
- if (TARGET_OS_WATCH) return 13; | ||
+#if TARGET_OS_OSX | ||
+ return 4; | ||
+#endif | ||
+#if TARGET_OS_IOS || TARGET_OS_TV | ||
+ return 6; | ||
+#endif | ||
+#if TARGET_OS_WATCH | ||
+ return 13; | ||
+#endif | ||
} | ||
|
||
using VersStr = char[64]; | ||
@@ -627,13 +633,13 @@ static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) { | ||
u16 os_major = kernel_major - offset; | ||
|
||
const char *format = "%d.0"; | ||
- if (TARGET_OS_OSX) { | ||
- if (os_major >= 16) { // macOS 11+ | ||
- os_major -= 5; | ||
- } else { // macOS 10.15 and below | ||
- format = "10.%d"; | ||
- } | ||
+#if TARGET_OS_OSX | ||
+ if (os_major >= 16) { // macOS 11+ | ||
+ os_major -= 5; | ||
+ } else { // macOS 10.15 and below | ||
+ format = "10.%d"; | ||
} | ||
+#endif | ||
return internal_snprintf(vers, sizeof(VersStr), format, os_major); | ||
} | ||
|
||
@@ -681,15 +687,14 @@ void ParseVersion(const char *vers, u16 *major, u16 *minor) { | ||
// Aligned versions example: | ||
// macOS 10.15 -- iOS 13 -- tvOS 13 -- watchOS 6 | ||
static void MapToMacos(u16 *major, u16 *minor) { | ||
- if (TARGET_OS_OSX) | ||
- return; | ||
- | ||
- if (TARGET_OS_IOS || TARGET_OS_TV) | ||
+#if !TARGET_OS_OSX | ||
+#if TARGET_OS_IOS || TARGET_OS_TV | ||
*major += 2; | ||
- else if (TARGET_OS_WATCH) | ||
+#elif TARGET_OS_WATCH | ||
*major += 9; | ||
- else | ||
+#else | ||
UNREACHABLE("unsupported platform"); | ||
+#endif | ||
|
||
if (*major >= 16) { // macOS 11+ | ||
*major -= 5; | ||
@@ -697,6 +702,7 @@ static void MapToMacos(u16 *major, u16 *minor) { | ||
*minor = *major; | ||
*major = 10; | ||
} | ||
+#endif | ||
} | ||
|
||
static MacosVersion GetMacosAlignedVersionInternal() { |
Oops, something went wrong.