Merge pull request #268509 from sternenseemann/kill-llvm-6-7

haskell.compiler: stop reliance on LLVM 6 & 7; haskell.compiler.ghc884: remove at 8.8.4; llvmPackages_7: remove at 7.1.0
This commit is contained in:
sternenseemann 2023-12-05 02:03:01 +01:00 committed by GitHub
commit 1b97c8741d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 28 additions and 4007 deletions

View file

@ -155,7 +155,7 @@ stdenv.mkDerivation rec {
homepage = "https://root.cern.ch/";
description = "A data analysis framework";
platforms = platforms.unix;
broken = !stdenv.isx86_64;
broken = !stdenv.isx86_64 || stdenv.cc.isClang or false;
maintainers = with maintainers; [ veprbl ];
license = licenses.lgpl21;
};

View file

@ -6,13 +6,13 @@
llvmPackages.stdenv.mkDerivation rec {
pname = "cone";
version = "unstable-2021-07-25";
version = "unstable-2022-12-12";
src = fetchFromGitHub {
owner = "jondgoodwin";
repo = pname;
rev = "5feaabc342bcff3755f638a7e25155cd12127592";
sha256 = "CTDS83AWtuDY5g6NDn7O2awrYsKFf3Kp35FkMEjfbVw=";
rev = "698bd6afc75777eabbc8ef576d64d683c6a1c5ab";
sha256 = "0y2s9xgkci8n72v6gnc1i7shr2y3g2sa8fbr25gpxa9ipiq9khg7";
};
nativeBuildInputs = [ cmake ];
@ -21,10 +21,10 @@ llvmPackages.stdenv.mkDerivation rec {
llvmPackages.llvm
];
# M68k is an experimental target, so not enabled by default
postPatch = ''
sed -i CMakeLists.txt \
-e 's/LLVM 7/LLVM/' \
-e '/AVR/d'
-e '/M68k/d'
'';
installPhase = ''

View file

@ -10,7 +10,9 @@
assert stdenv.targetPlatform == stdenv.hostPlatform;
let
useLLVM = !stdenv.targetPlatform.isx86;
useLLVM = !(stdenv.targetPlatform.isx86
|| stdenv.targetPlatform.isPower
|| stdenv.targetPlatform.isSparc);
useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux"
|| (with stdenv.hostPlatform; isPower64 && isLittleEndian);
@ -38,7 +40,7 @@ let
targetPackages.stdenv.cc.bintools
coreutils # for cat
]
++ lib.optionals useLLVM [
++ lib.optionals (assert useLLVM -> !(llvmPackages == null); useLLVM) [
(lib.getBin llvmPackages.llvm)
]
# On darwin, we need unwrapped bintools as well (for otool)
@ -66,10 +68,6 @@ stdenv.mkDerivation rec {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz";
sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g";
};
aarch64-linux = {
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz";
sha256 = "11n7l2a36i5vxzzp85la2555q4m34l747g0pnmd81cp46y85hlhq";
};
x86_64-darwin = {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
sha256 = "0s9188vhhgf23q3rjarwhbr524z6h2qga5xaaa2pma03sfqvvhfz";
@ -216,7 +214,12 @@ stdenv.mkDerivation rec {
meta = rec {
license = lib.licenses.bsd3;
platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "powerpc64le-linux" ];
platforms = [
"x86_64-linux"
"i686-linux"
"x86_64-darwin"
"powerpc64le-linux"
];
# build segfaults, use ghc8102Binary which has proper musl support instead
broken = stdenv.hostPlatform.isMusl;
maintainers = with lib.maintainers; [

View file

@ -1,381 +0,0 @@
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
# build-tools
, bootPkgs
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
, bash
, libiconv ? null, ncurses
, # GHC can be built with system libffi or a bundled one.
libffi ? null
, useLLVM ? !(stdenv.targetPlatform.isx86
|| stdenv.targetPlatform.isPower
|| stdenv.targetPlatform.isSparc)
, # LLVM is conceptually a run-time-only dependency, but for
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
# build-time dependency too.
buildTargetLlvmPackages, llvmPackages
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp
&& lib.meta.availableOn stdenv.targetPlatform gmp)
, gmp
, # If enabled, use -fPIC when compiling static libs.
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
, enableProfiledLibs ? true
, # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built.
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
, # Whether to build terminfo.
enableTerminfo ? !stdenv.targetPlatform.isWindows
, # What flavour to build. An empty string indicates no
# specific flavour and falls back to ghc default values.
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
(if useLLVM then "perf-cross" else "perf-cross-ncg")
, # Whether to build sphinx documentation.
enableDocs ? (
# Docs disabled for musl and cross because it's a large task to keep
# all `sphinx` dependencies building in those environments.
# `sphinx` pullls in among others:
# Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
(stdenv.targetPlatform == stdenv.hostPlatform)
&& !stdenv.hostPlatform.isMusl
)
, enableHaddockProgram ?
# Disabled for cross; see note [HADDOCK_DOCS].
(stdenv.targetPlatform == stdenv.hostPlatform)
, # Whether to disable the large address space allocator
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
}:
assert !enableIntegerSimple -> gmp != null;
# Cross cannot currently build the `haddock` program for silly reasons,
# see note [HADDOCK_DOCS].
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
let
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
targetPrefix = lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
buildMK = dontStrip: ''
BuildFlavour = ${ghcFlavour}
ifneq \"\$(BuildFlavour)\" \"\"
include mk/flavours/\$(BuildFlavour).mk
endif
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
BUILD_SPHINX_PDF = NO
'' +
# Note [HADDOCK_DOCS]:
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
# program is built (which we generally always want to have a complete GHC install)
# and whether it is run on the GHC sources to generate hyperlinked source code
# (which is impossible for cross-compilation); see:
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
# This implies that currently a cross-compiled GHC will never have a `haddock`
# program, so it can never generate haddocks for any packages.
# If this is solved in the future, we'd like to unconditionally
# build the haddock program (removing the `enableHaddockProgram` option).
''
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
''
# We only need to build stage1 on most cross-compilation because
# we will be running the compiler on the native system. In some
# situations, like native Musl compilation, we need the compiler
# to actually link to our new Libc. The iOS simulator is a special
# exception because we cant actually run simulators binaries
# ourselves.
+ lib.optionalString (targetPlatform != hostPlatform) ''
Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
CrossCompilePrefix = ${targetPrefix}
'' + lib.optionalString dontStrip ''
STRIP_CMD = :
'' + lib.optionalString (!enableProfiledLibs) ''
GhcLibWays = "v dyn"
'' + lib.optionalString enableRelocatedStaticLibs ''
GhcLibHcOpts += -fPIC
GhcRtsHcOpts += -fPIC
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
EXTRA_CC_OPTS += -std=gnu99
''
# While split sections are now enabled by default in ghc 8.8 for windows,
# they seem to lead to `too many sections` errors when building base for
# profiling.
+ lib.optionalString targetPlatform.isWindows ''
SplitSections = NO
'';
# Splicer will pull out correct variations
libDeps = platform: lib.optional enableTerminfo ncurses
++ [libffi]
++ lib.optional (!enableIntegerSimple) gmp
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
# GHC doesn't seem to have {LLC,OPT}_HOST
toolsForTarget = [
pkgsBuildTarget.targetPackages.stdenv.cc
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
targetCC = builtins.head toolsForTarget;
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
# see #84670 and #49071 for more background.
useLdGold = targetPlatform.linker == "gold" ||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
variantSuffix = lib.concatStrings [
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
(lib.optionalString enableIntegerSimple "-integer-simple")
];
in
# C compiler, bintools and LLVM are used at build time, but will also leak into
# the resulting GHC's settings file and used at runtime. This means that we are
# currently only able to build GHC if hostPlatform == buildPlatform.
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
stdenv.mkDerivation (rec {
version = "8.8.4";
pname = "${targetPrefix}ghc${variantSuffix}";
src = fetchurl {
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
sha256 = "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h";
};
enableParallelBuilding = true;
outputs = [ "out" "doc" ];
patches = [
# Fix docs build with sphinx >= 6.0
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
./ghc-8.8.4-sphinx-6.0.patch
# See upstream patch at
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build
# from source distributions, the auto-generated configure script needs to be
# patched as well, therefore we use an in-tree patch instead of pulling the
# upstream patch. Don't forget to check backport status of the upstream patch
# when adding new GHC releases in nixpkgs.
./respect-ar-path.patch
# Fix documentation configuration which causes a syntax error with sphinx 4.*
# See also https://gitlab.haskell.org/ghc/ghc/-/issues/19962
./sphinx-4-configuration.patch
# cabal passes incorrect --host= when cross-compiling
# https://github.com/haskell/cabal/issues/5887
(fetchpatch {
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch";
sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1";
})
# error: 'VirtualAllocExNuma' redeclared as different kind of symbol
# name conflict between rts/win32/OSMem.c and winbase.h from the mingw-w64 runtime package
# Renamed to match ghc8.8:
# https://gitlab.haskell.org/ghc/ghc/-/commit/4b431f334018eaef2cf36de3316025c68c922915#20d64c0bdc272817149d1d5cf20a73a8b5fd637f
./rename-numa-api-call.patch
];
postPatch = "patchShebangs .";
# GHC is a bit confused on its cross terminology.
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
preConfigure =
# Aarch64 allow backward bootstrapping since earlier versions are unstable.
# Same for musl, as earlier versions do not provide a musl bindist for bootstrapping.
lib.optionalString (stdenv.isAarch64 || stdenv.hostPlatform.isMusl) ''
find . -name \*\.cabal\* -exec sed -i -e 's/\(base.*\)4.14/\14.16/' {} \; \
-exec sed -i -e 's/\(prim.*\)0.6/\10.8/' {} \;
''
+ ''
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
export "''${env#TARGET_}=''${!env}"
done
# GHC is a bit confused on its cross terminology, as these would normally be
# the *host* tools.
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
'' + lib.optionalString useLLVM ''
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
'' + ''
echo -n "${buildMK dontStrip}" > mk/build.mk
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
'' + lib.optionalString (!stdenv.isDarwin) ''
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
'' + lib.optionalString stdenv.isDarwin ''
export NIX_LDFLAGS+=" -no_dtrace_dof"
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
'' + lib.optionalString targetPlatform.isMusl ''
echo "patching llvm-targets for musl targets..."
echo "Cloning these existing '*-linux-gnu*' targets:"
grep linux-gnu llvm-targets | sed 's/^/ /'
echo "(go go gadget sed)"
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
echo "llvm-targets now contains these '*-linux-musl*' targets:"
grep linux-musl llvm-targets | sed 's/^/ /'
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
for x in configure aclocal.m4; do
substituteInPlace $x \
--replace '*-android*|*-gnueabi*)' \
'*-android*|*-gnueabi*|*-musleabi*)'
done
'';
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ]
++ lib.optional (targetPlatform != hostPlatform) "target";
# `--with` flags for libraries needed for RTS linker
configureFlags = [
"--datadir=$doc/share/doc/ghc"
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
] ++ lib.optionals (libffi != null) [
"--with-system-libffi"
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
"--with-iconv-includes=${libiconv}/include"
"--with-iconv-libraries=${libiconv}/lib"
] ++ lib.optionals (targetPlatform != hostPlatform) [
"--enable-bootstrap-with-devel-snapshot"
] ++ lib.optionals useLdGold [
"CFLAGS=-fuse-ld=gold"
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
] ++ lib.optionals (disableLargeAddressSpace) [
"--disable-large-address-space"
];
# Make sure we never relax`$PATH` and hooks support for compatibility.
strictDeps = true;
# Dont add -liconv to LDFLAGS automatically so that GHC will add it itself.
dontAddExtraLibs = true;
nativeBuildInputs = [
perl autoconf automake m4 python3
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
] ++ lib.optionals enableDocs [
sphinx
];
# For building runtime libs
depsBuildTarget = toolsForTarget;
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
# required, because otherwise all symbols from HSffi.o are stripped, and
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
checkTarget = "test";
hardeningDisable =
[ "format" ]
# In nixpkgs, musl based builds currently enable `pie` hardening by default
# (see `defaultHardeningFlags` in `make-derivation.nix`).
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
# See:
# * https://github.com/NixOS/nixpkgs/issues/129247
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
++ lib.optional stdenv.targetPlatform.isMusl "pie";
postInstall = ''
# Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
'';
passthru = {
inherit bootPkgs targetPrefix;
inherit llvmPackages;
inherit enableShared;
# This is used by the haskell builder to query
# the presence of the haddock program.
hasHaddock = enableHaddockProgram;
# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
};
meta = {
homepage = "http://haskell.org/ghc";
description = "The Glasgow Haskell Compiler";
maintainers = with lib.maintainers; [
guibou
] ++ lib.teams.haskell.members;
timeout = 24 * 3600;
inherit (ghc.meta) license;
# hardcode platforms because the bootstrap GHC differs depending on the platform,
# with differing platforms available for each of them; See HACK comment in
# 8.10.2-binary.nix for an explanation of the musl special casing.
platforms = [
"x86_64-linux"
] ++ lib.optionals (!hostPlatform.isMusl) [
"i686-linux"
"aarch64-linux"
"x86_64-darwin"
];
# integer-simple builds are broken with musl when bootstrapping using
# GHC 8.10.2 and below, however it is not possible to reverse bootstrap
# GHC 8.8.4 with GHC 8.10.7.
# See https://github.com/NixOS/nixpkgs/pull/138523#issuecomment-927339953
broken = hostPlatform.isMusl && enableIntegerSimple;
};
dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
dontPatchELF = true;
noAuditTmpdir = true;
})

View file

@ -1,68 +0,0 @@
From 8412cba68835f8f4cc527d02194b181faa5944d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Holger=20W=C3=BCnsche?= <holger.o.wuensche@t-online.de>
Date: Tue, 21 Jan 2020 19:46:09 +0100
Subject: [PATCH] [HIP] use GetProgramPath for executable discovery
This change replaces the manual building of executable paths
using llvm::sys::path::append with GetProgramPath.
This enables adding other paths in case executables reside
in different directories and makes the code easier to read.
Differential Revision: https://reviews.llvm.org/D72903
---
clang/lib/Driver/ToolChains/HIP.cpp | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/lib/Driver/ToolChains/HIP.cpp b/lib/Driver/ToolChains/HIP.cpp
index 03acf45a9b3..75fd3226c75 100644
--- a/lib/Driver/ToolChains/HIP.cpp
+++ b/lib/Driver/ToolChains/HIP.cpp
@@ -98,9 +98,8 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand(
const char *OutputFileName =
C.addTempFile(C.getArgs().MakeArgString(TmpName));
CmdArgs.push_back(OutputFileName);
- SmallString<128> ExecPath(C.getDriver().Dir);
- llvm::sys::path::append(ExecPath, "llvm-link");
- const char *Exec = Args.MakeArgString(ExecPath);
+ const char *Exec =
+ Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
return OutputFileName;
}
@@ -141,9 +140,8 @@ const char *AMDGCN::Linker::constructOptCommand(
const char *OutputFileName =
C.addTempFile(C.getArgs().MakeArgString(TmpFileName));
OptArgs.push_back(OutputFileName);
- SmallString<128> OptPath(C.getDriver().Dir);
- llvm::sys::path::append(OptPath, "opt");
- const char *OptExec = Args.MakeArgString(OptPath);
+ const char *OptExec =
+ Args.MakeArgString(getToolChain().GetProgramPath("opt"));
C.addCommand(llvm::make_unique<Command>(JA, *this, OptExec, OptArgs, Inputs));
return OutputFileName;
}
@@ -161,9 +159,7 @@ const char *AMDGCN::Linker::constructLlcCommand(
const char *LlcOutputFile =
C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName));
LlcArgs.push_back(LlcOutputFile);
- SmallString<128> LlcPath(C.getDriver().Dir);
- llvm::sys::path::append(LlcPath, "llc");
- const char *Llc = Args.MakeArgString(LlcPath);
+ const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
C.addCommand(llvm::make_unique<Command>(JA, *this, Llc, LlcArgs, Inputs));
return LlcOutputFile;
}
@@ -178,9 +174,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
ArgStringList LldArgs{"-flavor", "gnu", "--no-undefined",
"-shared", "-o", Output.getFilename(),
InputFileName};
- SmallString<128> LldPath(C.getDriver().Dir);
- llvm::sys::path::append(LldPath, "lld");
- const char *Lld = Args.MakeArgString(LldPath);
+ const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
C.addCommand(llvm::make_unique<Command>(JA, *this, Lld, LldArgs, Inputs));
}
--
2.23.1

View file

@ -1,139 +0,0 @@
{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false # TODO: get this info from llvm (passthru?)
}:
let
self = stdenv.mkDerivation ({
pname = "clang";
inherit version;
src = fetch "cfe" "0vc4i87qwxnw9lci4ayws9spakg0z6w5w670snj9f8g5m9rc8zg9";
unpackPhase = ''
unpackFile $src
mv cfe-${version}* clang
sourceRoot=$PWD/clang
unpackFile ${clang-tools-extra_src}
mv clang-tools-extra-* $sourceRoot/tools/extra
'';
nativeBuildInputs = [ cmake python3 ]
++ lib.optional enableManpages python3.pkgs.sphinx
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
buildInputs = [ libxml2 libllvm ];
cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-std=c++11"
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
] ++ 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.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
] ++ lib.optionals enablePolly [
"-DWITH_POLLY=ON"
"-DLINK_POLLY_INTO_TOOLS=ON"
];
patches = [
../../common/clang/5-8-purity.patch
# make clang -xhip use $PATH to find executables
./HIP-use-PATH-7.patch
# Backport for the `--unwindlib=[libgcc|compiler-rt]` flag, which is
# needed for our bootstrapping to not interfere with C.
./unwindlib.patch
./gnu-install-dirs.patch
(substituteAll {
src = ../../clang-6-10-LLVMgold-path.patch;
libllvmLibdir = "${libllvm.lib}/lib";
})
];
postPatch = ''
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
lib/Driver/ToolChains/*.cpp
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
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" "dev" "python" ];
postInstall = ''
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,scan-view}
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
mv $out/share/scan-view/*.py $python/share/scan-view
rm $out/bin/c-index-test
patchShebangs $python/bin
mkdir -p $dev/bin
cp bin/clang-tblgen $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";
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 = llvm_meta // {
description = "man page for Clang ${version}";
};
});
in self

View file

@ -1,281 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 52b881939499..85662a2113e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.4.3)
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
project(Clang)
+ include(GNUInstallDirs)
+
# Rely on llvm-config.
set(CONFIG_OUTPUT)
find_program(LLVM_CONFIG "llvm-config")
@@ -374,7 +376,7 @@ include_directories(BEFORE
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/clang include/clang-c
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.def"
PATTERN "*.h"
@@ -383,7 +385,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "CMakeFiles" EXCLUDE
PATTERN "*.inc"
@@ -391,7 +393,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
)
install(PROGRAMS utils/bash-autocomplete.sh
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
)
endif()
diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake
index c09a8423f9f6..39f37e0097eb 100644
--- a/cmake/modules/AddClang.cmake
+++ b/cmake/modules/AddClang.cmake
@@ -99,9 +99,9 @@ macro(add_clang_library name)
install(TARGETS ${name}
COMPONENT ${name}
${export_to_clangtargets}
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- RUNTIME DESTINATION bin)
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
@@ -141,7 +141,7 @@ macro(add_clang_tool name)
install(TARGETS ${name}
${export_to_clangtargets}
- RUNTIME DESTINATION bin
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT ${name})
if(NOT CMAKE_CONFIGURATION_TYPES)
@@ -156,5 +156,5 @@ endmacro()
macro(add_clang_symlink name dest)
add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
# Always generate install targets
- llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+ llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
endmacro()
diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
index 1930d8e225c7..bb9158093079 100644
--- a/lib/Headers/CMakeLists.txt
+++ b/lib/Headers/CMakeLists.txt
@@ -162,19 +162,19 @@ install(
FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
COMPONENT clang-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
install(
FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h
COMPONENT clang-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
install(
FILES ${cuda_wrapper_files}
COMPONENT clang-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
add_llvm_install_targets(install-clang-headers
diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt
index 53e3421f1b35..79ae5bb4c399 100644
--- a/tools/c-index-test/CMakeLists.txt
+++ b/tools/c-index-test/CMakeLists.txt
@@ -54,7 +54,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH
"@executable_path/../../lib")
else()
- set(INSTALL_DESTINATION bin)
+ set(INSTALL_DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS c-index-test
diff --git a/tools/clang-check/CMakeLists.txt b/tools/clang-check/CMakeLists.txt
index c5ace26c2914..97bdfca7d896 100644
--- a/tools/clang-check/CMakeLists.txt
+++ b/tools/clang-check/CMakeLists.txt
@@ -20,4 +20,4 @@ target_link_libraries(clang-check
)
install(TARGETS clang-check
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/tools/clang-format/CMakeLists.txt b/tools/clang-format/CMakeLists.txt
index a295e8cd0b2a..1973ff82c7f6 100644
--- a/tools/clang-format/CMakeLists.txt
+++ b/tools/clang-format/CMakeLists.txt
@@ -21,20 +21,20 @@ if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
endif()
install(PROGRAMS clang-format-bbedit.applescript
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
COMPONENT clang-format)
install(PROGRAMS clang-format-diff.py
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
COMPONENT clang-format)
install(PROGRAMS clang-format-sublime.py
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
COMPONENT clang-format)
install(PROGRAMS clang-format.el
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
COMPONENT clang-format)
install(PROGRAMS clang-format.py
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
COMPONENT clang-format)
install(PROGRAMS git-clang-format
- DESTINATION bin
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT clang-format)
diff --git a/tools/clang-func-mapping/CMakeLists.txt b/tools/clang-func-mapping/CMakeLists.txt
index ae28e28d532d..8ecb2e37a8f7 100644
--- a/tools/clang-func-mapping/CMakeLists.txt
+++ b/tools/clang-func-mapping/CMakeLists.txt
@@ -20,4 +20,4 @@ target_link_libraries(clang-func-mapping
)
install(TARGETS clang-func-mapping
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/tools/clang-offload-bundler/CMakeLists.txt b/tools/clang-offload-bundler/CMakeLists.txt
index 8718015be76a..7a038f39622e 100644
--- a/tools/clang-offload-bundler/CMakeLists.txt
+++ b/tools/clang-offload-bundler/CMakeLists.txt
@@ -22,4 +22,4 @@ target_link_libraries(clang-offload-bundler
${CLANG_OFFLOAD_BUNDLER_LIB_DEPS}
)
-install(TARGETS clang-offload-bundler RUNTIME DESTINATION bin)
+install(TARGETS clang-offload-bundler RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/tools/clang-rename/CMakeLists.txt b/tools/clang-rename/CMakeLists.txt
index 3b3ab1540a80..9aca9ba4a2cf 100644
--- a/tools/clang-rename/CMakeLists.txt
+++ b/tools/clang-rename/CMakeLists.txt
@@ -18,8 +18,8 @@ target_link_libraries(clang-rename
)
install(PROGRAMS clang-rename.py
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
COMPONENT clang-rename)
install(PROGRAMS clang-rename.el
- DESTINATION share/clang
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/clang
COMPONENT clang-rename)
diff --git a/tools/diagtool/CMakeLists.txt b/tools/diagtool/CMakeLists.txt
index 96d1c390249c..41c762b37b76 100644
--- a/tools/diagtool/CMakeLists.txt
+++ b/tools/diagtool/CMakeLists.txt
@@ -21,7 +21,7 @@ target_link_libraries(diagtool
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(TARGETS diagtool
COMPONENT diagtool
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-diagtool
diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
index e539c8308e75..4e1fbccea35d 100644
--- a/tools/libclang/CMakeLists.txt
+++ b/tools/libclang/CMakeLists.txt
@@ -130,7 +130,7 @@ endif()
if(INTERNAL_INSTALL_PREFIX)
set(LIBCLANG_HEADERS_INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/include")
else()
- set(LIBCLANG_HEADERS_INSTALL_DESTINATION include)
+ set(LIBCLANG_HEADERS_INSTALL_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
install(DIRECTORY ../../include/clang-c
diff --git a/tools/scan-build/CMakeLists.txt b/tools/scan-build/CMakeLists.txt
index 380379300b09..adfd58ed5f7d 100644
--- a/tools/scan-build/CMakeLists.txt
+++ b/tools/scan-build/CMakeLists.txt
@@ -41,7 +41,7 @@ if(CLANG_INSTALL_SCANBUILD)
${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
- install(PROGRAMS bin/${BinFile} DESTINATION bin)
+ install(PROGRAMS bin/${BinFile} DESTINATION ${CMAKE_INSTALL_BINDIR})
endforeach()
foreach(LibexecFile ${LibexecFiles})
@@ -53,7 +53,7 @@ if(CLANG_INSTALL_SCANBUILD)
${CMAKE_BINARY_DIR}/libexec/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
- install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
+ install(PROGRAMS libexec/${LibexecFile} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
endforeach()
foreach(ManPage ${ManPages})
@@ -77,7 +77,7 @@ if(CLANG_INSTALL_SCANBUILD)
${CMAKE_BINARY_DIR}/share/scan-build/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
- install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
+ install(FILES share/scan-build/${ShareFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-build)
endforeach()
add_custom_target(scan-build ALL DEPENDS ${Depends})
diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt
index b305ca562a72..554bcb379061 100644
--- a/tools/scan-view/CMakeLists.txt
+++ b/tools/scan-view/CMakeLists.txt
@@ -21,7 +21,7 @@ if(CLANG_INSTALL_SCANVIEW)
${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
- install(PROGRAMS bin/${BinFile} DESTINATION bin)
+ install(PROGRAMS bin/${BinFile} DESTINATION ${CMAKE_INSTALL_BINDIR})
endforeach()
foreach(ShareFile ${ShareFiles})
@@ -33,7 +33,7 @@ if(CLANG_INSTALL_SCANVIEW)
${CMAKE_BINARY_DIR}/share/scan-view/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
- install(FILES share/${ShareFile} DESTINATION share/scan-view)
+ install(FILES share/${ShareFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-view)
endforeach()
add_custom_target(scan-view ALL DEPENDS ${Depends})
diff --git a/utils/hmaptool/CMakeLists.txt b/utils/hmaptool/CMakeLists.txt
index 5573009d343a..24b3a90f233f 100644
--- a/utils/hmaptool/CMakeLists.txt
+++ b/utils/hmaptool/CMakeLists.txt
@@ -9,7 +9,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HM
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL})
list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
-install(PROGRAMS ${CLANG_HMAPTOOL} DESTINATION bin)
+install(PROGRAMS ${CLANG_HMAPTOOL} DESTINATION ${CMAKE_INSTALL_BINDIR})
add_custom_target(hmaptool ALL DEPENDS ${Depends})
set_target_properties(hmaptool PROPERTIES FOLDER "Utils")

View file

@ -1,227 +0,0 @@
commit a5cacb5ba7f1f18e7bb6f6709e42683eeb7e6470
Author: Sterling Augustine <saugustine@google.com>
Date: Tue Mar 19 20:01:59 2019 +0000
Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]
"clang++ hello.cc --rtlib=compiler-rt"
now can works without specifying additional unwind or exception
handling libraries.
This reworked version of the feature no longer modifies today's default
unwind library for compiler-rt: which is nothing. Rather, a user
can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring
the compiler.
This should address the issues from the previous version.
Update tests for new --unwindlib semantics.
Differential Revision: https://reviews.llvm.org/D59109
llvm-svn: 356508
diff --git clang/CMakeLists.txt clang/CMakeLists.txt
index 52b881939499..2c3fb62f6e73 100644
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -244,6 +244,24 @@ if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR
"Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE)
endif()
+set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
+ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)")
+if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
+ if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
+ set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
+ elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind")
+ set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
+ endif()
+endif()
+
+if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR
+ CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR
+ CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
+ message(WARNING "Resetting default unwindlib to use platform default")
+ set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
+ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE)
+endif()
+
set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
"Default objcopy executable to use.")
diff --git clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Basic/DiagnosticDriverKinds.td
index 7f75f45c6578..7e1bb33b5cef 100644
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -52,6 +52,10 @@ def err_drv_invalid_rtlib_name : Error<
"invalid runtime library name in argument '%0'">;
def err_drv_unsupported_rtlib_for_platform : Error<
"unsupported runtime library '%0' for platform '%1'">;
+def err_drv_invalid_unwindlib_name : Error<
+ "invalid unwind library name in argument '%0'">;
+def err_drv_incompatible_unwindlib : Error<
+ "--rtlib=libgcc requires --unwindlib=libgcc">;
def err_drv_invalid_stdlib_name : Error<
"invalid library name in argument '%0'">;
def err_drv_invalid_output_with_multiple_archs : Error<
diff --git clang/include/clang/Config/config.h.cmake clang/include/clang/Config/config.h.cmake
index 1d624450b9d9..2d4cb747e87e 100644
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -23,6 +23,9 @@
/* Default runtime library to use. */
#define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
+/* Default unwind library to use. */
+#define CLANG_DEFAULT_UNWINDLIB "${CLANG_DEFAULT_UNWINDLIB}"
+
/* Default objcopy to use */
#define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}"
diff --git clang/include/clang/Driver/Options.td clang/include/clang/Driver/Options.td
index 601aa8744967..0e74a2d36dea 100644
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2428,6 +2428,8 @@ def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
}]>;
def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
+def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
+ HelpText<"Unwind library to use">, Values<"libgcc,unwindlib,platform">;
def sub__library : JoinedOrSeparate<["-"], "sub_library">;
def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">;
def system_header_prefix : Joined<["--"], "system-header-prefix=">,
diff --git clang/include/clang/Driver/ToolChain.h clang/include/clang/Driver/ToolChain.h
index 2f9c2c190e32..d5b131bcf112 100644
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -99,6 +99,12 @@ public:
RLT_Libgcc
};
+ enum UnwindLibType {
+ UNW_None,
+ UNW_CompilerRT,
+ UNW_Libgcc
+ };
+
enum RTTIMode {
RM_Enabled,
RM_Disabled,
@@ -352,6 +358,10 @@ public:
return ToolChain::CST_Libstdcxx;
}
+ virtual UnwindLibType GetDefaultUnwindLibType() const {
+ return ToolChain::UNW_None;
+ }
+
virtual std::string getCompilerRTPath() const;
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
@@ -484,6 +494,10 @@ public:
// given compilation arguments.
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
+ // GetUnwindLibType - Determine the unwind library type to use with the
+ // given compilation arguments.
+ virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const;
+
/// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
/// the include paths to use for the given C++ standard library type.
virtual void
diff --git clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChain.cpp
index cf3db34688df..d980dd5d23fb 100644
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -665,6 +665,33 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
return GetDefaultRuntimeLibType();
}
+ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
+ const ArgList &Args) const {
+ const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
+ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;
+
+ if (LibName == "none")
+ return ToolChain::UNW_None;
+ else if (LibName == "platform" || LibName == "") {
+ ToolChain::RuntimeLibType RtLibType = GetRuntimeLibType(Args);
+ if (RtLibType == ToolChain::RLT_CompilerRT)
+ return ToolChain::UNW_None;
+ else if (RtLibType == ToolChain::RLT_Libgcc)
+ return ToolChain::UNW_Libgcc;
+ } else if (LibName == "libunwind") {
+ if (GetRuntimeLibType(Args) == RLT_Libgcc)
+ getDriver().Diag(diag::err_drv_incompatible_unwindlib);
+ return ToolChain::UNW_CompilerRT;
+ } else if (LibName == "libgcc")
+ return ToolChain::UNW_Libgcc;
+
+ if (A)
+ getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
+ << A->getAsString(Args);
+
+ return GetDefaultUnwindLibType();
+}
+
ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
diff --git clang/test/Driver/compiler-rt-unwind.c clang/test/Driver/compiler-rt-unwind.c
new file mode 100644
index 000000000000..00024dfa7ed3
--- /dev/null
+++ clang/test/Driver/compiler-rt-unwind.c
@@ -0,0 +1,49 @@
+// General tests that the driver handles combinations of --rtlib=XXX and
+// --unwindlib=XXX properly.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-EMPTY %s
+// RTLIB-EMPTY: "{{.*}}lgcc"
+// RTLIB-EMPTY: "{{.*}}-lgcc_s"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-GCC %s
+// RTLIB-GCC: "{{.*}}lgcc"
+// RTLIB-GCC: "{{.*}}lgcc_s"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT %s
+// RTLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC %s
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}lgcc_s"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \
+// RUN: -static --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC %s
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}lgcc_eh"
+//
+// RUN: not %clang -no-canonical-prefixes %s -o %t.o 2> %t.err \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
+// RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc"

View file

@ -1,38 +0,0 @@
diff -ur compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake
--- compiler-rt-7.1.0.src/cmake/builtin-config-ix.cmake 2018-05-25 06:36:27.000000000 +0900
+++ compiler-rt-7.1.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-09 20:26:33.030608692 +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-7.1.0.src/lib/builtins/CMakeLists.txt compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt
--- compiler-rt-7.1.0.src/lib/builtins/CMakeLists.txt 2018-07-31 03:18:59.000000000 +0900
+++ compiler-rt-7.1.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-09 20:27:38.893409318 +0900
@@ -453,6 +453,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
@@ -563,12 +564,12 @@
set(_arch ${arch})
if("${arch}" STREQUAL "armv6m")
set(_arch "arm|armv6m")
- elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
+ elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$")
set(_arch "arm")
endif()
# 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)

View file

@ -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")

View file

@ -1,117 +0,0 @@
{ lib, stdenv, llvm_meta, version, fetch, cmake, python3, libllvm, libcxxabi
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
}:
let
useLLVM = stdenv.hostPlatform.useLLVM or false;
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
haveLibc = stdenv.cc.libc != null;
inherit (stdenv.hostPlatform) isMusl;
in
stdenv.mkDerivation {
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
inherit version;
src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5";
nativeBuildInputs = [ cmake python3 libllvm.dev ];
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
env.NIX_CFLAGS_COMPILE = toString [
"-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 (useLLVM || bareMetal || isMusl) [
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
] ++ lib.optionals (useLLVM || bareMetal) [
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
"-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"
#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"
] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
];
outputs = [ "out" "dev" ];
patches = [
# https://github.com/llvm/llvm-project/commit/947f9692440836dcb8d88b74b69dd379d85974ce
../../common/compiler-rt/glibc.patch
../../common/compiler-rt/7-12-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
./gnu-install-dirs.patch
../../common/compiler-rt/libsanitizer-no-cyclades-9.patch
] ++ lib.optional (useLLVM) ./crtbegin-and-end.patch
++ lib.optional stdenv.hostPlatform.isAarch32 ./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/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>" ""
'';
preConfigure = lib.optionalString (useLLVM && !haveLibc) ''
cmakeFlagsArray+=(-DCMAKE_C_FLAGS="-nodefaultlibs -ffreestanding")
'';
# 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
'' + lib.optionalString doFakeLibgcc ''
ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a
'';
meta = llvm_meta // {
homepage = "https://compiler-rt.llvm.org/";
description = "Compiler runtime libraries";
longDescription = ''
The compiler-rt project provides highly tuned implementations of the
low-level code generator support routines like "__fixunsdfdi" and other
calls generated when a target doesn't have a short sequence of native
instructions to implement a core IR operation. It also provides
implementations of run-time libraries for dynamic testing tools such as
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
'';
# "All of the code in the compiler-rt project is dual licensed under the MIT
# license and the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64;
};
}

View file

@ -1,117 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 86ca2b3ef74b..555103bd97fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,7 @@ cmake_minimum_required(VERSION 3.4.3)
# Check if compiler-rt is built as a standalone project.
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD)
project(CompilerRT C CXX ASM)
+ include(GNUInstallDirs)
set(COMPILER_RT_STANDALONE_BUILD TRUE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index cd4c704fc824..5abcd1260381 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -478,7 +478,7 @@ macro(add_compiler_rt_resource_file target_name file_name component)
add_custom_target(${target_name} DEPENDS ${dst_file})
# Install in Clang resource directory.
install(FILES ${file_name}
- DESTINATION ${COMPILER_RT_INSTALL_PATH}/share
+ DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_DATADIR}
COMPONENT ${component})
add_dependencies(${component} ${target_name})
@@ -495,7 +495,7 @@ macro(add_compiler_rt_script name)
add_custom_target(${name} DEPENDS ${dst})
install(FILES ${dst}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
- DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin)
+ DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_BINDIR})
endmacro(add_compiler_rt_script src name)
# Builds custom version of libc++ and installs it in <prefix>.
diff --git a/cmake/Modules/CompilerRTDarwinUtils.cmake b/cmake/Modules/CompilerRTDarwinUtils.cmake
index 04cc955980fa..a99f6dfb2f82 100644
--- a/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -377,7 +377,7 @@ macro(darwin_add_embedded_builtin_libraries)
set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
- ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
+ ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_LIBDIR}/macho_embedded)
set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
set(CFLAGS_i386 "-march=pentium")
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index e5651718fa34..d95cfc984a85 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -330,7 +330,7 @@ endfunction()
function(get_compiler_rt_install_dir arch install_dir)
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
get_compiler_rt_target(${arch} target)
- set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/${target}/lib PARENT_SCOPE)
+ set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/${target}/${CMAKE_INSTALL_FULL_LIBDIR} PARENT_SCOPE)
else()
set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE)
endif()
diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake
index 91fe2494b476..b59a0ffc69f4 100644
--- a/cmake/base-config-ix.cmake
+++ b/cmake/base-config-ix.cmake
@@ -53,11 +53,11 @@ if (LLVM_TREE_AVAILABLE)
else()
# Take output dir and install path from the user.
set(COMPILER_RT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH
- "Path where built compiler-rt libraries should be stored.")
+ "Path where built compiler-rt build artifacts should be stored.")
set(COMPILER_RT_EXEC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH
"Path where built compiler-rt executables should be stored.")
- set(COMPILER_RT_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH
- "Path where built compiler-rt libraries should be installed.")
+ set(COMPILER_RT_INSTALL_PATH "" CACHE PATH
+ "Prefix where built compiler-rt artifacts should be installed, comes before CMAKE_INSTALL_PREFIX.")
option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." OFF)
option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" OFF)
# Use a host compiler to compile/link tests.
@@ -85,7 +85,7 @@ else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
set(COMPILER_RT_LIBRARY_OUTPUT_DIR
${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
set(COMPILER_RT_LIBRARY_INSTALL_DIR
- ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+ ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_LIBDIR}/${COMPILER_RT_OS_DIR})
endif()
if(APPLE)
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index c4b93b89a30c..3913dc3a1ee6 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -48,12 +48,12 @@ set_target_properties(compiler-rt-headers PROPERTIES FOLDER "Compiler-RT Misc")
install(FILES ${SANITIZER_HEADERS}
COMPONENT compiler-rt-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer)
+ DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_INCLUDEDIR}/sanitizer)
# Install xray headers.
install(FILES ${XRAY_HEADERS}
COMPONENT compiler-rt-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/xray)
+ DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_INCLUDEDIR}/xray)
if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDEs.
add_custom_target(install-compiler-rt-headers
diff --git a/lib/dfsan/CMakeLists.txt b/lib/dfsan/CMakeLists.txt
index b3ae713cf02c..52b364b900f5 100644
--- a/lib/dfsan/CMakeLists.txt
+++ b/lib/dfsan/CMakeLists.txt
@@ -54,4 +54,4 @@ add_custom_command(OUTPUT ${dfsan_abilist_filename}
DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
add_dependencies(dfsan dfsan_abilist)
install(FILES ${dfsan_abilist_filename}
- DESTINATION ${COMPILER_RT_INSTALL_PATH}/share)
+ DESTINATION ${COMPILER_RT_INSTALL_PATH}/${CMAKE_INSTALL_FULL_DATADIR})

View file

@ -1,273 +0,0 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
, preLibcCrossHeaders
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
, targetLlvm
# This is the default binutils, but with *this* version of LLD rather
# than the default LLVM version's, if LLD is the choice. We use these for
# the `useLLVM` bootstrapping below.
, bootBintoolsNoLibc ?
if stdenv.targetPlatform.linker == "lld"
then null
else pkgs.bintoolsNoLibc
, bootBintools ?
if stdenv.targetPlatform.linker == "lld"
then null
else pkgs.bintools
}:
let
release_version = "7.1.0";
version = release_version; # differentiating these is important for rc's
fetch = name: sha256: fetchurl {
url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz";
inherit sha256;
};
clang-tools-extra_src = fetch "clang-tools-extra" "0lb4kdh7j2fhfz8kd6iv5df7m3pikiryk1vvwsf87spc90n09q0w";
inherit (import ../common/common-let.nix { inherit lib release_version; }) llvm_meta;
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
mkExtraBuildCommands0 = cc: ''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'';
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
'';
bintoolsNoLibc' =
if bootBintoolsNoLibc == null
then tools.bintoolsNoLibc
else bootBintoolsNoLibc;
bintools' =
if bootBintools == null
then tools.bintools
else bootBintools;
in {
libllvm = callPackage ./llvm {
inherit llvm_meta;
};
# `llvm` historically had the binaries. When choosing an output explicitly,
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
llvm = tools.libllvm;
libllvm-polly = callPackage ./llvm {
inherit llvm_meta;
enablePolly = true;
};
llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; };
libclang = callPackage ./clang {
inherit clang-tools-extra_src llvm_meta;
};
clang-unwrapped = tools.libclang;
clang-polly-unwrapped = callPackage ./clang {
inherit llvm_meta;
inherit clang-tools-extra_src;
libllvm = tools.libllvm-polly;
enablePolly = true;
};
llvm-manpages = lowPrio (tools.libllvm.override {
enableManpages = true;
python3 = pkgs.python3; # don't use python-boot
});
clang-manpages = lowPrio (tools.libclang.override {
enableManpages = true;
python3 = pkgs.python3; # don't use python-boot
});
# pick clang appropriate for package set we are targeting
clang =
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
else if (pkgs.targetPackages.stdenv or 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 = [
libcxx.cxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld {
inherit llvm_meta;
};
lldb = callPackage ./lldb {
inherit llvm_meta;
};
# 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
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools-unwrapped = callPackage ../common/bintools.nix { };
bintoolsNoLibc = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
libc = preLibcCrossHeaders;
};
bintools = wrapBintoolsWith {
bintools = tools.bintools-unwrapped;
};
clangUseLLVM = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
libcxx.cxxabi
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 && stdenv.targetPlatform.useLLVM or false) ''
echo "-lunwind" >> $out/nix-support/cc-ldflags
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
clangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = 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;
};
clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = bintoolsNoLibc';
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;
};
clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands0 cc;
};
clangNoCompilerRtWithLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = bintools';
extraPackages = [ ];
extraBuildCommands = mkExtraBuildCommands0 cc;
};
});
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
else stdenv;
};
compiler-rt-no-libc = callPackage ./compiler-rt {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
else stdenv;
};
# N.B. condition is safe because without useLLVM both are the same.
compiler-rt =
if stdenv.hostPlatform.isAndroid || (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isDarwin)
then libraries.compiler-rt-libc
else libraries.compiler-rt-no-libc;
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libcxx {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
};
libcxxabi = callPackage ./libcxxabi {
inherit llvm_meta;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
};
libunwind = callPackage ./libunwind {
inherit llvm_meta;
inherit (buildLlvmTools) llvm;
stdenv = if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildLlvmTools.clangNoLibcxx
else stdenv;
};
openmp = callPackage ./openmp {
inherit llvm_meta targetLlvm;
};
});
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
in { inherit tools libraries release_version; } // (noExtend libraries) // (noExtend tools)

View file

@ -1,89 +0,0 @@
{ lib, stdenv, llvm_meta, fetch, cmake, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt
, enableShared ? !stdenv.hostPlatform.isStatic
}:
assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi";
stdenv.mkDerivation {
pname = "libcxx";
inherit version;
src = fetch "libcxx" "0kmhcapm2cjwalyiqasj9dmqbw59mcwdl8fgl951wg7ax84b8hj4";
postUnpack = ''
unpackFile ${libcxxabi.src}
export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
'';
outputs = [ "out" "dev" ];
patches = [
./gnu-install-dirs.patch
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
# Prevent errors like "error: 'foo' is unavailable: introduced in macOS yy.zz"
postPatch = ''
substituteInPlace include/__config \
--replace "# define _LIBCPP_USE_AVAILABILITY_APPLE" ""
'';
prePatch = ''
substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
'';
preConfigure = ''
# Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR")
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py
'';
nativeBuildInputs = [ cmake ]
++ lib.optional stdenv.hostPlatform.isMusl python3
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
buildInputs = [ cxxabi ];
cmakeFlags = [
"-DLIBCXX_LIBCPPABI_VERSION=2"
"-DLIBCXX_CXX_ABI=${cxxabi.pname}"
] ++ lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"
++ lib.optional (cxxabi.pname == "libcxxabi") "-DLIBCXX_LIBCXXABI_LIB_PATH=${cxxabi}/lib"
++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" ;
preInstall = lib.optionalString (stdenv.isDarwin) ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))
installName="$out/lib/$baseName"
abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/')
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file
done
done
'';
passthru = {
isLLVM = true;
inherit cxxabi;
};
meta = llvm_meta // {
homepage = "https://libcxx.llvm.org/";
description = "C++ standard library";
longDescription = ''
libc++ is an implementation of the C++ standard library, targeting C++11,
C++14 and above.
'';
# "All of the code in libc++ is dual licensed under the MIT license and the
# UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,72 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index acb49565ce97..6a863926cbca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,8 @@ set(CMAKE_MODULE_PATH
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(libcxx CXX C)
+ include(GNUInstallDirs)
+
set(PACKAGE_NAME libcxx)
set(PACKAGE_VERSION 7.0.0)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake
index 1c19d7e01af7..9c8aee8e8bb7 100644
--- a/cmake/Modules/HandleLibCXXABI.cmake
+++ b/cmake/Modules/HandleLibCXXABI.cmake
@@ -59,7 +59,7 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
if (LIBCXX_INSTALL_HEADERS)
install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
- DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dstdir}
+ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}
COMPONENT cxx-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index d9def18d725c..16494dacaf6f 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -243,7 +243,7 @@ if (LIBCXX_INSTALL_HEADERS)
foreach(file ${files})
get_filename_component(dir ${file} DIRECTORY)
install(FILES ${file}
- DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir}
+ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dir}
COMPONENT cxx-headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
@@ -252,7 +252,7 @@ if (LIBCXX_INSTALL_HEADERS)
if (LIBCXX_NEEDS_SITE_CONFIG)
# Install the generated header as __config.
install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
- DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1
+ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}${CMAKE_INSTALL_INCLUDEDIR}/c++/v1
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
RENAME __config
COMPONENT cxx-headers)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index e068edc8a7af..b63ad92d1d78 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -399,8 +399,8 @@ if (LIBCXX_INSTALL_LIBRARY)
set(experimental_lib cxx_experimental)
endif()
install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${filesystem_lib} ${experimental_lib}
- LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
- ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
+ LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
+ ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
)
# NOTE: This install command must go after the cxx install command otherwise
# it will not be executed after the library symlinks are installed.
@@ -408,7 +408,7 @@ if (LIBCXX_INSTALL_LIBRARY)
# Replace the libc++ filename with $<TARGET_LINKER_FILE:cxx>
# after we required CMake 3.0.
install(FILES "${LIBCXX_LIBRARY_DIR}/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}"
- DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX}
+ DESTINATION ${LIBCXX_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX}
COMPONENT libcxx)
endif()
endif()

View file

@ -1,89 +0,0 @@
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, fetchpatch
, standalone ? stdenv.hostPlatform.useLLVM or false
, withLibunwind ? !stdenv.isDarwin && !stdenv.hostPlatform.isWasm
# on musl the shared objects don't build
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation {
pname = "libcxxabi";
inherit version;
src = fetch "libcxxabi" "1zcqxsdjhawgz1cvpk07y3jl6fg9p3ay4nl69zsirqb2ghgyhhb2";
outputs = [ "out" "dev" ];
postUnpack = ''
unpackFile ${libcxx.src}
unpackFile ${llvm.src}
cmakeFlagsArray=($cmakeFlagsArray -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*) )
'' + lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -d $(ls -d libcxx-*) -i ${../../libcxx-0001-musl-hacks.patch}
'' + lib.optionalString (!stdenv.cc.isClang) ''
pushd libcxx-*
patch -p2 < ${fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/76ccec07b4fa0cc68dfd07d557e7fb661804a468.patch";
sha256 = "1lgzkfkp7qinfc6gd8x5di1iq1gqdv81249c6f02chn9q122sbq1";
}}
popd
'';
patches = [
./gnu-install-dirs.patch
];
nativeBuildInputs = [ cmake ];
buildInputs = lib.optional withLibunwind libunwind;
cmakeFlags = lib.optionals standalone [
"-DLLVM_ENABLE_LIBCXX=ON"
] ++ lib.optionals (standalone && withLibunwind) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";
preInstall = lib.optionalString stdenv.isDarwin ''
for file in lib/*.dylib; do
if [ -L "$file" ]; then continue; fi
# Fix up the install name. Preserve the basename, just replace the path.
installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))"
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
${stdenv.cc.targetPrefix}install_name_tool -id $installName $file
# cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes
# libcxxabi to sometimes link against a different version of itself.
# Here we simply make that second reference point to ourselves.
for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do
${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file
done
done
'';
postInstall = ''
mkdir -p "$dev/include"
install -m 644 ../include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include"
'';
passthru = {
libName = "c++abi";
};
meta = llvm_meta // {
homepage = "https://libcxxabi.llvm.org/";
description = "Provides C++ standard library support";
longDescription = ''
libc++abi is a new implementation of low level support for a standard C++ library.
'';
# "All of the code in libc++abi is dual licensed under the MIT license and
# the UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ];
};
}

View file

@ -1,28 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6648ede1f59..55a8f17ca5e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,8 @@ set(CMAKE_MODULE_PATH
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(libcxxabi CXX C)
+ include(GNUInstallDirs)
+
set(PACKAGE_NAME libcxxabi)
set(PACKAGE_VERSION 7.0.0svn)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 776c51294330..314b45feac69 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -195,8 +195,8 @@ add_custom_target(cxxabi DEPENDS ${LIBCXXABI_BUILD_TARGETS})
if (LIBCXXABI_INSTALL_LIBRARY)
install(TARGETS ${LIBCXXABI_INSTALL_TARGETS}
- LIBRARY DESTINATION ${LIBCXXABI_INSTALL_PREFIX}lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi
- ARCHIVE DESTINATION ${LIBCXXABI_INSTALL_PREFIX}lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi
+ LIBRARY DESTINATION ${LIBCXXABI_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi
+ ARCHIVE DESTINATION ${LIBCXXABI_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi
)
endif()

View file

@ -1,53 +0,0 @@
{ lib, stdenv, llvm_meta, version, fetch, fetchpatch, cmake, llvm
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
src = fetch pname "035dsxs10nyiqd00q07yycvmkjl01yz4jdlrjvmch8klxg4pyjhp";
postUnpack = ''
unpackFile ${llvm.src}
cmakeFlagsArray=($cmakeFlagsArray -DLLVM_PATH=$PWD/$(ls -d llvm-*))
'';
patches = [
./gnu-install-dirs.patch
] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
# removes use of `new` that require libc++
(fetchpatch {
url = "https://github.com/llvm-mirror/libunwind/commit/34a45c630d4c79af403661d267db42fbe7de1178.patch";
sha256 = "0n0pv6jvcky8pn3srhrf9x5kbnd0d2kia9xlx2g590f5q0bgwfhv";
})
# cleans up remaining libc++ dependencies (mostly header inclusions)
(fetchpatch {
url = "https://github.com/llvm-mirror/libunwind/commit/e050272d2eb57eb4e56a37b429a61df2ebb8aa3e.patch";
sha256 = "170mwmj0wf40iyk1kzdpaiy36rz9n8dpl881h4h7s5da0rh51xya";
includes = [ "src/libunwind.cpp" "src/UnwindCursor.hpp" ];
})
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optionals (!enableShared) [
"-DLIBUNWIND_ENABLE_SHARED=OFF"
] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLLVM_ENABLE_LIBCXX=ON"
];
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -1,28 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e48d713837a..05483c367bd1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,8 @@ set(CMAKE_MODULE_PATH
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(libunwind)
+ include(GNUInstallDirs)
+
# Rely on llvm-config.
set(CONFIG_OUTPUT)
if(NOT LLVM_CONFIG_PATH)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 937159e2cb86..07f8b936e7e5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -141,8 +141,8 @@ add_custom_target(unwind DEPENDS ${LIBUNWIND_BUILD_TARGETS})
if (LIBUNWIND_INSTALL_LIBRARY)
install(TARGETS ${LIBUNWIND_INSTALL_TARGETS}
- LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind
- ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind)
+ LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind
+ ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind)
endif()
if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)

View file

@ -1,46 +0,0 @@
{ lib, stdenv, llvm_meta
, buildLlvmTools
, fetch
, cmake
, libxml2
, libllvm
, version
}:
stdenv.mkDerivation rec {
pname = "lld";
inherit version;
src = fetch pname "0rsqb7zcnij5r5ipfhr129j7skr5n9pyr388kjpqwh091952f3x1";
patches = [
./gnu-install-dirs.patch
];
nativeBuildInputs = [ cmake ];
buildInputs = [ libllvm libxml2 ];
cmakeFlags = [
"-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
];
# Musl's default stack size is too small for lld to be able to link Firefox.
LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152";
outputs = [ "out" "lib" "dev" ];
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker (unwrapped)";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), and Mach-O (macOS)
in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}

View file

@ -1,68 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e2fbdbfbbb47..d601b231ebb8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(LLD_BUILT_STANDALONE TRUE)
+ include(GNUInstallDirs)
+
find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary")
if(NOT LLVM_CONFIG_PATH)
message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH")
@@ -203,7 +205,7 @@ include_directories(BEFORE
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake
index fa48b428d26b..e7967aad3ceb 100644
--- a/cmake/modules/AddLLD.cmake
+++ b/cmake/modules/AddLLD.cmake
@@ -20,9 +20,9 @@ macro(add_lld_library name)
install(TARGETS ${name}
COMPONENT ${name}
${export_to_lldtargets}
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- RUNTIME DESTINATION bin)
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
@@ -54,7 +54,7 @@ macro(add_lld_tool name)
install(TARGETS ${name}
${export_to_lldtargets}
- RUNTIME DESTINATION bin
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT ${name})
if(NOT CMAKE_CONFIGURATION_TYPES)
@@ -69,5 +69,5 @@ endmacro()
macro(add_lld_symlink name dest)
add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
# Always generate install targets
- llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+ llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
endmacro()
diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt
index d8829493fc22..df748a0e749b 100644
--- a/tools/lld/CMakeLists.txt
+++ b/tools/lld/CMakeLists.txt
@@ -16,7 +16,7 @@ target_link_libraries(lld
)
install(TARGETS lld
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if(NOT LLD_SYMLINKS_TO_CREATE)
set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld wasm-ld)

View file

@ -1,95 +0,0 @@
{ lib, stdenv, llvm_meta
, fetch
, cmake
, zlib
, ncurses
, swig
, which
, libedit
, libxml2
, libllvm
, libclang
, perl
, python3
, version
, darwin
}:
stdenv.mkDerivation rec {
pname = "lldb";
inherit version;
src = fetch "lldb" "0klsscg1sczc4nw2l53xggi969k361cng2sjjrfp3bv4g5x14s4v";
patches = [
./gnu-install-dirs.patch
];
postPatch = ''
# Fix up various paths that assume llvm and clang are installed in the same place
sed -i 's,".*ClangConfig.cmake","${libclang.dev}/lib/cmake/clang/ClangConfig.cmake",' \
cmake/modules/LLDBStandalone.cmake
sed -i 's,".*tools/clang/include","${libclang.dev}/include",' \
cmake/modules/LLDBStandalone.cmake
sed -i 's,"$.LLVM_LIBRARY_DIR.",${libllvm.lib}/lib ${libclang.lib}/lib,' \
cmake/modules/LLDBStandalone.cmake
sed -i -e 's,message(SEND_ERROR "Cannot find debugserver on system."),,' \
-e 's,string(STRIP ''${XCODE_DEV_DIR} XCODE_DEV_DIR),,' \
tools/debugserver/source/CMakeLists.txt
# Fix /usr/bin references for sandboxed builds.
patchShebangs scripts
'';
outputs = [ "out" "lib" "dev" ];
nativeBuildInputs = [
cmake perl python3 which swig
];
buildInputs = [
ncurses zlib libedit libxml2 libllvm
] ++ lib.optionals stdenv.isDarwin [
darwin.libobjc
darwin.apple_sdk.libs.xpc
darwin.apple_sdk.frameworks.Foundation
darwin.bootstrap_cmds
darwin.apple_sdk.frameworks.Carbon
darwin.apple_sdk.frameworks.Cocoa
darwin.apple_sdk.frameworks.DebugSymbols
];
CXXFLAGS = "-fno-rtti";
hardeningDisable = [ "format" ];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-I${libxml2.dev}/include/libxml2";
cmakeFlags = [
"-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}"
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
"-DSKIP_DEBUGSERVER=ON"
] ++ lib.optionals doCheck [
"-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
];
doCheck = false;
postInstall = ''
mkdir -p $out/share/man/man1
cp ../docs/lldb.1 $out/share/man/man1/
'';
meta = llvm_meta // {
homepage = "https://lldb.llvm.org/";
description = "A next-generation high-performance debugger";
longDescription = ''
LLDB is a next generation, high-performance debugger. It is built as a set
of reusable components which highly leverage existing libraries in the
larger LLVM Project, such as the Clang expression parser and LLVM
disassembler.
'';
# never built on aarch64-darwin since first introduction in nixpkgs
broken = stdenv.isDarwin && stdenv.isAarch64;
};
}

View file

@ -1,76 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 00ddcdc1488f..af2aa238939a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,8 @@ set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)
+include(GNUInstallDirs)
+
include(LLDBStandalone)
include(LLDBConfig)
include(AddLLDB)
diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake
index 129a5ef7500d..fb3fb3ce655c 100644
--- a/cmake/modules/AddLLDB.cmake
+++ b/cmake/modules/AddLLDB.cmake
@@ -56,14 +56,14 @@ function(add_lldb_library name)
endif()
install(TARGETS ${name}
COMPONENT ${name}
- RUNTIME DESTINATION bin
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${out_dir}
ARCHIVE DESTINATION ${out_dir})
else()
install(TARGETS ${name}
COMPONENT ${name}
- 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})
endif()
if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
@@ -121,7 +121,7 @@ function(add_lldb_executable name)
endif()
if(ARG_GENERATE_INSTALL)
- set(out_dir "bin")
+ set(out_dir "${CMAKE_INSTALL_BINDIR}")
if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE)
set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR})
endif()
diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake
index dae6e365da38..ef272d5de5c0 100644
--- a/cmake/modules/LLDBConfig.cmake
+++ b/cmake/modules/LLDBConfig.cmake
@@ -278,7 +278,7 @@ include_directories(BEFORE
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
COMPONENT lldb-headers
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
@@ -288,7 +288,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
COMPONENT lldb-headers
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
diff --git a/tools/intel-features/CMakeLists.txt b/tools/intel-features/CMakeLists.txt
index b5316540fdf3..3c3c882d503f 100644
--- a/tools/intel-features/CMakeLists.txt
+++ b/tools/intel-features/CMakeLists.txt
@@ -64,4 +64,4 @@ if (NOT LLDB_DISABLE_PYTHON AND LLDB_BUILD_INTEL_PT)
endif()
install(TARGETS lldbIntelFeatures
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})

View file

@ -1,332 +0,0 @@
{ lib, stdenv, llvm_meta
, pkgsBuildBuild
, fetch
, fetchpatch
, cmake
, python3
, libffi
, enableGoldPlugin ? libbfd.hasPluginAPI
, libbfd
, libpfm
, libxml2
, ncurses
, version
, release_version
, zlib
, buildLlvmTools
, debugVersion ? false
, doCheck ? stdenv.isLinux && (!stdenv.isx86_32)
&& (stdenv.hostPlatform == stdenv.buildPlatform)
, enableManpages ? false
, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
# broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
# broken for the armv7l builder
, enablePFM ? stdenv.isLinux && !stdenv.hostPlatform.isAarch
, enablePolly ? false
}:
let
inherit (lib) optional optionals optionalString;
# Used when creating a versioned symlinks of libLLVM.dylib
versionSuffixes = with lib;
let parts = splitVersion release_version; in
imap (i: _: concatStringsSep "." (take i parts)) parts;
# Ordinarily we would just the `doCheck` and `checkDeps` functionality
# `mkDerivation` gives us to manage our test dependencies (instead of breaking
# out `doCheck` as a package level attribute).
#
# Unfortunately `lit` does not forward `$PYTHONPATH` to children processes, in
# particular the children it uses to do feature detection.
#
# This means that python deps we add to `checkDeps` (which the python
# interpreter is made aware of via `$PYTHONPATH` populated by the python
# setup hook) are not picked up by `lit` which causes it to skip tests.
#
# Adding `python3.withPackages (ps: [ ... ])` to `checkDeps` also doesn't work
# because this package is shadowed in `$PATH` by the regular `python3`
# package.
#
# So, we "manually" assemble one python derivation for the package to depend
# on, taking into account whether checks are enabled or not:
python = if doCheck then
let
checkDeps = ps: with ps; [ psutil ];
in python3.withPackages checkDeps
else python3;
in stdenv.mkDerivation (rec {
pname = "llvm";
inherit version;
src = fetch "llvm" "0r1p5didv4rkgxyvbkyz671xddg6i3dxvbpsi1xxipkla0l9pk0v";
polly_src = fetch "polly" "16qkns4ab4x0azrvhy4j7cncbyb2rrbdrqj87zphvqxm5pvm8m1h";
unpackPhase = ''
unpackFile $src
mv llvm-${version}* llvm
sourceRoot=$PWD/llvm
'' + optionalString enablePolly ''
unpackFile $polly_src
mv polly-* $sourceRoot/tools/polly
'';
outputs = [ "out" "lib" "dev" "python" ];
nativeBuildInputs = [ cmake python ]
++ optional enableManpages python3.pkgs.sphinx;
buildInputs = [ libxml2 libffi ]
++ optional enablePFM libpfm; # exegesis
propagatedBuildInputs = [ ncurses zlib ];
patches = [
# backport, fix building rust crates with lto
(fetchpatch {
url = "https://github.com/llvm-mirror/llvm/commit/da1fb72bb305d6bc1f3899d541414146934bf80f.patch";
sha256 = "0p81gkhc1xhcx0hmnkwyhrn8x8l8fd24xgaj1whni29yga466dwc";
})
(fetchpatch {
url = "https://github.com/llvm-mirror/llvm/commit/cc1f2a595ead516812a6c50398f0f3480ebe031f.patch";
sha256 = "0k6k1p5yisgwx417a67s7sr9930rqh1n0zv5jvply8vjjy4b3kf8";
})
# When cross-compiling we configure llvm-config-native with an approximation
# of the flags used for the normal LLVM build. To avoid the need for building
# a native libLLVM.so (which would fail) we force llvm-config to be linked
# statically against the necessary LLVM components always.
../../llvm-config-link-static.patch
./gnu-install-dirs.patch
# Fix invalid std::string(nullptr) for GCC 12
(fetchpatch {
name = "nvptx-gcc-12.patch";
url = "https://github.com/llvm/llvm-project/commit/99e64623ec9b31def9375753491cc6093c831809.patch";
sha256 = "0zjfjgavqzi2ypqwqnlvy6flyvdz8hi1anwv0ybwnm2zqixg7za3";
stripLen = 1;
})
../../llvm-7-musl.patch
] ++ lib.optionals enablePolly [
./gnu-install-dirs-polly.patch
# Add missing isl header includess required to build LLVM 7 + Polly with clang 16.
(fetchpatch {
name = "polly-ppcg-isl-headers.patch";
url = "https://repo.or.cz/ppcg.git/patch/098ba285306114dc71497f7b51c357f69c9b4472";
hash = "sha256-c9L30rDROYAMbUSuaK9U/ixyFMlH/Sa1n+VgLODzSCQ=";
extraPrefix = "tools/polly/lib/External/ppcg/";
stripLen = 1;
})
];
postPatch = optionalString stdenv.isDarwin ''
substituteInPlace cmake/modules/AddLLVM.cmake \
--replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}" ''${extra_libdir})' ""
'' + ''
# FileSystem permissions tests fail with various special bits
substituteInPlace unittests/Support/CMakeLists.txt \
--replace "Path.cpp" ""
rm unittests/Support/Path.cpp
'' + optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -i ${../../TLI-musl.patch}
substituteInPlace unittests/Support/CMakeLists.txt \
--replace "add_subdirectory(DynamicLibrary)" ""
rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
'' + optionalString stdenv.hostPlatform.isAarch32 ''
# skip failing X86 test cases on armv7l
rm test/DebugInfo/X86/debug_addr.ll
rm test/tools/llvm-dwarfdump/X86/debug_addr.s
rm test/tools/llvm-dwarfdump/X86/debug_addr_address_size_mismatch.s
rm test/tools/llvm-dwarfdump/X86/debug_addr_dwarf4.s
rm test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
rm test/tools/llvm-dwarfdump/X86/debug_addr_version_mismatch.s
'' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
# Seems to require certain floating point hardware (NEON?)
rm test/ExecutionEngine/frem.ll
'' + ''
patchShebangs test/BugPoint/compile-custom.ll.py
'' + ''
# Tweak tests to ignore namespace part of type to support
# gcc-12: https://gcc.gnu.org/PR103598.
# The change below mangles strings like:
# CHECK-NEXT: Starting llvm::Function pass manager run.
# to:
# CHECK-NEXT: Starting {{.*}}Function pass manager run.
for f in \
test/Other/new-pass-manager.ll \
test/Other/new-pm-defaults.ll \
test/Other/new-pm-lto-defaults.ll \
test/Other/new-pm-thinlto-defaults.ll \
test/Other/pass-pipeline-parsing.ll \
test/Transforms/Inline/cgscc-incremental-invalidate.ll \
test/Transforms/Inline/clear-analyses.ll \
test/Transforms/LoopUnroll/unroll-loop-invalidation.ll \
test/Transforms/SCCP/preserve-analysis.ll \
test/Transforms/SROA/dead-inst.ll \
test/tools/gold/X86/new-pm.ll \
; do
echo "PATCH: $f"
substituteInPlace $f \
--replace 'Starting llvm::' 'Starting {{.*}}' \
--replace 'Finished llvm::' 'Finished {{.*}}'
done
'';
preConfigure = ''
# Workaround for configure flags that need to have spaces
cmakeFlagsArray+=(
-DLLVM_LIT_ARGS='-svj''${NIX_BUILD_CORES} --no-progress-bar'
)
'';
# hacky fix: created binaries need to be run before installation
preBuild = ''
mkdir -p $out/
ln -sv $PWD/lib $out
'';
cmakeBuildType = if debugVersion then "Debug" else "Release";
cmakeFlags = with stdenv; let
# These flags influence llvm-config's BuildVariables.inc in addition to the
# general build. We need to make sure these are also passed via
# CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native
# will return different results from the cross llvm-config.
#
# Some flags don't need to be repassed because LLVM already does so (like
# CMAKE_BUILD_TYPE), others are irrelevant to the result.
flagsForLlvmConfig = [
"-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/"
"-DLLVM_ENABLE_RTTI=ON"
] ++ optionals enableSharedLibraries [
"-DLLVM_LINK_LLVM_DYLIB=ON"
];
in flagsForLlvmConfig ++ [
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
"-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
"-DLLVM_ENABLE_FFI=ON"
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly"
"-DLLVM_ENABLE_DUMP=ON"
] ++ optionals enableManpages [
"-DLLVM_BUILD_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ++ optionals (enableGoldPlugin) [
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
] ++ optionals (isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false"
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
"-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen"
(
let
nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc;
nativeBintools = nativeCC.bintools.bintools;
nativeToolchainFlags = [
"-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
"-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
"-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
"-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
"-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
];
# We need to repass the custom GNUInstallDirs values, otherwise CMake
# will choose them for us, leading to wrong results in llvm-config-native
nativeInstallFlags = [
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
"-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin"
"-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include"
"-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib"
"-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec"
];
in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list="
+ lib.concatStringsSep ";" (lib.concatLists [
flagsForLlvmConfig
nativeToolchainFlags
nativeInstallFlags
])
)
];
postBuild = ''
rm -fR $out
'';
preCheck = ''
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
'';
postInstall = ''
mkdir -p $python/share
mv $out/share/opt-viewer $python/share/opt-viewer
moveToOutput "bin/llvm-config*" "$dev"
substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
--replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \
--replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \
--replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}'"$lib"'")'
''
+ optionalString (stdenv.isDarwin && enableSharedLibraries) ''
${lib.concatMapStringsSep "\n" (v: ''
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
'') versionSuffixes}
''
+ optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
'';
inherit doCheck;
checkTarget = "check-all";
requiredSystemFeatures = [ "big-parallel" ];
meta = llvm_meta // {
homepage = "https://llvm.org/";
description = "A collection of modular and reusable compiler and toolchain technologies";
longDescription = ''
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do with
traditional virtual machines. The name "LLVM" itself is not an acronym; it
is the full name of the project.
LLVM began as a research project at the University of Illinois, with the
goal of providing a modern, SSA-based compilation strategy capable of
supporting both static and dynamic compilation of arbitrary programming
languages. Since then, LLVM has grown to be an umbrella project consisting
of a number of subprojects, many of which are being used in production by
a wide variety of commercial and open source projects as well as being
widely used in academic research. Code in the LLVM project is licensed
under the "Apache 2.0 License with LLVM exceptions".
'';
};
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
buildPhase = ''
make docs-llvm-man
'';
propagatedBuildInputs = [];
installPhase = ''
make -C docs install
'';
postPatch = null;
postInstall = null;
outputs = [ "out" ];
doCheck = false;
meta = llvm_meta // {
description = "man pages for LLVM ${version}";
};
})

View file

@ -1,106 +0,0 @@
diff --git a/tools/polly/CMakeLists.txt b/tools/polly/CMakeLists.txt
index 9939097f743e..8cc538da912a 100644
--- a/tools/polly/CMakeLists.txt
+++ b/tools/polly/CMakeLists.txt
@@ -2,7 +2,11 @@
if (NOT DEFINED LLVM_MAIN_SRC_DIR)
project(Polly)
cmake_minimum_required(VERSION 3.4.3)
+endif()
+
+include(GNUInstallDirs)
+if (NOT DEFINED LLVM_MAIN_SRC_DIR)
# Where is LLVM installed?
find_package(LLVM CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
@@ -145,14 +149,14 @@ include_directories(
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY ${POLLY_BINARY_DIR}/include/
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN "CMakeFiles" EXCLUDE
diff --git a/tools/polly/cmake/CMakeLists.txt b/tools/polly/cmake/CMakeLists.txt
index 969292cd6b00..d7aea77bdd20 100644
--- a/tools/polly/cmake/CMakeLists.txt
+++ b/tools/polly/cmake/CMakeLists.txt
@@ -79,18 +79,18 @@ file(GENERATE
# Generate PollyConfig.cmake for the install tree.
unset(POLLY_EXPORTS)
-set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+set(POLLY_INSTALL_PREFIX "")
set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
+set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
if (POLLY_BUNDLED_ISL)
set(POLLY_CONFIG_INCLUDE_DIRS
- "${POLLY_INSTALL_PREFIX}/include"
- "${POLLY_INSTALL_PREFIX}/include/polly"
+ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}"
+ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}/polly"
)
else()
set(POLLY_CONFIG_INCLUDE_DIRS
- "${POLLY_INSTALL_PREFIX}/include"
+ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_INCLUDEDIR}"
${ISL_INCLUDE_DIRS}
)
endif()
@@ -100,12 +100,12 @@ endif()
foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
get_target_property(tgt_type ${tgt} TYPE)
if (tgt_type STREQUAL "EXECUTABLE")
- set(tgt_prefix "bin/")
+ set(tgt_prefix "${CMAKE_INSTALL_BINDIR}/")
else()
- set(tgt_prefix "lib/")
+ set(tgt_prefix "${CMAKE_INSTALL_LIBDIR}/")
endif()
- set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
+ set(tgt_path "${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path})
if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake
index e48203871884..5bc8a2a52541 100644
--- a/tools/polly/cmake/polly_macros.cmake
+++ b/tools/polly/cmake/polly_macros.cmake
@@ -44,8 +44,8 @@ macro(add_polly_library name)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
install(TARGETS ${name}
EXPORT LLVMExports
- 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})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endmacro(add_polly_library)
diff --git a/tools/polly/lib/External/CMakeLists.txt b/tools/polly/lib/External/CMakeLists.txt
index 8ffd984e542b..261cc19f3238 100644
--- a/tools/polly/lib/External/CMakeLists.txt
+++ b/tools/polly/lib/External/CMakeLists.txt
@@ -274,7 +274,7 @@ if (POLLY_BUNDLED_ISL)
install(DIRECTORY
${ISL_SOURCE_DIR}/include/
${ISL_BINARY_DIR}/include/
- DESTINATION include/polly
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
FILES_MATCHING
PATTERN "*.h"
PATTERN "CMakeFiles" EXCLUDE

View file

@ -1,386 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a3d3013cedcd..b298d6ef04af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -275,15 +275,21 @@ if (CMAKE_BUILD_TYPE AND
message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()
+include(GNUInstallDirs)
+
set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
-set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')")
+set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
+ "Path for binary subdirectory (defaults to 'bin')")
mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)
set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING
"Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)")
mark_as_advanced(LLVM_UTILS_INSTALL_DIR)
+set(LLVM_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/cmake/llvm" CACHE STRING
+ "Path for CMake subdirectory (defaults to lib/cmake/llvm)" )
+
# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
@@ -531,9 +537,9 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON)
option (LLVM_ENABLE_BINDINGS "Build bindings." ON)
-set(LLVM_INSTALL_DOXYGEN_HTML_DIR "share/doc/llvm/doxygen-html"
+set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html"
CACHE STRING "Doxygen-generated HTML documentation install directory")
-set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "share/doc/llvm/ocaml-html"
+set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html"
CACHE STRING "OCamldoc-generated HTML documentation install directory")
option (LLVM_BUILD_EXTERNAL_COMPILER_RT
@@ -966,7 +972,7 @@ endif()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/llvm include/llvm-c
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT llvm-headers
FILES_MATCHING
PATTERN "*.def"
@@ -978,7 +984,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
)
install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT llvm-headers
FILES_MATCHING
PATTERN "*.def"
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index c0f90ba7068d..d656156ff9c8 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -638,11 +638,11 @@ macro(add_llvm_library name)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO" OR
(LLVM_LINK_LLVM_DYLIB AND ${name} STREQUAL "LLVM"))
- set(install_dir lib${LLVM_LIBDIR_SUFFIX})
+ set(install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
if(ARG_SHARED OR BUILD_SHARED_LIBS)
if(WIN32 OR CYGWIN OR MINGW)
set(install_type RUNTIME)
- set(install_dir bin)
+ set(install_dir ${CMAKE_INSTALL_BINDIR})
else()
set(install_type LIBRARY)
endif()
@@ -684,9 +684,9 @@ macro(add_llvm_loadable_module name)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if(WIN32 OR CYGWIN)
# DLL platform
- set(dlldir "bin")
+ set(dlldir "${CMAKE_INSTALL_BINDIR}")
else()
- set(dlldir "lib${LLVM_LIBDIR_SUFFIX}")
+ set(dlldir "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
endif()
if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
@@ -698,7 +698,7 @@ macro(add_llvm_loadable_module name)
install(TARGETS ${name}
${export_to_llvmexports}
LIBRARY DESTINATION ${dlldir}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
@@ -912,7 +912,7 @@ macro(add_llvm_example name)
endif()
add_llvm_executable(${name} ${ARGN})
if( LLVM_BUILD_EXAMPLES )
- install(TARGETS ${name} RUNTIME DESTINATION examples)
+ install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples)
endif()
set_target_properties(${name} PROPERTIES FOLDER "Examples")
endmacro(add_llvm_example name)
@@ -1430,7 +1430,7 @@ function(llvm_install_library_symlink name dest type)
set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
- set(output_dir lib${LLVM_LIBDIR_SUFFIX})
+ set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
if(WIN32 AND "${type}" STREQUAL "SHARED")
set(output_dir bin)
endif()
@@ -1446,7 +1446,7 @@ function(llvm_install_library_symlink name dest type)
endif()
endfunction()
-function(llvm_install_symlink name dest)
+function(llvm_install_symlink name dest output_dir)
cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
foreach(path ${CMAKE_MODULE_PATH})
if(EXISTS ${path}/LLVMInstallSymlink.cmake)
@@ -1469,7 +1469,7 @@ function(llvm_install_symlink name dest)
set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
install(SCRIPT ${INSTALL_SYMLINK}
- CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})"
+ CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
COMPONENT ${component})
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
@@ -1551,7 +1551,8 @@ function(add_llvm_tool_symlink link_name target)
endif()
if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
- llvm_install_symlink(${link_name} ${target})
+ GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR)
+ llvm_install_symlink(${link_name} ${target} ${output_dir})
endif()
endif()
endfunction()
@@ -1635,9 +1636,9 @@ function(llvm_setup_rpath name)
if (APPLE)
set(_install_name_dir INSTALL_NAME_DIR "@rpath")
- set(_install_rpath "@loader_path/../lib" ${extra_libdir})
+ set(_install_rpath "@loader_path/../${CMAKE_INSTALL_LIBDIR}" ${extra_libdir})
elseif(UNIX)
- set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+ set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,origin ")
diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake
index 02bab6846376..eff26adb2efc 100644
--- a/cmake/modules/AddOCaml.cmake
+++ b/cmake/modules/AddOCaml.cmake
@@ -140,9 +140,9 @@ function(add_ocaml_library name)
endforeach()
if( APPLE )
- set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
+ set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
elseif( UNIX )
- set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
+ set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
endif()
list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
diff --git a/cmake/modules/AddSphinxTarget.cmake b/cmake/modules/AddSphinxTarget.cmake
index 22e3dcb776aa..ba77b9c195e2 100644
--- a/cmake/modules/AddSphinxTarget.cmake
+++ b/cmake/modules/AddSphinxTarget.cmake
@@ -73,7 +73,7 @@ function (add_sphinx_target builder project)
elseif (builder STREQUAL html)
string(TOUPPER "${project}" project_upper)
- set(${project_upper}_INSTALL_SPHINX_HTML_DIR "share/doc/${project}/html"
+ set(${project_upper}_INSTALL_SPHINX_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/html"
CACHE STRING "HTML documentation install directory for ${project}")
# '/.' indicates: copy the contents of the directory directly into
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
index 6c316a2f04fb..129c0995059c 100644
--- a/cmake/modules/CMakeLists.txt
+++ b/cmake/modules/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(LLVM_INSTALL_PACKAGE_DIR ${LLVM_INSTALL_CMAKE_DIR} CACHE STRING "Path for CMake subdirectory (defaults to 'cmake/llvm')")
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
# First for users who use an installed LLVM, create the LLVMExports.cmake file.
@@ -90,11 +90,11 @@ foreach(p ${_count})
set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
endforeach(p)
-set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
-set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
+set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
+set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}")
set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
-set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
+set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS}")
configure_file(
diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake
index 1a04de931ff7..1c5ea4200635 100644
--- a/cmake/modules/LLVMInstallSymlink.cmake
+++ b/cmake/modules/LLVMInstallSymlink.cmake
@@ -10,7 +10,7 @@ function(install_symlink name target outdir)
set(LINK_OR_COPY copy)
endif()
- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
+ set(bindir "${DESTDIR}${outdir}/")
message("Creating ${name}")
diff --git a/docs/CMake.rst b/docs/CMake.rst
index cbcadc212498..a3da96546f43 100644
--- a/docs/CMake.rst
+++ b/docs/CMake.rst
@@ -196,7 +196,7 @@ CMake manual, or execute ``cmake --help-variable VARIABLE_NAME``.
**LLVM_LIBDIR_SUFFIX**:STRING
Extra suffix to append to the directory where libraries are to be
installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64``
- to install libraries to ``/usr/lib64``.
+ to install libraries to ``/usr/lib64``. See also ``CMAKE_INSTALL_LIBDIR``.
**CMAKE_C_FLAGS**:STRING
Extra flags to use when compiling C source files.
@@ -473,8 +473,8 @@ LLVM-specific variables
**LLVM_INSTALL_DOXYGEN_HTML_DIR**:STRING
The path to install Doxygen-generated HTML documentation to. This path can
- either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
- `share/doc/llvm/doxygen-html`.
+ either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
+ `${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html`.
**LLVM_ENABLE_SPHINX**:BOOL
If specified, CMake will search for the ``sphinx-build`` executable and will make
@@ -505,13 +505,33 @@ LLVM-specific variables
**LLVM_INSTALL_SPHINX_HTML_DIR**:STRING
The path to install Sphinx-generated HTML documentation to. This path can
- either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
- `share/doc/llvm/html`.
+ either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
+ `${CMAKE_INSTALL_DOCDIR}/${project}/html`.
**LLVM_INSTALL_OCAMLDOC_HTML_DIR**:STRING
The path to install OCamldoc-generated HTML documentation to. This path can
- either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
- `share/doc/llvm/ocaml-html`.
+ either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
+ `${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html`.
+
+**CMAKE_INSTALL_BINDIR**:STRING
+ The path to install binary tools, relative to the ``CMAKE_INSTALL_PREFIX``.
+ Defaults to `bin`.
+
+**CMAKE_INSTALL_LIBDIR**:STRING
+ The path to install libraries, relative to the ``CMAKE_INSTALL_PREFIX``.
+ Defaults to `lib`.
+
+**CMAKE_INSTALL_INCLUDEDIR**:STRING
+ The path to install header files, relative to the ``CMAKE_INSTALL_PREFIX``.
+ Defaults to `include`.
+
+**CMAKE_INSTALL_DOCDIR**:STRING
+ The path to install documentation, relative to the ``CMAKE_INSTALL_PREFIX``.
+ Defaults to `share/doc`.
+
+**CMAKE_INSTALL_MANDIR**:STRING
+ The path to install manpage files, relative to the ``CMAKE_INSTALL_PREFIX``.
+ Defaults to `share/man`.
**LLVM_CREATE_XCODE_TOOLCHAIN**:BOOL
OS X Only: If enabled CMake will generate a target named
@@ -676,9 +696,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
This file is available in two different locations.
-* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where
- ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM.
- On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
+* ``<LLVM_INSTALL_PACKAGE_DIR>LLVMConfig.cmake`` where
+ ``<LLVM_INSTALL_PACKAGE_DIR>`` is the location where LLVM CMake modules are
+ installed as part of an installed version of LLVM. This is typically
+ ``cmake/llvm/`` within the lib directory. On Linux, this is typically
+ ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
* ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where
``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note: this is only
diff --git a/include/llvm/CMakeLists.txt b/include/llvm/CMakeLists.txt
index 1d5ca3ba92b0..026f5453c1da 100644
--- a/include/llvm/CMakeLists.txt
+++ b/include/llvm/CMakeLists.txt
@@ -4,5 +4,5 @@ add_subdirectory(Support)
# If we're doing an out-of-tree build, copy a module map for generated
# header files into the build area.
if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
- configure_file(module.modulemap.build module.modulemap COPYONLY)
+ configure_file(module.modulemap.build ${LLVM_INCLUDE_DIR}/module.modulemap COPYONLY)
endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
index f201e1f7bff0..4582ed556a02 100644
--- a/tools/llvm-config/BuildVariables.inc.in
+++ b/tools/llvm-config/BuildVariables.inc.in
@@ -24,6 +24,10 @@
#define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
#define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
#define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
+#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
+#define LLVM_INSTALL_CMAKEDIR "@LLVM_INSTALL_CMAKE_DIR@"
#define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
#define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
#define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 892adc3b9dd8..cabe7fcc630f 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -333,12 +333,26 @@ int main(int argc, char **argv) {
("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
} else {
ActivePrefix = CurrentExecPrefix;
- ActiveIncludeDir = ActivePrefix + "/include";
- SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
- sys::fs::make_absolute(ActivePrefix, path);
- ActiveBinDir = path.str();
- ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
- ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
+ {
+ SmallString<256> path(StringRef(LLVM_INSTALL_INCLUDEDIR));
+ sys::fs::make_absolute(ActivePrefix, path);
+ ActiveIncludeDir = std::string(path.str());
+ }
+ {
+ SmallString<256> path(StringRef(LLVM_INSTALL_BINDIR));
+ sys::fs::make_absolute(ActivePrefix, path);
+ ActiveBinDir = std::string(path.str());
+ }
+ {
+ SmallString<256> path(StringRef(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX));
+ sys::fs::make_absolute(ActivePrefix, path);
+ ActiveLibDir = std::string(path.str());
+ }
+ {
+ SmallString<256> path(StringRef(LLVM_INSTALL_CMAKEDIR));
+ sys::fs::make_absolute(ActivePrefix, path);
+ ActiveCMakeDir = std::string(path.str());
+ }
ActiveIncludeOption = "-I" + ActiveIncludeDir;
}
diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt
index 6e913519a809..85641eef721f 100644
--- a/tools/lto/CMakeLists.txt
+++ b/tools/lto/CMakeLists.txt
@@ -19,7 +19,7 @@ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lto.exports)
add_llvm_library(LTO SHARED ${SOURCES} DEPENDS intrinsics_gen)
install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
- DESTINATION include/llvm-c
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm-c
COMPONENT LTO)
if (APPLE)
diff --git a/tools/opt-viewer/CMakeLists.txt b/tools/opt-viewer/CMakeLists.txt
index 19b606933082..27b9f71b3d79 100644
--- a/tools/opt-viewer/CMakeLists.txt
+++ b/tools/opt-viewer/CMakeLists.txt
@@ -8,6 +8,6 @@ set (files
foreach (file ${files})
install(PROGRAMS ${file}
- DESTINATION share/opt-viewer
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/opt-viewer
COMPONENT opt-viewer)
endforeach (file)

View file

@ -1,37 +0,0 @@
{ lib
, stdenv
, llvm_meta
, fetch
, cmake
, llvm
, targetLlvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "1dg53wzsci2kra8lh1y0chh60h2l8h1by93br5spzvzlxshkmrqy";
nativeBuildInputs = [ cmake perl ];
buildInputs = [
(if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
];
meta = llvm_meta // {
homepage = "https://openmp.llvm.org/";
description = "Support for the OpenMP language";
longDescription = ''
The OpenMP subproject of LLVM contains the components required to build an
executable OpenMP program that are outside the compiler itself.
Contains the code for the runtime library against which code compiled by
"clang -fopenmp" must be linked before it can run and the library that
supports offload to target devices.
'';
# "All of the code is dual licensed under the MIT license and the UIUC
# License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];
};
}

View file

@ -1,195 +0,0 @@
{ pkgs, haskellLib }:
with haskellLib;
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
in
self: super: {
llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
# Disable GHC 8.8.x core libraries.
array = null;
base = null;
binary = null;
bytestring = null;
Cabal = null;
containers = null;
deepseq = null;
directory = null;
filepath = null;
ghc-boot = null;
ghc-boot-th = null;
ghc-compact = null;
ghc-heap = null;
ghc-prim = null;
ghci = null;
haskeline = null;
hpc = null;
integer-gmp = null;
libiserv = null;
mtl = null;
parsec = null;
pretty = null;
process = null;
rts = null;
stm = null;
template-haskell = null;
# GHC only builds terminfo if it is a native compiler
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else self.terminfo_0_4_1_6;
text = null;
time = null;
transformers = null;
unix = null;
# GHC only bundles the xhtml library if haddock is enabled, check if this is
# still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
xhtml = if self.ghc.hasHaddock or true then null else self.xhtml_3000_3_0_0;
# These core package only exist for GHC >= 9.4. The best we can do is feign
# their existence to callPackages, but their is no shim for lower GHC versions.
system-cxx-std-lib = null;
# Need the Cabal-syntax-3.6.0.0 fake package for Cabal < 3.8 to allow callPackage and the constraint solver to work
Cabal-syntax = self.Cabal-syntax_3_6_0_0;
# GHC 8.8.x can build haddock version 2.23.*
haddock = self.haddock_2_23_1;
haddock-api = self.haddock-api_2_23_1;
# This build needs a newer version of Cabal.
cabal2spec = super.cabal2spec.override { Cabal = self.Cabal_3_2_1_0; };
# Additionally depends on OneTuple for GHC < 9.0
base-compat-batteries = addBuildDepend self.OneTuple super.base-compat-batteries;
# For GHC < 9.4, some packages need data-array-byte as an extra dependency
primitive = addBuildDepends [ self.data-array-byte ] super.primitive;
hashable = addBuildDepends [
self.data-array-byte
self.base-orphans
] super.hashable;
# Ignore overly restrictive upper version bounds.
aeson-diff = doJailbreak super.aeson-diff;
async = doJailbreak super.async;
ChasingBottoms = doJailbreak super.ChasingBottoms;
chell = doJailbreak super.chell;
Diff = dontCheck super.Diff;
doctest = overrideCabal (drv: {
jailbreak = true;
# The test case relies on the Printf module which did not exist in base 4.13
testFlags = drv.testFlags or [ ] ++ [
"--skip=/Main/doctest (regression tests)/template-haskell-bugfix/"
];
}) super.doctest;
hashable-time = doJailbreak super.hashable-time;
hledger-lib = doJailbreak super.hledger-lib; # base >=4.8 && <4.13, easytest >=0.2.1 && <0.3
integer-logarithms = doJailbreak super.integer-logarithms;
lucid = doJailbreak super.lucid;
parallel = doJailbreak super.parallel;
setlocale = doJailbreak super.setlocale;
split = doJailbreak super.split;
system-fileio = doJailbreak super.system-fileio;
tasty-expected-failure = doJailbreak super.tasty-expected-failure;
tasty-hedgehog = doJailbreak super.tasty-hedgehog;
test-framework = doJailbreak super.test-framework;
th-expand-syns = doJailbreak super.th-expand-syns;
# TODO: remove when upstream accepts https://github.com/snapframework/io-streams-haproxy/pull/17
io-streams-haproxy = doJailbreak super.io-streams-haproxy; # base >=4.5 && <4.13
snap-server = doJailbreak super.snap-server;
exact-pi = doJailbreak super.exact-pi;
time-compat = doJailbreak super.time-compat;
http-media = unmarkBroken (doJailbreak super.http-media);
servant-server = unmarkBroken (doJailbreak super.servant-server);
basement = doDistribute self.basement_0_0_14;
foundation = doDistribute (dontCheck self.foundation_0_0_28);
vault = dontHaddock super.vault;
# https://github.com/snapframework/snap-core/issues/288
snap-core = overrideCabal (drv: { prePatch = "substituteInPlace src/Snap/Internal/Core.hs --replace 'fail = Fail.fail' ''"; }) super.snap-core;
# Upstream ships a broken Setup.hs file.
csv = overrideCabal (drv: { prePatch = "rm Setup.hs"; }) super.csv;
# https://github.com/kowainik/relude/issues/241
relude = dontCheck super.relude;
# The current version 2.14.2 does not compile with ghc-8.8.x or newer because
# of issues with Cabal 3.x.
darcs = dontDistribute super.darcs;
# liquidhaskell does not support ghc version 8.8.x.
liquid = markBroken super.liquid;
liquid-base = markBroken super.liquid-base;
liquid-bytestring = markBroken super.liquid-bytestring;
liquid-containers = markBroken super.liquid-containers;
liquid-ghc-prim = markBroken super.liquid-ghc-prim;
liquid-parallel = markBroken super.liquid-parallel;
liquid-platform = markBroken super.liquid-platform;
liquid-prelude = markBroken super.liquid-prelude;
liquid-vector = markBroken super.liquid-vector;
liquidhaskell = markBroken super.liquidhaskell;
# This became a core library in ghc 8.10., so we dont have an "exception" attribute anymore.
exceptions = super.exceptions_0_10_7;
ormolu = super.ormolu_0_2_0_0;
ghc-api-compat = doDistribute (unmarkBroken super.ghc-api-compat_8_6);
mime-string = disableOptimization super.mime-string;
haskell-language-server = throw "haskell-language-server dropped support for ghc 8.8 in version 1.9.0.0 please use a newer ghc version or an older nixpkgs version";
hlint = self.hlint_3_2_8;
ghc-lib-parser = doDistribute self.ghc-lib-parser_8_10_7_20220219;
ghc-lib = doDistribute self.ghc-lib_8_10_7_20220219;
# ghc versions which dont match the ghc-lib-parser-ex version need the
# additional dependency to compile successfully.
ghc-lib-parser-ex = doDistribute (addBuildDepend self.ghc-lib-parser self.ghc-lib-parser-ex_8_10_0_24);
# has a restrictive lower bound on Cabal
fourmolu = doJailbreak super.fourmolu;
# Overly-strict bounds introducted by a revision in version 0.3.2.
text-metrics = doJailbreak super.text-metrics;
# OneTuple needs hashable (instead of ghc-prim) and foldable1-classes-compat for GHC < 9
OneTuple = addBuildDepends [
self.foldable1-classes-compat
] (super.OneTuple.override {
ghc-prim = self.hashable;
});
# Temporarily disabled blaze-textual for GHC >= 9.0 causing hackage2nix ignoring it
# https://github.com/paul-rouse/mysql-simple/blob/872604f87044ff6d1a240d9819a16c2bdf4ed8f5/Database/MySQL/Internal/Blaze.hs#L4-L10
mysql-simple = addBuildDepends [
self.blaze-textual
] super.mysql-simple;
# https://github.com/fpco/inline-c/issues/127 (recommend to upgrade to Nixpkgs GHC >=9.0)
inline-c-cpp = (if isDarwin then dontCheck else x: x) super.inline-c-cpp;
# Depends on OneTuple for GHC < 9.0
universe-base = addBuildDepends [ self.OneTuple ] super.universe-base;
# doctest-parallel dependency requires newer Cabal
regex-tdfa = dontCheck super.regex-tdfa;
# Unnecessarily strict lower bound on base
# https://github.com/mrkkrp/megaparsec/pull/485#issuecomment-1250051823
megaparsec = doJailbreak super.megaparsec;
# Needs OneTuple for ghc < 9.2
binary-orphans = addBuildDepends [ self.OneTuple ] super.binary-orphans;
# Later versions only support GHC >= 9.2
ghc-exactprint = self.ghc-exactprint_0_6_4;
apply-refact = self.apply-refact_0_9_3_0;
# Requires GHC < 9.4
ghc-source-gen = doDistribute (unmarkBroken super.ghc-source-gen);
}

View file

@ -63,12 +63,8 @@ with pkgs;
# libcxxStdenv broken
# fix in https://github.com/NixOS/nixpkgs/pull/216273
] ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
# libcxx does not build for some reason on aarch64-linux
(filterAttrs (n: _: n != "llvmPackages_7"))
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
(filterAttrs (n: _: n != "llvmPackages_6"))
(filterAttrs (n: _: n != "llvmPackages_7"))
(filterAttrs (n: _: n != "llvmPackages_8"))
(filterAttrs (n: _: n != "llvmPackages_9"))
(filterAttrs (n: _: n != "llvmPackages_10"))

View file

@ -164,7 +164,7 @@ mapAliases ({
# these are for convenience, not for backward compat and shouldn't expire
clang6Stdenv = lowPrio llvmPackages_6.stdenv;
clang7Stdenv = lowPrio llvmPackages_7.stdenv;
clang7Stdenv = throw "clang7Stdenv has been removed from nixpkgs"; # Added 2023-11-19
clang8Stdenv = lowPrio llvmPackages_8.stdenv;
clang9Stdenv = lowPrio llvmPackages_9.stdenv;
clang10Stdenv = lowPrio llvmPackages_10.stdenv;
@ -175,6 +175,9 @@ mapAliases ({
clang15Stdenv = lowPrio llvmPackages_15.stdenv;
clang16Stdenv = lowPrio llvmPackages_16.stdenv;
clang-tools_7 = throw "clang-tools_7 has been removed from nixpkgs"; # Added 2023-11-19
clang_7 = throw "clang_7 has been removed from nixpkgs"; # Added 2023-11-19
### D ###
dagger = throw "'dagger' has been removed from nixpkgs, as the trademark policy of the upstream project is incompatible"; # Added 2023-10-16
@ -559,6 +562,10 @@ mapAliases ({
'';
linux_latest_hardened = linuxPackages_latest_hardened;
lld_7 = throw "lld_7 has been removed from nixpkgs"; # Added 2023-11-19
lldb_7 = throw "lldb_7 has been removed from nixpkgs"; # Added 2023-11-19
llvmPackages_7 = throw "llvmPackages_7 has been removed from nixpkgs"; # Added 2023-11-19
llvm_7 = throw "llvm_7 has been removed from nixpkgs"; # Added 2023-11-19
lobster-two = google-fonts; # Added 2021-07-22
luxcorerender = throw "'luxcorerender' has been removed as it's unmaintained and broken in nixpkgs since a while ago"; # Added 2023-06-07

View file

@ -7238,7 +7238,7 @@ with pkgs;
compass = callPackage ../development/tools/compass { };
cone = callPackage ../development/compilers/cone {
llvmPackages = llvmPackages_7;
llvmPackages = llvmPackages_13;
};
conda = callPackage ../tools/package-management/conda { };
@ -15648,7 +15648,6 @@ with pkgs;
clang = llvmPackages.clang;
clang_6 = llvmPackages_6.clang;
clang_7 = llvmPackages_7.clang;
clang_8 = llvmPackages_8.clang;
clang_9 = llvmPackages_9.clang;
clang_10 = llvmPackages_10.clang;
@ -15667,10 +15666,6 @@ with pkgs;
llvmPackages = llvmPackages_6;
};
clang-tools_7 = callPackage ../development/tools/clang-tools {
llvmPackages = llvmPackages_7;
};
clang-tools_8 = callPackage ../development/tools/clang-tools {
llvmPackages = llvmPackages_8;
};
@ -16600,7 +16595,6 @@ with pkgs;
lld = llvmPackages.lld;
lld_6 = llvmPackages_6.lld;
lld_7 = llvmPackages_7.lld;
lld_8 = llvmPackages_8.lld;
lld_9 = llvmPackages_9.lld;
lld_10 = llvmPackages_10.lld;
@ -16613,7 +16607,6 @@ with pkgs;
lldb = lldb_14;
lldb_6 = llvmPackages_6.lldb;
lldb_7 = llvmPackages_7.lldb;
lldb_8 = llvmPackages_8.lldb;
lldb_9 = llvmPackages_9.lldb;
lldb_10 = llvmPackages_10.lldb;
@ -16626,7 +16619,6 @@ with pkgs;
llvm = llvmPackages.llvm;
llvm_6 = llvmPackages_6.llvm;
llvm_7 = llvmPackages_7.llvm;
llvm_8 = llvmPackages_8.llvm;
llvm_9 = llvmPackages_9.llvm;
llvm_10 = llvmPackages_10.llvm;
@ -16664,13 +16656,6 @@ with pkgs;
targetLlvmLibraries = targetPackages.llvmPackages_6.libraries or llvmPackages_6.libraries;
});
llvmPackages_7 = recurseIntoAttrs (callPackage ../development/compilers/llvm/7 {
inherit (stdenvAdapters) overrideCC;
buildLlvmTools = buildPackages.llvmPackages_7.tools;
targetLlvm = targetPackages.llvmPackages_7.llvm or llvmPackages_7.llvm;
targetLlvmLibraries = targetPackages.llvmPackages_7.libraries or llvmPackages_7.libraries;
});
llvmPackages_8 = recurseIntoAttrs (callPackage ../development/compilers/llvm/8 {
inherit (stdenvAdapters) overrideCC;
buildLlvmTools = buildPackages.llvmPackages_8.tools;
@ -17749,9 +17734,7 @@ with pkgs;
### End of CuboCore
maude = callPackage ../development/interpreters/maude {
stdenv = if stdenv.cc.isClang then llvmPackages_7.stdenv else stdenv;
};
maude = callPackage ../development/interpreters/maude { };
me_cleaner = callPackage ../tools/misc/me_cleaner { };
@ -40032,7 +40015,6 @@ with pkgs;
root5 = lowPrio (callPackage ../applications/science/misc/root/5.nix {
inherit (darwin.apple_sdk.frameworks) Cocoa OpenGL;
stdenv = if stdenv.cc.isClang then llvmPackages_7.stdenv else stdenv;
});
rinetd = callPackage ../servers/rinetd { };

View file

@ -65,7 +65,8 @@ in {
compiler = {
ghc865Binary = callPackage ../development/compilers/ghc/8.6.5-binary.nix {
llvmPackages = pkgs.llvmPackages_6;
# Should be llvmPackages_6 which has been removed from nixpkgs
llvmPackages = null;
};
ghc8102Binary = callPackage ../development/compilers/ghc/8.10.2-binary.nix {
@ -80,20 +81,6 @@ in {
llvmPackages = pkgs.llvmPackages_12;
};
ghc884 = callPackage ../development/compilers/ghc/8.8.4.nix {
bootPkgs =
# aarch64 ghc865Binary gets SEGVs due to haskell#15449 or similar
# 8.10.2 is needed as using 8.10.7 is broken due to RTS-incompatibilities
# Musl bindists do not exist for ghc 8.6.5, so we use 8.10.* for them
if stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isMusl then
packages.ghc8102Binary
else
packages.ghc865Binary;
inherit (buildPackages.python3Packages) sphinx;
buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_7;
llvmPackages = pkgs.llvmPackages_7;
};
ghc88 = compiler.ghc884;
ghc8107 = callPackage ../development/compilers/ghc/8.10.7.nix {
bootPkgs =
# the oldest ghc with aarch64-darwin support is 8.10.5
@ -484,12 +471,6 @@ in {
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-9.2.x.nix { };
packageSetConfig = bootstrapPackageSet;
};
ghc884 = callPackage ../development/haskell-modules {
buildHaskellPackages = bh.packages.ghc884;
ghc = bh.compiler.ghc884;
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.8.x.nix { };
};
ghc88 = packages.ghc884;
ghc8107 = callPackage ../development/haskell-modules {
buildHaskellPackages = bh.packages.ghc8107;
ghc = bh.compiler.ghc8107;

View file

@ -60,7 +60,6 @@ let
# list of all compilers to test specific packages on
released = with compilerNames; [
ghc884
ghc8107
ghc902
ghc924
@ -390,10 +389,6 @@ let
ghcjs = {};
ghcjs810 = {};
# Can't be built with musl, see meta.broken comment in the drv
integer-simple.ghc884 = {};
integer-simple.ghc88 = {};
};
# Get some cache going for MUSL-enabled GHC.
@ -501,8 +496,6 @@ let
] released;
funcmp = released;
haskell-language-server = lib.subtractLists [
# Support ceased as of 1.9.0.0
compilerNames.ghc884
# Support ceased as of 2.3.0.0
compilerNames.ghc8107
# Not yet supported
@ -534,12 +527,10 @@ let
compilerNames.ghc981
] released;
ghc-api-compat = [
compilerNames.ghc884
compilerNames.ghc8107
compilerNames.ghc902
];
ghc-bignum = [
compilerNames.ghc884
compilerNames.ghc8107
];
ghc-lib = lib.subtractLists [
@ -554,13 +545,11 @@ let
ghc-source-gen = [
# Feel free to remove these as they break,
# ghc-source-gen currently doesn't support GHC 9.4
compilerNames.ghc884
compilerNames.ghc8107
compilerNames.ghc902
compilerNames.ghc928
];
ghc-tags = lib.subtractLists [
compilerNames.ghc884
compilerNames.ghc981
] released;
hashable = lib.subtractLists [
@ -653,7 +642,6 @@ let
constituents = accumulateDerivations [
jobs.pkgsMusl.haskell.compiler.ghc8102Binary
jobs.pkgsMusl.haskell.compiler.ghc8107Binary
jobs.pkgsMusl.haskell.compiler.ghc884
jobs.pkgsMusl.haskell.compiler.ghc8107
jobs.pkgsMusl.haskell.compiler.ghc902
jobs.pkgsMusl.haskell.compiler.ghc924