2011-10-18 22:03:09 +02:00
|
|
|
# The Nix `clang' stdenv.mkDerivation is not directly usable, since it doesn't
|
|
|
|
# know where the C library and standard header files are. Therefore
|
|
|
|
# the compiler produced by that package cannot be installed directly
|
|
|
|
# in a user environment and used from the command line. This
|
|
|
|
# stdenv.mkDerivation provides a wrapper that sets up the right environment
|
|
|
|
# variables so that the compiler and the linker just "work".
|
|
|
|
|
|
|
|
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
|
|
|
|
, clang ? null, libc ? null, binutils ? null, coreutils ? null, shell ? ""
|
2013-09-07 11:02:32 +02:00
|
|
|
, zlib ? null, libcxx ? null
|
2011-10-18 22:03:09 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert nativeTools -> nativePrefix != "";
|
|
|
|
assert !nativeTools -> clang != null && binutils != null && coreutils != null;
|
|
|
|
assert !nativeLibc -> libc != null;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
clangVersion = (builtins.parseDrvName clang.name).version;
|
|
|
|
clangName = (builtins.parseDrvName clang.name).name;
|
2014-02-04 16:58:12 +01:00
|
|
|
|
2011-10-18 22:03:09 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name =
|
|
|
|
(if name != "" then name else clangName + "-wrapper") +
|
|
|
|
(if clang != null && clangVersion != "" then "-" + clangVersion else "");
|
2014-02-04 16:58:12 +01:00
|
|
|
|
2011-10-18 22:03:09 +02:00
|
|
|
builder = ./builder.sh;
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
clangWrapper = ./clang-wrapper.sh;
|
2014-07-02 20:10:40 +02:00
|
|
|
ldWrapper = ../gcc-wrapper/ld-wrapper.sh;
|
|
|
|
utils = ../gcc-wrapper/utils.sh;
|
2011-10-18 22:03:09 +02:00
|
|
|
addFlags = ./add-flags;
|
2014-02-04 16:58:12 +01:00
|
|
|
|
2013-09-07 11:02:32 +02:00
|
|
|
inherit nativeTools nativeLibc nativePrefix clang clangVersion libcxx;
|
Add full llvm build, update libc++ and dragonegg
Some packages in the llvm suite (e.g. compiler-rt) cannot be built
separate from the build of llvm, and while some others (e.g. clang) can
the combined build is much better tested (we've had to work around
annoying issues before). So this puts llvm, clang, clang-tools-extra,
compiler-rt, lld, lldb, and polly all into one big build (llvmFull).
This build includes a static llvm, as dynamic is similarly less tested
and has known failures.
This also updates libc++ and dragonegg. libc++ now builds against
libc++abi as a separate package rather than building it during the
libc++ build.
The clang purity patch is gone. Instead, we simply set --sysroot to
/var/empty for pure builds, as all impure paths are either looked up in
the gcc prefix (which we hard-code at compile time) or in the sysroot.
This also means that if NIX_ENFORCE_PURITY is 0 then clang will look in
the normal Linux paths by default, which is the proper behavior IMO.
polly required an updated isl. When stdenv-updates is merged, perhaps we
can update the isl used by gcc and avoid having two versions.
Since llvm on its own is now separate from the llvm used by clang, I've
removed myself as maintainer from llvm and will leave maintenance of
that to those who are interested in llvm separate from clang.
Signed-off-by: Shea Levy <shea@shealevy.com>
2014-01-20 11:23:17 +01:00
|
|
|
|
|
|
|
libcxxabi = libcxx.abi or null;
|
|
|
|
|
2011-10-18 22:03:09 +02:00
|
|
|
gcc = clang.gcc;
|
|
|
|
libc = if nativeLibc then null else libc;
|
|
|
|
binutils = if nativeTools then null else binutils;
|
|
|
|
# The wrapper scripts use 'cat', so we may need coreutils
|
|
|
|
coreutils = if nativeTools then null else coreutils;
|
2014-02-04 16:58:12 +01:00
|
|
|
|
2011-10-18 22:03:09 +02:00
|
|
|
langC = true;
|
|
|
|
langCC = true;
|
|
|
|
shell = if shell == "" then stdenv.shell else
|
|
|
|
if builtins.isAttrs shell then (shell + shell.shellPath)
|
|
|
|
else shell;
|
|
|
|
|
|
|
|
crossAttrs = {
|
2012-12-28 19:08:19 +01:00
|
|
|
shell = shell.crossDrv + shell.crossDrv.shellPath;
|
|
|
|
libc = libc.crossDrv;
|
|
|
|
coreutils = coreutils.crossDrv;
|
|
|
|
binutils = binutils.crossDrv;
|
|
|
|
clang = clang.crossDrv;
|
2011-10-18 22:03:09 +02:00
|
|
|
#
|
|
|
|
# This is not the best way to do this. I think the reference should be
|
|
|
|
# the style in the gcc-cross-wrapper, but to keep a stable stdenv now I
|
|
|
|
# do this sufficient if/else.
|
|
|
|
dynamicLinker =
|
|
|
|
(if stdenv.cross.arch == "arm" then "ld-linux.so.3" else
|
|
|
|
if stdenv.cross.arch == "mips" then "ld.so.1" else
|
|
|
|
if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
|
|
|
|
abort "don't know the name of the dynamic linker for this platform");
|
|
|
|
};
|
2014-02-04 16:58:12 +01:00
|
|
|
|
2011-10-18 22:03:09 +02:00
|
|
|
meta =
|
|
|
|
let clang_ = if clang != null then clang else {}; in
|
|
|
|
(if clang_ ? meta then removeAttrs clang.meta ["priority"] else {}) //
|
|
|
|
{ description =
|
|
|
|
stdenv.lib.attrByPath ["meta" "description"] "System C compiler" clang_
|
|
|
|
+ " (wrapper script)";
|
|
|
|
};
|
|
|
|
|
|
|
|
# The dynamic linker has different names on different Linux platforms.
|
|
|
|
dynamicLinker =
|
|
|
|
if !nativeLibc then
|
|
|
|
(if stdenv.system == "i686-linux" then "ld-linux.so.2" else
|
|
|
|
if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
|
2012-04-16 01:41:25 +02:00
|
|
|
if stdenv.isArm then "ld-linux.so.3" else
|
2011-10-18 22:03:09 +02:00
|
|
|
if stdenv.system == "powerpc-linux" then "ld.so.1" else
|
2012-01-21 01:34:51 +01:00
|
|
|
if stdenv.system == "mips64el-linux" then "ld.so.1" else
|
2011-10-18 22:03:09 +02:00
|
|
|
abort "don't know the name of the dynamic linker for this platform")
|
|
|
|
else "";
|
2014-02-10 21:03:17 +01:00
|
|
|
|
|
|
|
preferLocalBuild = true;
|
2011-10-18 22:03:09 +02:00
|
|
|
}
|