mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
llvmPackages_13: build from filtered monorepoSrc
This change implements a leftover task from #307211, namely passing monorepoSrc to the different llvmPackages_13 package expressions. Before this change, all packages llvmPackages_13 would be built from a subdirectory of the full LLVM monorepo tree. After this change only the relevant directories are made available at build time. This - reduces the size of the source that needs to be made available to the builder. - prevents LLVM from sidestepping our instructions and including extra sources from other directories it shouldn't. Since LLVM 12 and 13 don't have the `cmake` directory at the top level, the runCommand expressions filtering the source need to be adjusted, but this causes no rebuild for any other LLVM version (ofborg should confirm this). The only problem encountered was in lld: - We need to make the patch to the inclusion of libunwind headers unconditional now. lld needs this on non-darwin as well. In the full monorepo, LLVM_MAIN_SRC_DIR would be set correctly, so the patch wasn't necessary. - The substitute mechanism for LLVM 12 and 13 can't be unified yet since LLVM 12 still uses a non monorepo build, so we come up with a different LLVM_MAIN_SRC_DIR. Change was tested by building the following expression on x86_64-linux. with import ./. {}; builtins.removeAttrs llvmPackages_13 [ "lldb" "lldbPlugins" ]' lld was also tested on aarch64-darwin.
This commit is contained in:
parent
f7dbf14e43
commit
1d6675e530
@ -3,6 +3,7 @@
|
||||
stdenv,
|
||||
llvm_meta,
|
||||
monorepoSrc,
|
||||
release_version,
|
||||
runCommand,
|
||||
cmake,
|
||||
libxml2,
|
||||
@ -20,16 +21,22 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
inherit version patches;
|
||||
|
||||
# Blank llvm dir just so relative path works
|
||||
src = runCommand "bolt-src-${finalAttrs.version}" { } ''
|
||||
mkdir $out
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/${finalAttrs.pname} "$out"
|
||||
cp -r ${monorepoSrc}/third-party "$out"
|
||||
src = runCommand "bolt-src-${finalAttrs.version}" { } (
|
||||
''
|
||||
mkdir $out
|
||||
''
|
||||
+ lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
''
|
||||
+ ''
|
||||
cp -r ${monorepoSrc}/${finalAttrs.pname} "$out"
|
||||
cp -r ${monorepoSrc}/third-party "$out"
|
||||
|
||||
# tablegen stuff, probably not the best way but it works...
|
||||
cp -r ${monorepoSrc}/llvm/ "$out"
|
||||
chmod -R +w $out/llvm
|
||||
'';
|
||||
# tablegen stuff, probably not the best way but it works...
|
||||
cp -r ${monorepoSrc}/llvm/ "$out"
|
||||
chmod -R +w $out/llvm
|
||||
''
|
||||
);
|
||||
|
||||
sourceRoot = "${finalAttrs.src.name}/bolt";
|
||||
|
||||
|
@ -24,12 +24,14 @@ let
|
||||
pname = "clang";
|
||||
|
||||
src' = if monorepoSrc != null then
|
||||
runCommand "${pname}-src-${version}" {} ''
|
||||
runCommand "${pname}-src-${version}" {} (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/${pname} "$out"
|
||||
cp -r ${monorepoSrc}/clang-tools-extra "$out"
|
||||
'' else src;
|
||||
'') else src;
|
||||
|
||||
self = stdenv.mkDerivation (finalAttrs: rec {
|
||||
inherit pname version patches;
|
||||
|
@ -47,11 +47,13 @@ let
|
||||
pname = baseName + lib.optionalString (haveLibc) "-libc";
|
||||
|
||||
src' = if monorepoSrc != null then
|
||||
runCommand "${baseName}-src-${version}" {} ''
|
||||
runCommand "${baseName}-src-${version}" {} (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/${baseName} "$out"
|
||||
'' else src;
|
||||
'') else src;
|
||||
|
||||
preConfigure = lib.optionalString (!haveLibc) ''
|
||||
cmakeFlagsArray+=(-DCMAKE_C_FLAGS="-nodefaultlibs -ffreestanding")
|
||||
|
@ -346,13 +346,7 @@ let
|
||||
tools = lib.makeExtensible (
|
||||
tools:
|
||||
let
|
||||
callPackage = newScope (
|
||||
tools
|
||||
// args
|
||||
// metadata
|
||||
# Previously monorepoSrc was erroneously not being passed through.
|
||||
// lib.optionalAttrs (lib.versionOlder metadata.release_version "14") { monorepoSrc = null; } # Preserve a bug during #307211, TODO: remove; causes llvm 13 rebuild.
|
||||
);
|
||||
callPackage = newScope (tools // args // metadata);
|
||||
clangVersion =
|
||||
if (lib.versionOlder metadata.release_version "16") then
|
||||
metadata.release_version
|
||||
|
@ -22,11 +22,17 @@ stdenv.mkDerivation rec {
|
||||
pname = "libclc";
|
||||
inherit version;
|
||||
|
||||
src = runCommand "${pname}-src-${version}" { } ''
|
||||
mkdir -p "$out"
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/${pname} "$out"
|
||||
'';
|
||||
src = runCommand "${pname}-src-${version}" { } (
|
||||
''
|
||||
mkdir -p "$out"
|
||||
''
|
||||
+ lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
''
|
||||
+ ''
|
||||
cp -r ${monorepoSrc}/${pname} "$out"
|
||||
''
|
||||
);
|
||||
|
||||
sourceRoot = "${src.name}/${pname}";
|
||||
|
||||
|
@ -19,7 +19,9 @@ let
|
||||
src' = if monorepoSrc != null then
|
||||
runCommand "${pname}-src-${version}" {} (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/${pname} "$out"
|
||||
mkdir -p "$out/libcxx"
|
||||
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
|
||||
|
@ -19,21 +19,23 @@ let
|
||||
pname = "lld";
|
||||
src' =
|
||||
if monorepoSrc != null then
|
||||
runCommand "lld-src-${version}" {} ''
|
||||
runCommand "lld-src-${version}" {} (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/${pname} "$out"
|
||||
mkdir -p "$out/libunwind"
|
||||
cp -r ${monorepoSrc}/libunwind/include "$out/libunwind"
|
||||
mkdir -p "$out/llvm"
|
||||
'' else src;
|
||||
'') else src;
|
||||
|
||||
postPatch = lib.optionalString (lib.versions.major release_version == "12") ''
|
||||
substituteInPlace MachO/CMakeLists.txt --replace \
|
||||
'(''${LLVM_MAIN_SRC_DIR}/' '('
|
||||
mkdir -p libunwind/include
|
||||
tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/"
|
||||
'' + lib.optionalString (lib.versions.major release_version == "13" && stdenv.hostPlatform.isDarwin) ''
|
||||
'' + lib.optionalString (lib.versions.major release_version == "13") ''
|
||||
substituteInPlace MachO/CMakeLists.txt --replace \
|
||||
'(''${LLVM_MAIN_SRC_DIR}/' '(../'
|
||||
'';
|
||||
@ -75,4 +77,4 @@ stdenv.mkDerivation (rec {
|
||||
of several different linkers.
|
||||
'';
|
||||
};
|
||||
} // (if (postPatch == "" && lib.versions.major release_version != "13") then {} else { inherit postPatch; }))
|
||||
} // (lib.optionalAttrs (postPatch != "") { inherit postPatch; }))
|
||||
|
@ -32,7 +32,9 @@ let
|
||||
if monorepoSrc != null then
|
||||
runCommand "lldb-src-${version}" { } (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/lldb "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "19" && enableManpages) ''
|
||||
mkdir -p "$out/llvm"
|
||||
|
@ -77,11 +77,15 @@ let
|
||||
|
||||
pname = "llvm";
|
||||
|
||||
# TODO: simplify versionAtLeast condition for cmake and third-party via rebuild
|
||||
src' = if monorepoSrc != null then
|
||||
runCommand "${pname}-src-${version}" {} (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/${pname} "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/third-party "$out"
|
||||
'' + lib.optionalString enablePolly ''
|
||||
chmod u+w "$out/${pname}/tools"
|
||||
|
@ -1,6 +1,7 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, llvm_meta
|
||||
, release_version
|
||||
, buildLlvmTools
|
||||
, monorepoSrc
|
||||
, runCommand
|
||||
@ -18,14 +19,16 @@ stdenv.mkDerivation rec {
|
||||
inherit version doCheck;
|
||||
|
||||
# Blank llvm dir just so relative path works
|
||||
src = runCommand "${pname}-src-${version}" { } ''
|
||||
src = runCommand "${pname}-src-${version}" { } (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/mlir "$out"
|
||||
cp -r ${monorepoSrc}/third-party "$out/third-party"
|
||||
|
||||
mkdir -p "$out/llvm"
|
||||
'';
|
||||
'');
|
||||
|
||||
sourceRoot = "${src.name}/mlir";
|
||||
|
||||
|
@ -21,11 +21,13 @@ let
|
||||
pname = "openmp";
|
||||
src' =
|
||||
if monorepoSrc != null then
|
||||
runCommand "${pname}-src-${version}" {} ''
|
||||
runCommand "${pname}-src-${version}" {} (''
|
||||
mkdir -p "$out"
|
||||
'' + lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
'' + ''
|
||||
cp -r ${monorepoSrc}/${pname} "$out"
|
||||
'' else src;
|
||||
'') else src;
|
||||
in
|
||||
stdenv.mkDerivation (rec {
|
||||
inherit pname version patches;
|
||||
|
Loading…
Reference in New Issue
Block a user