28 changed files with 155 additions and 2179 deletions
@ -1,29 +0,0 @@
|
||||
{ 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 |
||||
'' |
@ -1,116 +0,0 @@
|
||||
{ lib, 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 ] |
||||
++ lib.optional enableManpages python3.pkgs.sphinx |
||||
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; |
||||
|
||||
buildInputs = [ libxml2 llvm ]; |
||||
|
||||
cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++14" "-DCLANGD_BUILD_XPC=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" |
||||
]; |
||||
|
||||
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 |
||||
'' + lib.optionalString |
||||
(stdenv.hostPlatform.isMusl || stdenv.targetPlatform.isGenode) '' |
||||
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp |
||||
'' + 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 = lib.licenses.ncsa; |
||||
platforms = lib.platforms.all; |
||||
}; |
||||
} // 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; |
||||
|
||||
requiredSystemFeatures = [ "big-parallel" ]; |
||||
meta.description = "man page for Clang ${version}"; |
||||
}); |
||||
in self |
@ -1,28 +0,0 @@
|
||||
From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
|
||||
From: Will Dietz <w@wdtz.org>
|
||||
Date: Thu, 18 May 2017 11:56:12 -0500
|
||||
Subject: [PATCH] "purity" patch for 5.0
|
||||
|
||||
---
|
||||
lib/Driver/ToolChains/Gnu.cpp | 7 -------
|
||||
1 file changed, 7 deletions(-)
|
||||
|
||||
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
|
||||
index fe3c0191bb..c6a482bece 100644
|
||||
--- a/lib/Driver/ToolChains/Gnu.cpp
|
||||
+++ b/lib/Driver/ToolChains/Gnu.cpp
|
||||
@@ -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
|
@ -1,23 +0,0 @@
|
||||
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)$")
|
@ -1,32 +0,0 @@
|
||||
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)
|
@ -1,33 +0,0 @@
|
||||
From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001
|
||||
From: Will Dietz <w@wdtz.org>
|
||||
Date: Tue, 19 Sep 2017 13:13:06 -0500
|
||||
Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that
|
||||
needs it
|
||||
|
||||
---
|
||||
cmake/Modules/AddCompilerRT.cmake | 8 ------
|
||||
test/asan/CMakeLists.txt | 52 ---------------------------------------
|
||||
test/tsan/CMakeLists.txt | 47 -----------------------------------
|
||||
3 files changed, 107 deletions(-)
|
||||
|
||||
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
|
||||
index bc5fb9ff7..b64eb4246 100644
|
||||
--- a/cmake/Modules/AddCompilerRT.cmake
|
||||
+++ b/cmake/Modules/AddCompilerRT.cmake
|
||||
@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type)
|
||||
set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
|
||||
set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
|
||||
endif()
|
||||
- if(APPLE)
|
||||
- # Ad-hoc sign the dylibs
|
||||
- add_custom_command(TARGET ${libname}
|
||||
- POST_BUILD
|
||||
- COMMAND codesign --sign - $<TARGET_FILE:${libname}>
|
||||
- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
|
||||
- )
|
||||
- endif()
|
||||
endif()
|
||||
install(TARGETS ${libname}
|
||||
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
|
||||
2.14.1
|
||||
|
@ -1,88 +0,0 @@
|
||||
{ lib, 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 = 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}" |
||||
] ++ lib.optionals (stdenv.isDarwin) |
||||
[ "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON" ] |
||||
++ 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" |
||||
] ++ 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) |
||||
}" |
||||
] ++ 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" |
||||
] ++ 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 |
||||
] # ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch |
||||
++ 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 = lib.optionalString (!stdenv.isDarwin) '' |
||||
substituteInPlace cmake/builtin-config-ix.cmake \ |
||||
--replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' |
||||
'' + 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)' |
||||
'' + 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 = lib.optionalString |
||||
(stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' |
||||
ln -s "$out/lib"/*/* "$out/lib" |
||||
'' + 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; |
||||
} |
@ -1,595 +0,0 @@
|
||||
Get crtbegin and crtend without compiler GCC! PR is at https://reviews.llvm.org/D28791
|
||||
|
||||
Index: compiler-rt/CMakeLists.txt
|
||||
===================================================================
|
||||
--- compiler-rt/CMakeLists.txt
|
||||
+++ compiler-rt/CMakeLists.txt
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
|
||||
mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
|
||||
+option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_CRT)
|
||||
option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
|
||||
mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
|
||||
option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
|
||||
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
|
||||
===================================================================
|
||||
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
|
||||
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
|
||||
@@ -132,7 +132,7 @@
|
||||
# Adds static or shared runtime for a list of architectures and operating
|
||||
# systems and puts it in the proper directory in the build and install trees.
|
||||
# add_compiler_rt_runtime(<name>
|
||||
-# {STATIC|SHARED}
|
||||
+# {OBJECT|STATIC|SHARED}
|
||||
# ARCHS <architectures>
|
||||
# OS <os list>
|
||||
# SOURCES <source files>
|
||||
@@ -144,8 +144,8 @@
|
||||
# PARENT_TARGET <convenience parent target>
|
||||
# ADDITIONAL_HEADERS <header files>)
|
||||
function(add_compiler_rt_runtime name type)
|
||||
- if(NOT type MATCHES "^(STATIC|SHARED)$")
|
||||
- message(FATAL_ERROR "type argument must be STATIC or SHARED")
|
||||
+ if(NOT type MATCHES "^(OBJECT|STATIC|SHARED)$")
|
||||
+ message(FATAL_ERROR "type argument must be OBJECT, STATIC or SHARED")
|
||||
return()
|
||||
endif()
|
||||
cmake_parse_arguments(LIB
|
||||
@@ -204,7 +204,10 @@
|
||||
message(FATAL_ERROR "Architecture ${arch} can't be targeted")
|
||||
return()
|
||||
endif()
|
||||
- if(type STREQUAL "STATIC")
|
||||
+ if(type STREQUAL "OBJECT")
|
||||
+ set(libname "${name}-${arch}")
|
||||
+ set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX})
|
||||
+ elseif(type STREQUAL "STATIC")
|
||||
set(libname "${name}-${arch}")
|
||||
set_output_name(output_name_${libname} ${name} ${arch})
|
||||
else()
|
||||
@@ -270,12 +273,34 @@
|
||||
set(COMPONENT_OPTION COMPONENT ${libname})
|
||||
endif()
|
||||
|
||||
- add_library(${libname} ${type} ${sources_${libname}})
|
||||
- set_target_compile_flags(${libname} ${extra_cflags_${libname}})
|
||||
- set_target_link_flags(${libname} ${extra_link_flags_${libname}})
|
||||
- set_property(TARGET ${libname} APPEND PROPERTY
|
||||
- COMPILE_DEFINITIONS ${LIB_DEFS})
|
||||
- set_target_output_directories(${libname} ${output_dir_${libname}})
|
||||
+ if(type STREQUAL "OBJECT")
|
||||
+ string(TOUPPER ${CMAKE_BUILD_TYPE} config)
|
||||
+ get_property(cflags SOURCE ${sources_${libname}} PROPERTY COMPILE_FLAGS)
|
||||
+ separate_arguments(cflags)
|
||||
+ add_custom_command(
|
||||
+ OUTPUT ${output_dir_${libname}}/${libname}.o
|
||||
+ COMMAND ${CMAKE_C_COMPILER} ${sources_${libname}} ${cflags} ${extra_cflags_${libname}} -c -o ${output_dir_${libname}}/${libname}.o
|
||||
+ DEPENDS ${sources_${libname}}
|
||||
+ COMMENT "Building C object ${libname}.o")
|
||||
+ add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${libname}.o)
|
||||
+ install(FILES ${output_dir_${libname}}/${libname}.o
|
||||
+ DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION})
|
||||
+ else()
|
||||
+ add_library(${libname} ${type} ${sources_${libname}})
|
||||
+ set_target_compile_flags(${libname} ${extra_cflags_${libname}})
|
||||
+ set_target_link_flags(${libname} ${extra_link_flags_${libname}})
|
||||
+ set_property(TARGET ${libname} APPEND PROPERTY
|
||||
+ COMPILE_DEFINITIONS ${LIB_DEFS})
|
||||
+ set_target_output_directories(${libname} ${output_dir_${libname}})
|
||||
+ install(TARGETS ${libname}
|
||||
+ ARCHIVE DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION}
|
||||
+ LIBRARY DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION}
|
||||
+ RUNTIME DESTINATION ${install_dir_${libname}}
|
||||
+ ${COMPONENT_OPTION})
|
||||
+ endif()
|
||||
set_target_properties(${libname} PROPERTIES
|
||||
OUTPUT_NAME ${output_name_${libname}})
|
||||
set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime")
|
||||
@@ -299,13 +324,6 @@
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
- install(TARGETS ${libname}
|
||||
- ARCHIVE DESTINATION ${install_dir_${libname}}
|
||||
- ${COMPONENT_OPTION}
|
||||
- LIBRARY DESTINATION ${install_dir_${libname}}
|
||||
- ${COMPONENT_OPTION}
|
||||
- RUNTIME DESTINATION ${install_dir_${libname}}
|
||||
- ${COMPONENT_OPTION})
|
||||
|
||||
# We only want to generate per-library install targets if you aren't using
|
||||
# an IDE because the extra targets get cluttered in IDEs.
|
||||
Index: compiler-rt/cmake/config-ix.cmake
|
||||
===================================================================
|
||||
--- compiler-rt/cmake/config-ix.cmake
|
||||
+++ compiler-rt/cmake/config-ix.cmake
|
||||
@@ -227,6 +227,7 @@
|
||||
${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X})
|
||||
set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
|
||||
${MIPS32} ${MIPS64} ${PPC64} ${S390X})
|
||||
+set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64})
|
||||
set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
|
||||
set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64})
|
||||
|
||||
@@ -474,6 +475,7 @@
|
||||
SANITIZER_COMMON_SUPPORTED_ARCH)
|
||||
|
||||
else()
|
||||
+ filter_available_targets(CRT_SUPPORTED_ARCH ${ALL_CRT_SUPPORTED_ARCH})
|
||||
# Architectures supported by compiler-rt libraries.
|
||||
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
|
||||
${ALL_SANITIZER_COMMON_SUPPORTED_ARCH})
|
||||
@@ -563,6 +565,12 @@
|
||||
|
||||
# TODO: Add builtins support.
|
||||
|
||||
+if (CRT_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux")
|
||||
+ set(COMPILER_RT_HAS_CRT TRUE)
|
||||
+else()
|
||||
+ set(COMPILER_RT_HAS_CRT FALSE)
|
||||
+endif()
|
||||
+
|
||||
if (COMPILER_RT_HAS_SANITIZER_COMMON AND DFSAN_SUPPORTED_ARCH AND
|
||||
OS_NAME MATCHES "Linux")
|
||||
set(COMPILER_RT_HAS_DFSAN TRUE)
|
||||
Index: compiler-rt/lib/CMakeLists.txt
|
||||
===================================================================
|
||||
--- compiler-rt/lib/CMakeLists.txt
|
||||
+++ compiler-rt/lib/CMakeLists.txt
|
||||
@@ -17,6 +17,10 @@
|
||||
add_subdirectory(builtins)
|
||||
endif()
|
||||
|
||||
+if(COMPILER_RT_BUILD_CRT)
|
||||
+ add_subdirectory(crt)
|
||||
+endif()
|
||||
+
|
||||
function(compiler_rt_build_runtime runtime)
|
||||
string(TOUPPER ${runtime} runtime_uppercase)
|
||||
if(COMPILER_RT_HAS_${runtime_uppercase})
|
||||
Index: compiler-rt/lib/crt/CMakeLists.txt
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ compiler-rt/lib/crt/CMakeLists.txt
|
||||
@@ -0,0 +1,102 @@
|
||||
+add_compiler_rt_component(crt)
|
||||
+
|
||||
+function(check_cxx_section_exists section output)
|
||||
+ cmake_parse_arguments(ARG "" "" "SOURCE;FLAGS" ${ARGN})
|
||||
+ if(NOT ARG_SOURCE)
|
||||
+ set(ARG_SOURCE "int main() { return 0; }\n")
|
||||
+ endif()
|
||||
+
|
||||
+ string(RANDOM TARGET_NAME)
|
||||
+ set(TARGET_NAME "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cmTC_${TARGET_NAME}.dir")
|
||||
+ file(MAKE_DIRECTORY ${TARGET_NAME})
|
||||
+
|
||||
+ file(WRITE "${TARGET_NAME}/CheckSectionExists.c" "${ARG_SOURCE}\n")
|
||||
+
|
||||
+ string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions
|
||||
+ ${CMAKE_C_COMPILE_OBJECT})
|
||||
+
|
||||
+ set(try_compile_flags "${ARG_FLAGS}")
|
||||
+ if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET)
|
||||
+ list(APPEND try_compile_flags "-target ${CMAKE_C_COMPILER_TARGET}")
|
||||
+ endif()
|
||||
+
|
||||
+ string(REPLACE ";" " " extra_flags "${try_compile_flags}")
|
||||
+
|
||||
+ set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}")
|
||||
+ foreach(substitution ${substitutions})
|
||||
+ if(substitution STREQUAL "<CMAKE_C_COMPILER>")
|
||||
+ string(REPLACE "<CMAKE_C_COMPILER>"
|
||||
+ "${CMAKE_C_COMPILER}" test_compile_command ${test_compile_command})
|
||||
+ elseif(substitution STREQUAL "<OBJECT>")
|
||||
+ string(REPLACE "<OBJECT>" "${TARGET_NAME}/CheckSectionExists.o"
|
||||
+ test_compile_command ${test_compile_command})
|
||||
+ elseif(substitution STREQUAL "<SOURCE>")
|
||||
+ string(REPLACE "<SOURCE>" "${TARGET_NAME}/CheckSectionExists.c"
|
||||
+ test_compile_command ${test_compile_command})
|
||||
+ elseif(substitution STREQUAL "<FLAGS>")
|
||||
+ string(REPLACE "<FLAGS>" "${CMAKE_C_FLAGS} ${extra_flags}"
|
||||
+ test_compile_command ${test_compile_command})
|
||||
+ else()
|
||||
+ string(REPLACE "${substitution}" "" test_compile_command
|
||||
+ ${test_compile_command})
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+
|
||||
+ string(REPLACE " " ";" test_compile_command "${test_compile_command}")
|
||||
+
|
||||
+ execute_process(
|
||||
+ COMMAND ${test_compile_command}
|
||||
+ RESULT_VARIABLE TEST_RESULT
|
||||
+ OUTPUT_VARIABLE TEST_OUTPUT
|
||||
+ ERROR_VARIABLE TEST_ERROR
|
||||
+ )
|
||||
+
|
||||
+ execute_process(
|
||||
+ COMMAND ${CMAKE_OBJDUMP} -h "${TARGET_NAME}/CheckSectionExists.o"
|
||||
+ RESULT_VARIABLE CHECK_RESULT
|
||||
+ OUTPUT_VARIABLE CHECK_OUTPUT
|
||||
+ ERROR_VARIABLE CHECK_ERROR
|
||||
+ )
|
||||
+ string(FIND "${CHECK_OUTPUT}" "${section}" SECTION_FOUND)
|
||||
+
|
||||
+ if(NOT SECTION_FOUND EQUAL -1)
|
||||
+ set(${output} TRUE PARENT_SCOPE)
|
||||
+ else()
|
||||
+ set(${output} FALSE PARENT_SCOPE)
|
||||
+ endif()
|
||||
+
|
||||
+ file(REMOVE_RECURSE ${TARGET_NAME})
|
||||
+endfunction()
|
||||
+
|
||||
+check_cxx_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY
|
||||
+ SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n")
|
||||
+
|
||||
+append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS)
|
||||
+append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS)
|
||||
+
|
||||
+foreach(arch ${CRT_SUPPORTED_ARCH})
|
||||
+ add_compiler_rt_runtime(clang_rt.crtbegin
|
||||
+ OBJECT
|
||||
+ ARCHS ${arch}
|
||||
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c
|
||||
+ CFLAGS ${CRT_CFLAGS}
|
||||
+ PARENT_TARGET crt)
|
||||
+ add_compiler_rt_runtime(clang_rt.crtbegin_shared
|
||||
+ OBJECT
|
||||
+ ARCHS ${arch}
|
||||
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c
|
||||
+ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED
|
||||
+ PARENT_TARGET crt)
|
||||
+ add_compiler_rt_runtime(clang_rt.crtend
|
||||
+ OBJECT
|
||||
+ ARCHS ${arch}
|
||||
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c
|
||||
+ CFLAGS ${CRT_CFLAGS}
|
||||
+ 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")
|
@ -1,219 +0,0 @@
|
||||
{ lib, 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 |
||||
, erisPatchHook, genodePackages ? null }: |
||||
|
||||
let |
||||
release_version = "11.0.0"; |
||||
version = |
||||
release_version; # differentiating these (variables) is important for RCs |
||||
|
||||
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 = 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 |
||||
'' + 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 = if stdenv.targetPlatform.isGenode then |
||||
wrapCCWith rec { |
||||
cc = tools.clang-unwrapped; |
||||
gccForLibs = genodePackages.genodeSources.toolchain.cc; |
||||
bintools = wrapBintoolsWith { inherit (tools) bintools; }; |
||||
extraBuildCommands = with genodePackages.genodeSources; '' |
||||
echo "--gcc-toolchain=${toolchain.cc}" >> $out/nix-support/cc-cflags |
||||
echo "--sysroot=${genodeBase}" >> $out/nix-support/cc-cflags |
||||
echo "-I${genodeBase}/include" >> $out/nix-support/cc-cflags |
||||
echo "-L ${genodeBase}" >> $out/nix-support/cc-ldflags |
||||
|
||||
for dir in ${gccForLibs}/${stdenv.targetPlatform.config}/include/c++/*; do |
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags |
||||
done |
||||
echo "-isystem ${genodePackages.genodeSources}/repos/libports/include/stdcxx" >> $out/nix-support/libcxx-cxxflags |
||||
for dir in ${genodePackages.genodeSources.ports.stdcxx}/*/include/stdcxx; do |
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags |
||||
echo "-isystem $dir/std" >> $out/nix-support/libcxx-cxxflags |
||||
echo "-isystem $dir/c_global" >> $out/nix-support/libcxx-cxxflags |
||||
done |
||||
|
||||
echo "${genodePackages.stdcxx}/lib/stdcxx.lib.so" >> $out/nix-support/libcxx-ldflags |
||||
''; |
||||
} |
||||
else |
||||
wrapCCWith rec { |
||||
cc = tools.clang-unwrapped; |
||||
libcxx = targetLlvmLibraries.libcxx; |
||||
bintools = wrapBintoolsWith { inherit (tools) bintools; }; |
||||
extraPackages = |
||||
[ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ] |
||||
++ 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 |
||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' |
||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags |
||||
'' + lib.optionalString stdenv.targetPlatform.isWasm '' |
||||
echo "-fno-exceptions" >> $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 |
||||
'' + 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 = 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 ({ } |
||||
// (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++ ({ } |
||||
// (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { |
||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; |
||||
})); |
||||
|
||||
libcxxabi = callPackage ./libc++abi.nix ({ } |
||||
// (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { |
||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; |
||||
libunwind = libraries.libunwind; |
||||
})); |
||||
|
||||
openmp = callPackage ./openmp.nix { }; |
||||
|
||||
libunwind = callPackage ./libunwind.nix ({ } |
||||
// (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { |
||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; |
||||
})); |
||||
|
||||
}); |
||||
|
||||
in { inherit tools libraries; } // libraries // tools |
@ -1,47 +0,0 @@
|
||||
{ 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 |
||||
''; |
||||
|
||||
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" ] |
||||
++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) |
||||
"-DLIBCXX_HAS_MUSL_LIBC=1" |
||||
++ lib.optional (stdenv.hostPlatform.useLLVM or false) |
||||
"-DLIBCXX_USE_COMPILER_RT=ON" ++ lib.optional stdenv.hostPlatform.isWasm [ |
||||
"-DLIBCXX_ENABLE_THREADS=OFF" |
||||
"-DLIBCXX_ENABLE_FILESYSTEM=OFF" |
||||
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF" |
||||
] ++ 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 lib.licenses; [ ncsa mit ]; |
||||
platforms = lib.platforms.all; |
||||
}; |
||||
} |
@ -1,61 +0,0 @@
|
||||
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())
|
@ -1,69 +0,0 @@
|
||||
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version |
||||
, enableShared ? true }: |
||||
|
||||
stdenv.mkDerivation { |
||||
pname = "libc++abi"; |
||||
inherit version; |
||||
|
||||
src = |
||||
fetch "libcxxabi" "05ac7rkjbla03bc0lf92f901dfjgxdvp8cr9fpn59a5p4x27ssaq"; |
||||
|
||||
nativeBuildInputs = [ cmake ]; |
||||
buildInputs = lib.optional |
||||
(!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) |
||||
libunwind; |
||||
|
||||
cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [ |
||||
"-DLLVM_ENABLE_LIBCXX=ON" |
||||
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON" |
||||