LLVM, clang, and lldb 3.6

This commit is contained in:
Benjamin Saunders 2015-03-05 06:43:33 +01:00
parent 19a7494600
commit f1b7e4d127
10 changed files with 367 additions and 0 deletions

@ -0,0 +1,29 @@
diff -Naur clang-3.6.0.src-orig/CMakeLists.txt clang-3.6.0.src/CMakeLists.txt
--- clang-3.6.0.src-orig/CMakeLists.txt 2015-03-05 05:56:20.788520896 +0100
+++ clang-3.6.0.src/CMakeLists.txt 2015-03-05 06:02:15.589365469 +0100
@@ -362,6 +362,7 @@
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
install(TARGETS ${name}
+ EXPORT ClangTargets
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
RUNTIME DESTINATION bin)
@@ -516,15 +517,15 @@
set(CLANG_INSTALL_PACKAGE_DIR share/clang/cmake)
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
- export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
# Install a <prefix>/share/clang/cmake/ClangConfig.cmake file so that
# find_package(Clang) works. Install the target list with it.
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
- ${CLANG_BINARY_DIR}/share/clang/cmake/ClangTargets.cmake
DESTINATION share/clang/cmake)
+ install(EXPORT ClangTargets DESTINATION share/clang/cmake)
+
# Also copy ClangConfig.cmake to the build directory so that dependent projects
# can build against a build directory of Clang more easily.
configure_file(

@ -0,0 +1,22 @@
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 198e82e..810d006 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -7355,17 +7355,6 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-shared");
}
- if (ToolChain.getArch() == llvm::Triple::arm ||
- ToolChain.getArch() == llvm::Triple::armeb ||
- ToolChain.getArch() == llvm::Triple::thumb ||
- ToolChain.getArch() == llvm::Triple::thumbeb ||
- (!Args.hasArg(options::OPT_static) &&
- !Args.hasArg(options::OPT_shared))) {
- CmdArgs.push_back("-dynamic-linker");
- CmdArgs.push_back(Args.MakeArgString(
- D.DyldPrefix + getLinuxDynamicLinker(Args, ToolChain)));
- }
-
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());

@ -0,0 +1,46 @@
{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src }:
stdenv.mkDerivation {
name = "clang-${version}";
unpackPhase = ''
unpackFile ${fetch "cfe" "0b8825mvdhfk5r9gwcwp1j2dl9kw5glgyk7pybq2dzhrh4vnj3my"}
mv cfe-${version}.src clang
sourceRoot=$PWD/clang
unpackFile ${clang-tools-extra_src}
mv clang-tools-extra-* $sourceRoot/tools/extra
'';
buildInputs = [ cmake libedit libxml2 llvm ];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_CXX_FLAGS=-std=c++11"
] ++
(stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include");
patches = [ ./clang-purity.patch ./clang-exports.patch ];
postPatch = ''
sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp
'';
# Clang expects to find LLVMgold in its own prefix
# Clang expects to find sanitizer libraries in its own prefix
postInstall = ''
ln -sv ${llvm}/lib/LLVMgold.so $out/lib
ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/
ln -sv $out/bin/clang $out/bin/cpp
'';
enableParallelBuilding = true;
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.all;
};
}

@ -0,0 +1,31 @@
{ pkgs, newScope, stdenv, isl, fetchurl }:
let
callPackage = newScope (self // { inherit stdenv isl version fetch; });
version = "3.6.0";
fetch = fetch_v version;
fetch_v = ver: name: sha256: fetchurl {
url = "http://llvm.org/releases/${ver}/${name}-${ver}.src.tar.xz";
inherit sha256;
};
compiler-rt_src = fetch "compiler-rt" "04bbn946jninynkrjyp337xqs8ihn4fkz5xgvmywxkddwmwznjbz";
clang-tools-extra_src = fetch "clang-tools-extra" "04n83gsmy2ghvn7vp9hamsgn332rx2g7sa4paskr0d4ihax4ka9s";
self = {
llvm = callPackage ./llvm.nix {
inherit compiler-rt_src;
};
clang = callPackage ./clang.nix {
inherit clang-tools-extra_src;
};
lldb = callPackage ./lldb.nix {};
libcxx = callPackage ./libc++ { stdenv = pkgs.clangStdenv; };
libcxxabi = callPackage ./libc++abi { stdenv = pkgs.clangStdenv; };
};
in self

@ -0,0 +1,30 @@
diff -ru -x '*~' libcxx-3.4.2.src-orig/lib/CMakeLists.txt libcxx-3.4.2.src/lib/CMakeLists.txt
--- libcxx-3.4.2.src-orig/lib/CMakeLists.txt 2013-11-15 18:18:57.000000000 +0100
+++ libcxx-3.4.2.src/lib/CMakeLists.txt 2014-09-24 14:04:01.000000000 +0200
@@ -56,7 +56,7 @@
"-compatibility_version 1"
"-current_version ${LIBCXX_VERSION}"
"-install_name /usr/lib/libc++.1.dylib"
- "-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
+ "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
"/usr/lib/libSystem.B.dylib")
else()
@@ -64,14 +64,14 @@
list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7)
if (OSX_HAS_ARMV7)
set(OSX_RE_EXPORT_LINE
- "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"
+ "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
"-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
else()
set(OSX_RE_EXPORT_LINE
- "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
+ "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib")
endif()
else()
- set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+ set (OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
endif()
list(APPEND link_flags

@ -0,0 +1,41 @@
{ lib, stdenv, fetch, cmake, libcxxabi, fixDarwinDylibNames, version }:
stdenv.mkDerivation rec {
name = "libc++-${version}";
src = fetch "libcxx" "1dzvhyrzj54v823biadag5lwxfz37gm8a65aq72pjsh8n211x719";
# instead of allowing libc++ to link with /usr/lib/libc++abi.dylib,
# force it to link with our copy
preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace lib/CMakeLists.txt \
--replace 'OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib' \
'OSX_RE_EXPORT_LINE "${libcxxabi}/lib/libc++abi.dylib' \
--replace '"''${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"' \
'"${libcxxabi}/lib/libc++abi.dylib"'
'';
patches = [ ./darwin.patch ];
buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
cmakeFlags =
[ "-DCMAKE_BUILD_TYPE=Release"
"-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include"
"-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
"-DLIBCXX_LIBCPPABI_VERSION=2"
"-DLIBCXX_CXX_ABI=libcxxabi"
];
enableParallelBuilding = true;
setupHook = ./setup-hook.sh;
meta = {
homepage = http://libcxx.llvm.org/;
description = "A new implementation of the C++ standard library, targeting C++11";
license = "BSD";
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.unix;
};
}

@ -0,0 +1,4 @@
export NIX_CFLAGS_COMPILE+=" -isystem @out@/include/c++/v1"
export NIX_CXXSTDLIB_COMPILE=" -stdlib=libc++"
export NIX_CXXSTDLIB_LINK=" -stdlib=libc++"

@ -0,0 +1,47 @@
{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
stdenv.mkDerivation {
name = "libc++abi-${version}";
src = fetch "libcxxabi" "1xclv63l7cmrxkl129w6j9fsxgdm8jjlcm8gswl2y9qmh3dwz2zp";
buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin) libunwind;
postUnpack = ''
unpackFile ${libcxx.src}
unpackFile ${llvm.src}
export NIX_CFLAGS_COMPILE+=" -I$PWD/include"
export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include"
'' + stdenv.lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'';
installPhase = if stdenv.isDarwin
then ''
for file in lib/*; 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
# http://www.cmake.org/Wiki/CMake_RPATH_handling
install_name_tool -id $out/$file $file
done
make install
install -d 755 $out/include
install -m 644 ../include/cxxabi.h $out/include
''
else ''
install -d -m 755 $out/include $out/lib
install -m 644 lib/libc++abi.so.1.0 $out/lib
install -m 644 ../include/cxxabi.h $out/include
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 = http://libcxxabi.llvm.org/;
description = "A new implementation of low level support for a standard C++ library";
license = "BSD";
maintainers = with stdenv.lib.maintainers; [ shlevy vlstill ];
platforms = stdenv.lib.platforms.unix;
};
}

@ -0,0 +1,44 @@
{ stdenv
, fetch
, cmake
, zlib
, ncurses
, swig
, which
, libedit
, llvm
, clang
, python
, version
}:
stdenv.mkDerivation {
name = "lldb-${version}";
src = fetch "lldb" "1cphxbc8c0yqs2rxn94vcn8his465m97rnynklpzm8sf5kad26ib";
patchPhase = ''
sed -i 's|/usr/bin/env||' \
scripts/Python/finish-swig-Python-LLDB.sh \
scripts/Python/build-swig-Python.sh
'';
buildInputs = [ cmake python which swig ncurses zlib libedit ];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_CXX_FLAGS=-std=c++11"
"-DLLDB_PATH_TO_LLVM_BUILD=${llvm}"
"-DLLDB_PATH_TO_CLANG_BUILD=${clang}"
];
enableParallelBuilding = true;
meta = {
description = "A next-generation high-performance debugger";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.all;
};
}

@ -0,0 +1,73 @@
{ stdenv
, fetch
, perl
, groff
, cmake
, python
, libffi
, binutils
, libxml2
, valgrind
, ncurses
, version
, zlib
, compiler-rt_src
}:
let
src = fetch "llvm" "1kmr5vlnz1419nnvyc7lsrcfx09n65ravjbmzxrqz7ml07jnk6mk";
in stdenv.mkDerivation rec {
name = "llvm-${version}";
unpackPhase = ''
unpackFile ${src}
mv llvm-${version}.src llvm
sourceRoot=$PWD/llvm
unpackFile ${compiler-rt_src}
mv compiler-rt-* $sourceRoot/projects/compiler-rt
'';
buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind;
propagatedBuildInputs = [ ncurses zlib ];
# hacky fix: created binaries need to be run before installation
preBuild = ''
mkdir -p $out/
ln -sv $PWD/lib $out
'';
cmakeFlags = with stdenv; [
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_BUILD_TESTS=ON"
"-DLLVM_ENABLE_FFI=ON"
] ++ stdenv.lib.optionals (!isDarwin) [
"-DBUILD_SHARED_LIBS=ON"
"-DLLVM_BINUTILS_INCDIR=${binutils}/include"
] ++ stdenv.lib.optionals ( isDarwin) [
"-DCMAKE_CXX_FLAGS=-stdlib=libc++"
"-DCAN_TARGET_i386=false"
];
postBuild = ''
rm -fR $out
paxmark m bin/{lli,llvm-rtdyld}
paxmark m unittests/ExecutionEngine/JIT/JITTests
paxmark m unittests/ExecutionEngine/MCJIT/MCJITTests
paxmark m unittests/Support/SupportTests
'';
enableParallelBuilding = true;
passthru.src = src;
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = with stdenv.lib.maintainers; [ shlevy lovek323 raskin viric ];
platforms = stdenv.lib.platforms.all;
};
}