mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-22 08:30:57 +00:00
Compare commits
6 Commits
devShellTo
...
llvm-clean
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5975ba6be1 | ||
|
|
95191cd7a5 | ||
|
|
0fe5ab26b9 | ||
|
|
5b59dfc37a | ||
|
|
65e2d797a2 | ||
|
|
e8f0e65bf0 |
@@ -121,3 +121,6 @@ c759efa5e7f825913f9a69ef20f025f50f56dc4d
|
|||||||
|
|
||||||
# python3Packages: format with nixfmt
|
# python3Packages: format with nixfmt
|
||||||
59b1aef59071cae6e87859dc65de973d2cc595c0
|
59b1aef59071cae6e87859dc65de973d2cc595c0
|
||||||
|
|
||||||
|
# pkgs/development/compilers/llvm/common: Reformat with nixfmt-rfc-style
|
||||||
|
65e2d797a234feb71c787ad3ef0cafc52299bb37
|
||||||
|
|||||||
1
.github/workflows/check-nix-format.yml
vendored
1
.github/workflows/check-nix-format.yml
vendored
@@ -43,6 +43,7 @@ jobs:
|
|||||||
nixos/modules/services/cluster/k3s
|
nixos/modules/services/cluster/k3s
|
||||||
nixos/tests/k3s
|
nixos/tests/k3s
|
||||||
pkgs/applications/networking/cluster/k3s
|
pkgs/applications/networking/cluster/k3s
|
||||||
|
NIX_FMT_PATHS_LLVM_COMMON: pkgs/development/compilers/llvm/common
|
||||||
NIX_FMT_PATHS_VSCODE_EXTS: pkgs/applications/editors/vscode/extensions
|
NIX_FMT_PATHS_VSCODE_EXTS: pkgs/applications/editors/vscode/extensions
|
||||||
NIX_FMT_PATHS_PHP_PACKAGES: pkgs/development/php-packages
|
NIX_FMT_PATHS_PHP_PACKAGES: pkgs/development/php-packages
|
||||||
NIX_FMT_PATHS_BUILD_SUPPORT_PHP: pkgs/build-support/php
|
NIX_FMT_PATHS_BUILD_SUPPORT_PHP: pkgs/build-support/php
|
||||||
|
|||||||
@@ -1,49 +1,62 @@
|
|||||||
{ lib, runCommand, stdenv, llvm, lld, version, release_version }:
|
{
|
||||||
|
lib,
|
||||||
|
runCommand,
|
||||||
|
stdenv,
|
||||||
|
llvm,
|
||||||
|
lld,
|
||||||
|
version,
|
||||||
|
release_version,
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
targetPrefix = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) "${stdenv.targetPlatform.config}-";
|
targetPrefix = lib.optionalString (
|
||||||
|
stdenv.hostPlatform != stdenv.targetPlatform
|
||||||
|
) "${stdenv.targetPlatform.config}-";
|
||||||
in
|
in
|
||||||
runCommand "llvm-binutils-${version}"
|
runCommand "llvm-binutils-${version}"
|
||||||
{
|
{
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
passthru = {
|
passthru = {
|
||||||
isLLVM = true;
|
isLLVM = true;
|
||||||
inherit targetPrefix;
|
inherit targetPrefix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
(''
|
(
|
||||||
mkdir -p $out/bin
|
''
|
||||||
for prog in ${lld}/bin/*; do
|
mkdir -p $out/bin
|
||||||
ln -s $prog $out/bin/${targetPrefix}$(basename $prog)
|
for prog in ${lld}/bin/*; do
|
||||||
done
|
ln -s $prog $out/bin/${targetPrefix}$(basename $prog)
|
||||||
for prog in ${llvm}/bin/*; do
|
done
|
||||||
ln -sf $prog $out/bin/${targetPrefix}$(basename $prog)
|
for prog in ${llvm}/bin/*; do
|
||||||
done
|
ln -sf $prog $out/bin/${targetPrefix}$(basename $prog)
|
||||||
|
done
|
||||||
|
|
||||||
llvmBin="${llvm}/bin"
|
llvmBin="${llvm}/bin"
|
||||||
|
|
||||||
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}ar
|
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}ar
|
||||||
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}dlltool
|
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}dlltool
|
||||||
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}ranlib
|
ln -s $llvmBin/llvm-ar $out/bin/${targetPrefix}ranlib
|
||||||
ln -s $llvmBin/llvm-cxxfilt $out/bin/${targetPrefix}c++filt
|
ln -s $llvmBin/llvm-cxxfilt $out/bin/${targetPrefix}c++filt
|
||||||
ln -s $llvmBin/llvm-dwp $out/bin/${targetPrefix}dwp
|
ln -s $llvmBin/llvm-dwp $out/bin/${targetPrefix}dwp
|
||||||
ln -s $llvmBin/llvm-nm $out/bin/${targetPrefix}nm
|
ln -s $llvmBin/llvm-nm $out/bin/${targetPrefix}nm
|
||||||
ln -s $llvmBin/llvm-objcopy $out/bin/${targetPrefix}objcopy
|
ln -s $llvmBin/llvm-objcopy $out/bin/${targetPrefix}objcopy
|
||||||
ln -s $llvmBin/llvm-objcopy $out/bin/${targetPrefix}strip
|
ln -s $llvmBin/llvm-objcopy $out/bin/${targetPrefix}strip
|
||||||
ln -s $llvmBin/llvm-objdump $out/bin/${targetPrefix}objdump
|
ln -s $llvmBin/llvm-objdump $out/bin/${targetPrefix}objdump
|
||||||
ln -s $llvmBin/llvm-readobj $out/bin/${targetPrefix}readelf
|
ln -s $llvmBin/llvm-readobj $out/bin/${targetPrefix}readelf
|
||||||
ln -s $llvmBin/llvm-size $out/bin/${targetPrefix}size
|
ln -s $llvmBin/llvm-size $out/bin/${targetPrefix}size
|
||||||
ln -s $llvmBin/llvm-strings $out/bin/${targetPrefix}strings
|
ln -s $llvmBin/llvm-strings $out/bin/${targetPrefix}strings
|
||||||
ln -s $llvmBin/llvm-symbolizer $out/bin/${targetPrefix}addr2line
|
ln -s $llvmBin/llvm-symbolizer $out/bin/${targetPrefix}addr2line
|
||||||
|
|
||||||
if [ -e "$llvmBin/llvm-debuginfod" ]; then
|
if [ -e "$llvmBin/llvm-debuginfod" ]; then
|
||||||
ln -s $llvmBin/llvm-debuginfod $out/bin/${targetPrefix}debuginfod
|
ln -s $llvmBin/llvm-debuginfod $out/bin/${targetPrefix}debuginfod
|
||||||
ln -s $llvmBin/llvm-debuginfod-find $out/bin/${targetPrefix}debuginfod-find
|
ln -s $llvmBin/llvm-debuginfod-find $out/bin/${targetPrefix}debuginfod-find
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -s ${lld}/bin/lld $out/bin/${targetPrefix}ld
|
ln -s ${lld}/bin/lld $out/bin/${targetPrefix}ld
|
||||||
|
|
||||||
# Only >=13 show GNU windres compatible in help
|
# Only >=13 show GNU windres compatible in help
|
||||||
'' + lib.optionalString (lib.versionAtLeast release_version "13") ''
|
''
|
||||||
ln -s $llvmBin/llvm-rc $out/bin/${targetPrefix}windres
|
+ lib.optionalString (lib.versionAtLeast release_version "13") ''
|
||||||
'')
|
ln -s $llvmBin/llvm-rc $out/bin/${targetPrefix}windres
|
||||||
|
''
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,149 +1,209 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, llvm_meta
|
stdenv,
|
||||||
, patches ? []
|
llvm_meta,
|
||||||
, src ? null
|
patches ? [ ],
|
||||||
, monorepoSrc ? null
|
src ? null,
|
||||||
, runCommand
|
monorepoSrc ? null,
|
||||||
, substituteAll
|
runCommand,
|
||||||
, cmake
|
substituteAll,
|
||||||
, ninja
|
cmake,
|
||||||
, libxml2
|
ninja,
|
||||||
, libllvm
|
libxml2,
|
||||||
, release_version
|
libllvm,
|
||||||
, version
|
release_version,
|
||||||
, python3
|
version,
|
||||||
, buildLlvmTools
|
python3,
|
||||||
, fixDarwinDylibNames
|
buildLlvmTools,
|
||||||
, enableManpages ? false
|
fixDarwinDylibNames,
|
||||||
, clang-tools-extra_src ? null
|
enableManpages ? false,
|
||||||
|
clang-tools-extra_src ? null,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
pname = "clang";
|
pname = "clang";
|
||||||
|
|
||||||
src' = if monorepoSrc != null then
|
src' =
|
||||||
runCommand "${pname}-src-${version}" {} ''
|
if monorepoSrc != null then
|
||||||
mkdir -p "$out"
|
runCommand "${pname}-src-${version}" { } ''
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
mkdir -p "$out"
|
||||||
cp -r ${monorepoSrc}/${pname} "$out"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
cp -r ${monorepoSrc}/clang-tools-extra "$out"
|
cp -r ${monorepoSrc}/${pname} "$out"
|
||||||
'' else src;
|
cp -r ${monorepoSrc}/clang-tools-extra "$out"
|
||||||
|
''
|
||||||
self = stdenv.mkDerivation (finalAttrs: rec {
|
else
|
||||||
|
src;
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation (
|
||||||
|
finalAttrs:
|
||||||
|
rec {
|
||||||
inherit pname version patches;
|
inherit pname version patches;
|
||||||
|
|
||||||
src = src';
|
src = src';
|
||||||
|
|
||||||
sourceRoot = if lib.versionOlder release_version "13" then null
|
sourceRoot = if lib.versionOlder release_version "13" then null else "${src.name}/${pname}";
|
||||||
else "${src.name}/${pname}";
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ]
|
nativeBuildInputs =
|
||||||
++ (lib.optional (lib.versionAtLeast release_version "15") ninja)
|
[
|
||||||
++ [ python3 ]
|
cmake
|
||||||
|
ninja
|
||||||
|
python3
|
||||||
|
]
|
||||||
++ lib.optional (lib.versionAtLeast version "18" && enableManpages) python3.pkgs.myst-parser
|
++ lib.optional (lib.versionAtLeast version "18" && enableManpages) python3.pkgs.myst-parser
|
||||||
++ lib.optional enableManpages python3.pkgs.sphinx
|
++ lib.optional enableManpages python3.pkgs.sphinx
|
||||||
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
|
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
|
||||||
|
|
||||||
buildInputs = [ libxml2 libllvm ];
|
buildInputs = [
|
||||||
|
libxml2
|
||||||
|
libllvm
|
||||||
|
];
|
||||||
|
|
||||||
cmakeFlags = (lib.optionals (lib.versionAtLeast release_version "15") [
|
cmakeFlags =
|
||||||
"-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang"
|
[
|
||||||
]) ++ [
|
"-DCMAKE_INSTALL_PACKAGEDIR=${placeholder "dev"}/lib/"
|
||||||
"-DCLANGD_BUILD_XPC=OFF"
|
"-DCLANGD_BUILD_XPC=OFF"
|
||||||
"-DLLVM_ENABLE_RTTI=ON"
|
"-DLLVM_ENABLE_RTTI=ON"
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "17") [
|
(lib.cmakeBool "LLVM_INCLUDE_TESTS" finalAttrs.doCheck)
|
||||||
"-DLLVM_INCLUDE_TESTS=OFF"
|
]
|
||||||
] ++ lib.optionals enableManpages [
|
++ lib.optionals enableManpages [
|
||||||
"-DCLANG_INCLUDE_DOCS=ON"
|
"-DCLANG_INCLUDE_DOCS=ON"
|
||||||
"-DLLVM_ENABLE_SPHINX=ON"
|
"-DLLVM_ENABLE_SPHINX=ON"
|
||||||
"-DSPHINX_OUTPUT_MAN=ON"
|
"-DSPHINX_OUTPUT_MAN=ON"
|
||||||
"-DSPHINX_OUTPUT_HTML=OFF"
|
"-DSPHINX_OUTPUT_HTML=OFF"
|
||||||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
||||||
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) ([
|
]
|
||||||
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
|
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) (
|
||||||
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
|
[
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
|
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
|
||||||
# Added in LLVM15:
|
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
|
||||||
# `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb
|
]
|
||||||
# `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7
|
++ lib.optionals (lib.versionAtLeast release_version "15") [
|
||||||
"-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen"
|
# Added in LLVM15:
|
||||||
"-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen"
|
# `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb
|
||||||
]);
|
# `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7
|
||||||
|
"-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen"
|
||||||
|
"-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
postPatch = ''
|
postPatch =
|
||||||
# Make sure clang passes the correct location of libLTO to ld64
|
''
|
||||||
substituteInPlace lib/Driver/ToolChains/Darwin.cpp \
|
# Make sure clang passes the correct location of libLTO to ld64
|
||||||
--replace-fail 'StringRef P = llvm::sys::path::parent_path(D.Dir);' 'StringRef P = "${lib.getLib libllvm}";'
|
substituteInPlace lib/Driver/ToolChains/Darwin.cpp \
|
||||||
'' + (if lib.versionOlder release_version "13" then ''
|
--replace-fail 'StringRef P = llvm::sys::path::parent_path(D.Dir);' 'StringRef P = "${lib.getLib libllvm}";'
|
||||||
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
|
''
|
||||||
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
|
+ (
|
||||||
lib/Driver/ToolChains/*.cpp
|
if lib.versionOlder release_version "13" then
|
||||||
'' else ''
|
''
|
||||||
(cd tools && ln -s ../../clang-tools-extra extra)
|
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
|
||||||
'') + lib.optionalString stdenv.hostPlatform.isMusl ''
|
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
|
||||||
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
|
lib/Driver/ToolChains/*.cpp
|
||||||
'';
|
''
|
||||||
|
else
|
||||||
|
''
|
||||||
|
(cd tools && ln -s ../../clang-tools-extra extra)
|
||||||
|
''
|
||||||
|
)
|
||||||
|
+ lib.optionalString stdenv.hostPlatform.isMusl ''
|
||||||
|
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
|
||||||
|
'';
|
||||||
|
|
||||||
outputs = [ "out" "lib" "dev" "python" ];
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"lib"
|
||||||
|
"dev"
|
||||||
|
"python"
|
||||||
|
];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall =
|
||||||
ln -sv $out/bin/clang $out/bin/cpp
|
''
|
||||||
'' + (lib.optionalString (lib.versions.major release_version == "17") ''
|
ln -sv $out/bin/clang $out/bin/cpp
|
||||||
|
''
|
||||||
|
+ (lib.optionalString (lib.versions.major release_version == "17") ''
|
||||||
|
|
||||||
mkdir -p $lib/lib/clang
|
mkdir -p $lib/lib/clang
|
||||||
mv $lib/lib/17 $lib/lib/clang/17
|
mv $lib/lib/17 $lib/lib/clang/17
|
||||||
'') + ''
|
'')
|
||||||
|
+ ''
|
||||||
|
|
||||||
# Move libclang to 'lib' output
|
# Move libclang to 'lib' output
|
||||||
moveToOutput "lib/libclang.*" "$lib"
|
moveToOutput "lib/libclang.*" "$lib"
|
||||||
moveToOutput "lib/libclang-cpp.*" "$lib"
|
moveToOutput "lib/libclang-cpp.*" "$lib"
|
||||||
'' + (if lib.versionOlder release_version "15" then ''
|
''
|
||||||
substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
|
+ (
|
||||||
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
|
if lib.versionOlder release_version "15" then
|
||||||
--replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
|
''
|
||||||
'' else ''
|
substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
|
||||||
substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \
|
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
|
||||||
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
|
--replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
|
||||||
--replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
|
''
|
||||||
'') + ''
|
else
|
||||||
|
''
|
||||||
|
substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \
|
||||||
|
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
|
||||||
|
--replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
|
||||||
|
''
|
||||||
|
)
|
||||||
|
+ ''
|
||||||
|
|
||||||
'' + (if lib.versionOlder release_version "15" then ''
|
''
|
||||||
mkdir -p $python/bin $python/share/{clang,scan-view}
|
+ (
|
||||||
'' else ''
|
if lib.versionOlder release_version "15" then
|
||||||
mkdir -p $python/bin $python/share/clang/
|
''
|
||||||
'') + ''
|
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
|
else
|
||||||
mv $out/bin/set-xcode-analyzer $python/bin
|
''
|
||||||
fi
|
mkdir -p $python/bin $python/share/clang/
|
||||||
mv $out/share/clang/*.py $python/share/clang
|
''
|
||||||
'' + (lib.optionalString (lib.versionOlder release_version "15") ''
|
)
|
||||||
mv $out/share/scan-view/*.py $python/share/scan-view
|
+ ''
|
||||||
'') + ''
|
mv $out/bin/{git-clang-format,scan-view} $python/bin
|
||||||
rm $out/bin/c-index-test
|
if [ -e $out/bin/set-xcode-analyzer ]; then
|
||||||
patchShebangs $python/bin
|
mv $out/bin/set-xcode-analyzer $python/bin
|
||||||
|
fi
|
||||||
|
mv $out/share/clang/*.py $python/share/clang
|
||||||
|
''
|
||||||
|
+ (lib.optionalString (lib.versionOlder release_version "15") ''
|
||||||
|
mv $out/share/scan-view/*.py $python/share/scan-view
|
||||||
|
'')
|
||||||
|
+ ''
|
||||||
|
rm $out/bin/c-index-test
|
||||||
|
patchShebangs $python/bin
|
||||||
|
|
||||||
mkdir -p $dev/bin
|
mkdir -p $dev/bin
|
||||||
'' + (if lib.versionOlder release_version "15" then ''
|
''
|
||||||
cp bin/clang-tblgen $dev/bin
|
+ (
|
||||||
'' else ''
|
if lib.versionOlder release_version "15" then
|
||||||
cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin
|
''
|
||||||
'');
|
cp bin/clang-tblgen $dev/bin
|
||||||
|
''
|
||||||
|
else
|
||||||
|
''
|
||||||
|
cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
passthru = {
|
doCheck = false;
|
||||||
inherit libllvm;
|
|
||||||
isClang = true;
|
passthru =
|
||||||
} // (lib.optionalAttrs (lib.versionAtLeast release_version "15") {
|
{
|
||||||
hardeningUnsupportedFlags = [
|
inherit libllvm;
|
||||||
"fortify3"
|
isClang = true;
|
||||||
];
|
}
|
||||||
hardeningUnsupportedFlagsByTargetPlatform = targetPlatform:
|
// (lib.optionalAttrs (lib.versionAtLeast release_version "15") {
|
||||||
lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs"
|
hardeningUnsupportedFlags = [ "fortify3" ];
|
||||||
++ (finalAttrs.passthru.hardeningUnsupportedFlags or []);
|
hardeningUnsupportedFlagsByTargetPlatform =
|
||||||
}) // (lib.optionalAttrs (lib.versionOlder release_version "15") {
|
targetPlatform:
|
||||||
hardeningUnsupportedFlags = [ "fortify3" "zerocallusedregs" ];
|
lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs"
|
||||||
});
|
++ (finalAttrs.passthru.hardeningUnsupportedFlags or [ ]);
|
||||||
|
})
|
||||||
|
// (lib.optionalAttrs (lib.versionOlder release_version "15") {
|
||||||
|
hardeningUnsupportedFlags = [
|
||||||
|
"fortify3"
|
||||||
|
"zerocallusedregs"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
meta = llvm_meta // {
|
meta = llvm_meta // {
|
||||||
homepage = "https://clang.llvm.org/";
|
homepage = "https://clang.llvm.org/";
|
||||||
@@ -161,7 +221,8 @@ let
|
|||||||
'';
|
'';
|
||||||
mainProgram = "clang";
|
mainProgram = "clang";
|
||||||
};
|
};
|
||||||
} // lib.optionalAttrs enableManpages ({
|
}
|
||||||
|
// lib.optionalAttrs enableManpages {
|
||||||
pname = "clang-manpages";
|
pname = "clang-manpages";
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
@@ -177,29 +238,26 @@ let
|
|||||||
meta = llvm_meta // {
|
meta = llvm_meta // {
|
||||||
description = "man page for Clang ${version}";
|
description = "man page for Clang ${version}";
|
||||||
};
|
};
|
||||||
} // (if lib.versionOlder release_version "15" then {
|
|
||||||
buildPhase = ''
|
|
||||||
make docs-clang-man
|
|
||||||
'';
|
|
||||||
} else {
|
|
||||||
ninjaFlags = [ "docs-clang-man" ];
|
ninjaFlags = [ "docs-clang-man" ];
|
||||||
})) // (lib.optionalAttrs (clang-tools-extra_src != null) { inherit clang-tools-extra_src; })
|
}
|
||||||
// (lib.optionalAttrs (lib.versionOlder release_version "13") {
|
// (lib.optionalAttrs (clang-tools-extra_src != null) { inherit clang-tools-extra_src; })
|
||||||
unpackPhase = ''
|
// (lib.optionalAttrs (lib.versionOlder release_version "13") {
|
||||||
unpackFile $src
|
unpackPhase = ''
|
||||||
mv clang-* clang
|
unpackFile $src
|
||||||
sourceRoot=$PWD/clang
|
mv clang-* clang
|
||||||
unpackFile ${clang-tools-extra_src}
|
sourceRoot=$PWD/clang
|
||||||
mv clang-tools-extra-* $sourceRoot/tools/extra
|
unpackFile ${clang-tools-extra_src}
|
||||||
substituteInPlace $sourceRoot/tools/extra/clangd/quality/CompletionModel.cmake \
|
mv clang-tools-extra-* $sourceRoot/tools/extra
|
||||||
--replace ' ''${CMAKE_SOURCE_DIR}/../clang-tools-extra' ' ''${CMAKE_SOURCE_DIR}/tools/extra'
|
substituteInPlace $sourceRoot/tools/extra/clangd/quality/CompletionModel.cmake \
|
||||||
'';
|
--replace ' ''${CMAKE_SOURCE_DIR}/../clang-tools-extra' ' ''${CMAKE_SOURCE_DIR}/tools/extra'
|
||||||
})
|
'';
|
||||||
|
})
|
||||||
// (lib.optionalAttrs (lib.versionAtLeast release_version "15") {
|
// (lib.optionalAttrs (lib.versionAtLeast release_version "15") {
|
||||||
env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
|
env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
|
||||||
# The following warning is triggered with (at least) gcc >=
|
# The following warning is triggered with (at least) gcc >=
|
||||||
# 12, but appears to occur only for cross compiles.
|
# 12, but appears to occur only for cross compiles.
|
||||||
NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized";
|
NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized";
|
||||||
};
|
};
|
||||||
}));
|
})
|
||||||
in self
|
)
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
{ lib
|
{
|
||||||
, fetchFromGitHub ? null
|
lib,
|
||||||
, release_version ? null
|
fetchFromGitHub ? null,
|
||||||
, gitRelease ? null
|
release_version ? null,
|
||||||
, officialRelease ? null
|
gitRelease ? null,
|
||||||
, monorepoSrc' ? null
|
officialRelease ? null,
|
||||||
|
monorepoSrc' ? null,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
@@ -13,31 +14,31 @@ rec {
|
|||||||
|
|
||||||
# See llvm/cmake/config-ix.cmake.
|
# See llvm/cmake/config-ix.cmake.
|
||||||
platforms =
|
platforms =
|
||||||
lib.platforms.aarch64 ++
|
lib.platforms.aarch64
|
||||||
lib.platforms.arm ++
|
++ lib.platforms.arm
|
||||||
lib.platforms.mips ++
|
++ lib.platforms.mips
|
||||||
lib.platforms.power ++
|
++ lib.platforms.power
|
||||||
lib.platforms.s390x ++
|
++ lib.platforms.s390x
|
||||||
lib.platforms.wasi ++
|
++ lib.platforms.wasi
|
||||||
lib.platforms.x86 ++
|
++ lib.platforms.x86
|
||||||
lib.optionals (lib.versionAtLeast release_version "7") lib.platforms.riscv ++
|
++ lib.optionals (lib.versionAtLeast release_version "7") lib.platforms.riscv
|
||||||
lib.optionals (lib.versionAtLeast release_version "14") lib.platforms.m68k;
|
++ lib.optionals (lib.versionAtLeast release_version "14") lib.platforms.m68k;
|
||||||
};
|
};
|
||||||
|
|
||||||
releaseInfo =
|
releaseInfo =
|
||||||
if gitRelease != null then rec {
|
if gitRelease != null then
|
||||||
original = gitRelease;
|
rec {
|
||||||
release_version = original.version;
|
original = gitRelease;
|
||||||
version = gitRelease.rev-version;
|
release_version = original.version;
|
||||||
} else rec {
|
version = gitRelease.rev-version;
|
||||||
original = officialRelease;
|
}
|
||||||
release_version = original.version;
|
else
|
||||||
version =
|
rec {
|
||||||
if original ? candidate then
|
original = officialRelease;
|
||||||
"${release_version}-${original.candidate}"
|
release_version = original.version;
|
||||||
else
|
version =
|
||||||
release_version;
|
if original ? candidate then "${release_version}-${original.candidate}" else release_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
monorepoSrc =
|
monorepoSrc =
|
||||||
if monorepoSrc' != null then
|
if monorepoSrc' != null then
|
||||||
@@ -45,16 +46,11 @@ rec {
|
|||||||
else
|
else
|
||||||
let
|
let
|
||||||
sha256 = releaseInfo.original.sha256;
|
sha256 = releaseInfo.original.sha256;
|
||||||
rev =
|
rev = if gitRelease != null then gitRelease.rev else "llvmorg-${releaseInfo.version}";
|
||||||
if gitRelease != null then
|
|
||||||
gitRelease.rev
|
|
||||||
else
|
|
||||||
"llvmorg-${releaseInfo.version}";
|
|
||||||
in
|
in
|
||||||
fetchFromGitHub {
|
fetchFromGitHub {
|
||||||
owner = "llvm";
|
owner = "llvm";
|
||||||
repo = "llvm-project";
|
repo = "llvm-project";
|
||||||
inherit rev sha256;
|
inherit rev sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, llvm_meta
|
stdenv,
|
||||||
, release_version
|
llvm_meta,
|
||||||
, version
|
release_version,
|
||||||
, patches ? []
|
version,
|
||||||
, src ? null
|
patches ? [ ],
|
||||||
, monorepoSrc ? null
|
src ? null,
|
||||||
, runCommand
|
monorepoSrc ? null,
|
||||||
, cmake
|
runCommand,
|
||||||
, ninja
|
cmake,
|
||||||
, python3
|
ninja,
|
||||||
, xcbuild
|
python3,
|
||||||
, libllvm
|
xcbuild,
|
||||||
, linuxHeaders
|
libllvm,
|
||||||
, libxcrypt
|
linuxHeaders,
|
||||||
, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
|
libxcrypt,
|
||||||
|
doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@@ -22,158 +23,204 @@ let
|
|||||||
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
||||||
haveLibc = stdenv.cc.libc != null;
|
haveLibc = stdenv.cc.libc != null;
|
||||||
isDarwinStatic = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic && lib.versionAtLeast release_version "16";
|
isDarwinStatic =
|
||||||
|
stdenv.hostPlatform.isDarwin
|
||||||
|
&& stdenv.hostPlatform.isStatic
|
||||||
|
&& lib.versionAtLeast release_version "16";
|
||||||
inherit (stdenv.hostPlatform) isMusl isAarch64;
|
inherit (stdenv.hostPlatform) isMusl isAarch64;
|
||||||
|
|
||||||
baseName = "compiler-rt";
|
baseName = "compiler-rt";
|
||||||
pname = baseName + lib.optionalString (haveLibc) "-libc";
|
pname = baseName + lib.optionalString (haveLibc) "-libc";
|
||||||
|
|
||||||
src' = if monorepoSrc != null then
|
src' =
|
||||||
runCommand "${baseName}-src-${version}" {} ''
|
if monorepoSrc != null then
|
||||||
mkdir -p "$out"
|
runCommand "${baseName}-src-${version}" { } ''
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
mkdir -p "$out"
|
||||||
cp -r ${monorepoSrc}/${baseName} "$out"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
'' else src;
|
cp -r ${monorepoSrc}/${baseName} "$out"
|
||||||
|
''
|
||||||
|
else
|
||||||
|
src;
|
||||||
|
|
||||||
preConfigure = lib.optionalString (useLLVM && !haveLibc) ''
|
preConfigure = lib.optionalString (useLLVM && !haveLibc) ''
|
||||||
cmakeFlagsArray+=(-DCMAKE_C_FLAGS="-nodefaultlibs -ffreestanding")
|
cmakeFlagsArray+=(-DCMAKE_C_FLAGS="-nodefaultlibs -ffreestanding")
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation (
|
||||||
inherit pname version patches;
|
{
|
||||||
|
inherit pname version patches;
|
||||||
|
|
||||||
src = src';
|
src = src';
|
||||||
sourceRoot = if lib.versionOlder release_version "13" then null
|
sourceRoot = if lib.versionOlder release_version "13" then null else "${src'.name}/${baseName}";
|
||||||
else "${src'.name}/${baseName}";
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ]
|
nativeBuildInputs =
|
||||||
++ (lib.optional (lib.versionAtLeast release_version "15") ninja)
|
[ cmake ]
|
||||||
++ [ python3 libllvm.dev ]
|
++ (lib.optional (lib.versionAtLeast release_version "15") ninja)
|
||||||
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
|
++ [
|
||||||
buildInputs =
|
python3
|
||||||
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
|
libllvm.dev
|
||||||
|
]
|
||||||
|
++ lib.optional stdenv.isDarwin xcbuild.xcrun;
|
||||||
|
buildInputs = lib.optional (
|
||||||
|
stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV
|
||||||
|
) linuxHeaders;
|
||||||
|
|
||||||
env.NIX_CFLAGS_COMPILE = toString ([
|
env.NIX_CFLAGS_COMPILE = toString (
|
||||||
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
|
[ "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" ]
|
||||||
] ++ lib.optionals (!haveLibc) [
|
++ lib.optionals (!haveLibc) [
|
||||||
# The compiler got stricter about this, and there is a usellvm patch below
|
# The compiler got stricter about this, and there is a usellvm patch below
|
||||||
# which patches out the assert include causing an implicit definition of
|
# which patches out the assert include causing an implicit definition of
|
||||||
# assert. It would be nicer to understand why compiler-rt thinks it should
|
# assert. It would be nicer to understand why compiler-rt thinks it should
|
||||||
# be able to #include <assert.h> in the first place; perhaps it's in the
|
# be able to #include <assert.h> in the first place; perhaps it's in the
|
||||||
# wrong, or perhaps there is a way to provide an assert.h.
|
# wrong, or perhaps there is a way to provide an assert.h.
|
||||||
"-Wno-error=implicit-function-declaration"
|
"-Wno-error=implicit-function-declaration"
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags =
|
||||||
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
|
[
|
||||||
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
|
||||||
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
||||||
] ++ lib.optionals (haveLibc && stdenv.hostPlatform.libc == "glibc") [
|
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
||||||
"-DSANITIZER_COMMON_CFLAGS=-I${libxcrypt}/include"
|
]
|
||||||
] ++ lib.optionals ((useLLVM || bareMetal || isMusl || isAarch64) && (lib.versions.major release_version == "13")) [
|
++ lib.optionals (haveLibc && stdenv.hostPlatform.libc == "glibc") [
|
||||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
"-DSANITIZER_COMMON_CFLAGS=-I${libxcrypt}/include"
|
||||||
] ++ lib.optionals (useLLVM || bareMetal || isMusl || isDarwinStatic) [
|
]
|
||||||
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
++ lib.optionals (
|
||||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
(useLLVM || bareMetal || isMusl || isAarch64) && (lib.versions.major release_version == "13")
|
||||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
) [ "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" ]
|
||||||
"-DCOMPILER_RT_BUILD_MEMPROF=OFF"
|
++ lib.optionals (useLLVM || bareMetal || isMusl || isDarwinStatic) [
|
||||||
"-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary
|
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
||||||
] ++ lib.optionals (useLLVM || bareMetal) [
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||||
] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal || isDarwinStatic) [
|
"-DCOMPILER_RT_BUILD_MEMPROF=OFF"
|
||||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
"-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary
|
||||||
] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal) [
|
]
|
||||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
++ lib.optionals (useLLVM || bareMetal) [ "-DCOMPILER_RT_BUILD_PROFILE=OFF" ]
|
||||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
++ lib.optionals ((useLLVM && !haveLibc) || bareMetal || isDarwinStatic) [
|
||||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
] ++ lib.optionals (useLLVM && !haveLibc) [
|
]
|
||||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
++ lib.optionals ((useLLVM && !haveLibc) || bareMetal) [
|
||||||
] ++ lib.optionals (useLLVM) [
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
]
|
||||||
] ++ lib.optionals (bareMetal) [
|
++ lib.optionals (useLLVM && !haveLibc) [ "-DCMAKE_C_FLAGS=-nodefaultlibs" ]
|
||||||
"-DCOMPILER_RT_OS_DIR=baremetal"
|
++ lib.optionals (useLLVM) [
|
||||||
] ++ lib.optionals (stdenv.hostPlatform.isDarwin) (lib.optionals (lib.versionAtLeast release_version "16") [
|
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||||
"-DCMAKE_LIPO=${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}lipo"
|
#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"
|
||||||
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
|
]
|
||||||
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
|
++ lib.optionals (bareMetal) [ "-DCOMPILER_RT_OS_DIR=baremetal" ]
|
||||||
"-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}"
|
++ lib.optionals (stdenv.hostPlatform.isDarwin) (
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
|
lib.optionals (lib.versionAtLeast release_version "16") [
|
||||||
# `COMPILER_RT_DEFAULT_TARGET_ONLY` does not apply to Darwin:
|
"-DCMAKE_LIPO=${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}lipo"
|
||||||
# https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/base-config-ix.cmake#L153
|
]
|
||||||
"-DCOMPILER_RT_ENABLE_IOS=OFF"
|
++ [
|
||||||
]) ++ lib.optionals (lib.versionAtLeast version "19" && stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
|
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
|
||||||
"-DSANITIZER_MIN_OSX_VERSION=10.10"
|
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
|
||||||
];
|
"-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}"
|
||||||
|
]
|
||||||
|
++ lib.optionals (lib.versionAtLeast release_version "15") [
|
||||||
|
# `COMPILER_RT_DEFAULT_TARGET_ONLY` does not apply to Darwin:
|
||||||
|
# https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/base-config-ix.cmake#L153
|
||||||
|
"-DCOMPILER_RT_ENABLE_IOS=OFF"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
++ lib.optionals (
|
||||||
|
lib.versionAtLeast version "19"
|
||||||
|
&& stdenv.isDarwin
|
||||||
|
&& lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13"
|
||||||
|
) [ "-DSANITIZER_MIN_OSX_VERSION=10.10" ];
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"dev"
|
||||||
|
];
|
||||||
|
|
||||||
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
# 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
|
# 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
|
# 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
|
# 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.
|
# a flag and turn the flag off during the stdenv build.
|
||||||
postPatch = lib.optionalString (!stdenv.isDarwin) ''
|
postPatch =
|
||||||
substituteInPlace cmake/builtin-config-ix.cmake \
|
lib.optionalString (!stdenv.isDarwin) ''
|
||||||
--replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
|
substituteInPlace cmake/builtin-config-ix.cmake \
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
--replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
|
||||||
substituteInPlace cmake/config-ix.cmake \
|
''
|
||||||
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
|
+ lib.optionalString stdenv.isDarwin ''
|
||||||
'' + lib.optionalString (useLLVM && !haveLibc) ((lib.optionalString (lib.versionAtLeast release_version "18") ''
|
substituteInPlace cmake/config-ix.cmake \
|
||||||
substituteInPlace lib/builtins/aarch64/sme-libc-routines.c \
|
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
|
||||||
--replace "<stdlib.h>" "<stddef.h>"
|
''
|
||||||
'') + ''
|
+ lib.optionalString (useLLVM && !haveLibc) (
|
||||||
substituteInPlace lib/builtins/int_util.c \
|
(lib.optionalString (lib.versionAtLeast release_version "18") ''
|
||||||
--replace "#include <stdlib.h>" ""
|
substituteInPlace lib/builtins/aarch64/sme-libc-routines.c \
|
||||||
'' + (if stdenv.hostPlatform.isFreeBSD then
|
--replace "<stdlib.h>" "<stddef.h>"
|
||||||
# As per above, but in FreeBSD assert is a macro and simply allowing it to be implicitly declared causes Issues!!!!!
|
'')
|
||||||
''
|
+ ''
|
||||||
substituteInPlace lib/builtins/clear_cache.c lib/builtins/cpu_model.c \
|
substituteInPlace lib/builtins/int_util.c \
|
||||||
--replace "#include <assert.h>" "#define assert(e) ((e)?(void)0:__assert(__FUNCTION__,__FILE__,__LINE__,#e))"
|
--replace "#include <stdlib.h>" ""
|
||||||
'' else ''
|
''
|
||||||
substituteInPlace lib/builtins/clear_cache.c \
|
+ (
|
||||||
--replace "#include <assert.h>" ""
|
if stdenv.hostPlatform.isFreeBSD then
|
||||||
substituteInPlace lib/builtins/cpu_model${lib.optionalString (lib.versionAtLeast version "18") "/x86"}.c \
|
# As per above, but in FreeBSD assert is a macro and simply allowing it to be implicitly declared causes Issues!!!!!
|
||||||
--replace "#include <assert.h>" ""
|
''
|
||||||
''));
|
substituteInPlace lib/builtins/clear_cache.c lib/builtins/cpu_model.c \
|
||||||
|
--replace "#include <assert.h>" "#define assert(e) ((e)?(void)0:__assert(__FUNCTION__,__FILE__,__LINE__,#e))"
|
||||||
|
''
|
||||||
|
else
|
||||||
|
''
|
||||||
|
substituteInPlace lib/builtins/clear_cache.c \
|
||||||
|
--replace "#include <assert.h>" ""
|
||||||
|
substituteInPlace lib/builtins/cpu_model${lib.optionalString (lib.versionAtLeast version "18") "/x86"}.c \
|
||||||
|
--replace "#include <assert.h>" ""
|
||||||
|
''
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
# Hack around weird upsream RPATH bug
|
# Hack around weird upsream RPATH bug
|
||||||
postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
postInstall =
|
||||||
ln -s "$out/lib"/*/* "$out/lib"
|
lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
||||||
'' + lib.optionalString (useLLVM && stdenv.hostPlatform.isLinux) ''
|
ln -s "$out/lib"/*/* "$out/lib"
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
|
''
|
||||||
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
|
+ lib.optionalString (useLLVM && stdenv.hostPlatform.isLinux) ''
|
||||||
# Note the history of crt{begin,end}S in previous versions of llvm in nixpkg:
|
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
|
||||||
# The presence of crtbegin_shared has been added and removed; it's possible
|
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
|
||||||
# people have added/removed it to get it working on their platforms.
|
# Note the history of crt{begin,end}S in previous versions of llvm in nixpkg:
|
||||||
# Try each in turn for now.
|
# The presence of crtbegin_shared has been added and removed; it's possible
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o
|
# people have added/removed it to get it working on their platforms.
|
||||||
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o
|
# Try each in turn for now.
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o
|
||||||
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o
|
||||||
'' + lib.optionalString doFakeLibgcc ''
|
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
||||||
ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a
|
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 // {
|
meta = llvm_meta // {
|
||||||
homepage = "https://compiler-rt.llvm.org/";
|
homepage = "https://compiler-rt.llvm.org/";
|
||||||
description = "Compiler runtime libraries";
|
description = "Compiler runtime libraries";
|
||||||
longDescription = ''
|
longDescription = ''
|
||||||
The compiler-rt project provides highly tuned implementations of the
|
The compiler-rt project provides highly tuned implementations of the
|
||||||
low-level code generator support routines like "__fixunsdfdi" and other
|
low-level code generator support routines like "__fixunsdfdi" and other
|
||||||
calls generated when a target doesn't have a short sequence of native
|
calls generated when a target doesn't have a short sequence of native
|
||||||
instructions to implement a core IR operation. It also provides
|
instructions to implement a core IR operation. It also provides
|
||||||
implementations of run-time libraries for dynamic testing tools such as
|
implementations of run-time libraries for dynamic testing tools such as
|
||||||
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
|
AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
|
||||||
'';
|
'';
|
||||||
# "All of the code in the compiler-rt project is dual licensed under the MIT
|
# "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 and the UIUC License (a BSD-like license)":
|
||||||
license = with lib.licenses; [ mit ncsa ];
|
license = with lib.licenses; [
|
||||||
# compiler-rt requires a Clang stdenv on 32-bit RISC-V:
|
mit
|
||||||
# https://reviews.llvm.org/D43106#1019077
|
ncsa
|
||||||
broken = stdenv.hostPlatform.isRiscV32 && !stdenv.cc.isClang;
|
];
|
||||||
};
|
# compiler-rt requires a Clang stdenv on 32-bit RISC-V:
|
||||||
} // (if lib.versionOlder release_version "16" then { inherit preConfigure; } else {}))
|
# https://reviews.llvm.org/D43106#1019077
|
||||||
|
broken = stdenv.hostPlatform.isRiscV32 && !stdenv.cc.isClang;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// (if lib.versionOlder release_version "16" then { inherit preConfigure; } else { })
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
{ lib, stdenv, version, runCommand, monorepoSrc, llvm, buildPackages, buildLlvmTools, ninja, cmake, python3 }:
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
version,
|
||||||
|
runCommand,
|
||||||
|
monorepoSrc,
|
||||||
|
llvm,
|
||||||
|
buildPackages,
|
||||||
|
buildLlvmTools,
|
||||||
|
ninja,
|
||||||
|
cmake,
|
||||||
|
python3,
|
||||||
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "libclc";
|
pname = "libclc";
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
src = runCommand "${pname}-src-${version}" {} ''
|
src = runCommand "${pname}-src-${version}" { } ''
|
||||||
mkdir -p "$out"
|
mkdir -p "$out"
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
cp -r ${monorepoSrc}/${pname} "$out"
|
cp -r ${monorepoSrc}/${pname} "$out"
|
||||||
@@ -12,31 +24,40 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
sourceRoot = "${src.name}/${pname}";
|
sourceRoot = "${src.name}/${pname}";
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [
|
||||||
|
"out"
|
||||||
patches = [
|
"dev"
|
||||||
./libclc/libclc-gnu-install-dirs.patch
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# cmake expects all required binaries to be in the same place, so it will not be able to find clang without the patch
|
patches = [ ./libclc/libclc-gnu-install-dirs.patch ];
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace CMakeLists.txt \
|
|
||||||
--replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
|
||||||
'find_program( LLVM_CLANG clang PATHS "${buildLlvmTools.clang.cc}/bin" NO_DEFAULT_PATH )' \
|
|
||||||
--replace 'find_program( LLVM_AS llvm-as PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
|
||||||
'find_program( LLVM_AS llvm-as PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
|
|
||||||
--replace 'find_program( LLVM_LINK llvm-link PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
|
||||||
'find_program( LLVM_LINK llvm-link PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
|
|
||||||
--replace 'find_program( LLVM_OPT opt PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
|
||||||
'find_program( LLVM_OPT opt PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
|
|
||||||
--replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
|
||||||
'find_program( LLVM_SPIRV llvm-spirv PATHS "${buildPackages.spirv-llvm-translator.override { inherit (buildLlvmTools) llvm; }}/bin" NO_DEFAULT_PATH )'
|
|
||||||
'' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
|
||||||
substituteInPlace CMakeLists.txt \
|
|
||||||
--replace 'COMMAND prepare_builtins' 'COMMAND ${buildLlvmTools.libclc.dev}/bin/prepare_builtins'
|
|
||||||
'';
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ninja python3 ];
|
# cmake expects all required binaries to be in the same place, so it will not be able to find clang without the patch
|
||||||
|
postPatch =
|
||||||
|
''
|
||||||
|
substituteInPlace CMakeLists.txt \
|
||||||
|
--replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
||||||
|
'find_program( LLVM_CLANG clang PATHS "${buildLlvmTools.clang.cc}/bin" NO_DEFAULT_PATH )' \
|
||||||
|
--replace 'find_program( LLVM_AS llvm-as PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
||||||
|
'find_program( LLVM_AS llvm-as PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
|
||||||
|
--replace 'find_program( LLVM_LINK llvm-link PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
||||||
|
'find_program( LLVM_LINK llvm-link PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
|
||||||
|
--replace 'find_program( LLVM_OPT opt PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
||||||
|
'find_program( LLVM_OPT opt PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \
|
||||||
|
--replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \
|
||||||
|
'find_program( LLVM_SPIRV llvm-spirv PATHS "${
|
||||||
|
buildPackages.spirv-llvm-translator.override { inherit (buildLlvmTools) llvm; }
|
||||||
|
}/bin" NO_DEFAULT_PATH )'
|
||||||
|
''
|
||||||
|
+ lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
||||||
|
substituteInPlace CMakeLists.txt \
|
||||||
|
--replace 'COMMAND prepare_builtins' 'COMMAND ${buildLlvmTools.libclc.dev}/bin/prepare_builtins'
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
cmake
|
||||||
|
ninja
|
||||||
|
python3
|
||||||
|
];
|
||||||
buildInputs = [ llvm ];
|
buildInputs = [ llvm ];
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, llvm_meta
|
stdenv,
|
||||||
, release_version
|
llvm_meta,
|
||||||
, monorepoSrc ? null
|
release_version,
|
||||||
, src ? null
|
monorepoSrc ? null,
|
||||||
, patches ? []
|
src ? null,
|
||||||
, runCommand
|
patches ? [ ],
|
||||||
, substitute
|
runCommand,
|
||||||
, cmake
|
substitute,
|
||||||
, lndir
|
cmake,
|
||||||
, ninja
|
lndir,
|
||||||
, python3
|
ninja,
|
||||||
, fixDarwinDylibNames
|
python3,
|
||||||
, version
|
fixDarwinDylibNames,
|
||||||
, cxxabi ? null
|
version,
|
||||||
, libcxxrt
|
cxxabi ? null,
|
||||||
, libunwind
|
libcxxrt,
|
||||||
, enableShared ? !stdenv.hostPlatform.isStatic
|
libunwind,
|
||||||
|
enableShared ? !stdenv.hostPlatform.isStatic,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# note: our setup using libcxxabi instead of libcxxrt on FreeBSD diverges from
|
# note: our setup using libcxxabi instead of libcxxrt on FreeBSD diverges from
|
||||||
@@ -37,156 +38,200 @@ let
|
|||||||
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
|
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
|
||||||
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
|
|
||||||
src' = if monorepoSrc != null then
|
src' =
|
||||||
runCommand "${pname}-src-${version}" {} (''
|
if monorepoSrc != null then
|
||||||
mkdir -p "$out/llvm"
|
runCommand "${pname}-src-${version}" { } (
|
||||||
'' + (lib.optionalString (lib.versionAtLeast release_version "14") ''
|
''
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
mkdir -p "$out/llvm"
|
||||||
'') + ''
|
''
|
||||||
cp -r ${monorepoSrc}/libcxx "$out"
|
+ (lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||||
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
|
'')
|
||||||
'' + (lib.optionalString (lib.versionAtLeast release_version "14") ''
|
+ ''
|
||||||
cp -r ${monorepoSrc}/third-party "$out"
|
cp -r ${monorepoSrc}/libcxx "$out"
|
||||||
'') + ''
|
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
|
||||||
cp -r ${monorepoSrc}/runtimes "$out"
|
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
|
||||||
'' + (lib.optionalString (cxxabi == null) ''
|
''
|
||||||
cp -r ${monorepoSrc}/libcxxabi "$out"
|
+ (lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||||
'')) else src;
|
cp -r ${monorepoSrc}/third-party "$out"
|
||||||
|
'')
|
||||||
|
+ ''
|
||||||
|
cp -r ${monorepoSrc}/runtimes "$out"
|
||||||
|
''
|
||||||
|
+ (lib.optionalString (cxxabi == null) ''
|
||||||
|
cp -r ${monorepoSrc}/libcxxabi "$out"
|
||||||
|
'')
|
||||||
|
)
|
||||||
|
else
|
||||||
|
src;
|
||||||
|
|
||||||
cxxabiCMakeFlags = lib.optionals (lib.versionAtLeast release_version "18") [
|
cxxabiCMakeFlags =
|
||||||
"-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
|
lib.optionals (lib.versionAtLeast release_version "18") [ "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF" ]
|
||||||
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) (if lib.versionAtLeast release_version "18" then [
|
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) (
|
||||||
"-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind"
|
if lib.versionAtLeast release_version "18" then
|
||||||
"-DLIBCXXABI_USE_COMPILER_RT=ON"
|
[
|
||||||
] else [
|
"-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind"
|
||||||
"-DLIBCXXABI_USE_COMPILER_RT=ON"
|
"-DLIBCXXABI_USE_COMPILER_RT=ON"
|
||||||
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
|
]
|
||||||
]) ++ lib.optionals stdenv.hostPlatform.isWasm [
|
else
|
||||||
"-DLIBCXXABI_ENABLE_THREADS=OFF"
|
[
|
||||||
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
|
"-DLIBCXXABI_USE_COMPILER_RT=ON"
|
||||||
] ++ lib.optionals (!enableShared) [
|
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
|
||||||
"-DLIBCXXABI_ENABLE_SHARED=OFF"
|
]
|
||||||
];
|
)
|
||||||
|
++ lib.optionals stdenv.hostPlatform.isWasm [
|
||||||
|
"-DLIBCXXABI_ENABLE_THREADS=OFF"
|
||||||
|
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
|
||||||
|
]
|
||||||
|
++ lib.optionals (!enableShared) [ "-DLIBCXXABI_ENABLE_SHARED=OFF" ];
|
||||||
|
|
||||||
cxxCMakeFlags = [
|
cxxCMakeFlags =
|
||||||
"-DLIBCXX_CXX_ABI=${cxxabiName}"
|
[ "-DLIBCXX_CXX_ABI=${cxxabiName}" ]
|
||||||
] ++ lib.optionals (cxxabi == null && lib.versionAtLeast release_version "16") [
|
++ lib.optionals (cxxabi == null && lib.versionAtLeast release_version "16") [
|
||||||
# Note: llvm < 16 doesn't support this flag (or it's broken); handled in postInstall instead.
|
# Note: llvm < 16 doesn't support this flag (or it's broken); handled in postInstall instead.
|
||||||
# Include libc++abi symbols within libc++.a for static linking libc++;
|
# Include libc++abi symbols within libc++.a for static linking libc++;
|
||||||
# dynamic linking includes them through libc++.so being a linker script
|
# dynamic linking includes them through libc++.so being a linker script
|
||||||
# which includes both shared objects.
|
# which includes both shared objects.
|
||||||
"-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON"
|
"-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON"
|
||||||
] ++ lib.optionals (cxxabi != null) [
|
]
|
||||||
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
|
++ lib.optionals (cxxabi != null) [ "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include" ]
|
||||||
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
|
++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
|
||||||
"-DLIBCXX_HAS_MUSL_LIBC=1"
|
"-DLIBCXX_HAS_MUSL_LIBC=1"
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
|
]
|
||||||
"-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
|
++ lib.optionals (
|
||||||
] ++ lib.optionals useLLVM [
|
lib.versionAtLeast release_version "18"
|
||||||
"-DLIBCXX_USE_COMPILER_RT=ON"
|
&& !useLLVM
|
||||||
] ++ lib.optionals (useLLVM && lib.versionAtLeast release_version "16") [
|
&& stdenv.hostPlatform.libc == "glibc"
|
||||||
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
|
&& !stdenv.hostPlatform.isStatic
|
||||||
] ++ lib.optionals stdenv.hostPlatform.isWasm [
|
) [ "-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s" ]
|
||||||
"-DLIBCXX_ENABLE_THREADS=OFF"
|
++ lib.optionals useLLVM [ "-DLIBCXX_USE_COMPILER_RT=ON" ]
|
||||||
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
|
++ lib.optionals (useLLVM && lib.versionAtLeast release_version "16") [
|
||||||
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
|
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
|
||||||
] ++ lib.optionals (!enableShared) [
|
]
|
||||||
"-DLIBCXX_ENABLE_SHARED=OFF"
|
++ lib.optionals stdenv.hostPlatform.isWasm [
|
||||||
];
|
"-DLIBCXX_ENABLE_THREADS=OFF"
|
||||||
|
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
|
||||||
|
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
|
||||||
|
]
|
||||||
|
++ lib.optionals (!enableShared) [ "-DLIBCXX_ENABLE_SHARED=OFF" ];
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags =
|
||||||
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
|
[ "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}" ]
|
||||||
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
|
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
|
||||||
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
|
# libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib,
|
||||||
# but that does not appear to be the case for example when building
|
# but that does not appear to be the case for example when building
|
||||||
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
|
# pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc).
|
||||||
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
|
"-DCMAKE_EXE_LINKER_FLAGS=-nostdlib"
|
||||||
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
|
"-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib"
|
||||||
] ++ lib.optionals stdenv.hostPlatform.isWasm [
|
]
|
||||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
++ lib.optionals stdenv.hostPlatform.isWasm [
|
||||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
] ++ cxxCMakeFlags
|
"-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
|
||||||
|
]
|
||||||
|
++ cxxCMakeFlags
|
||||||
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
|
++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
stdenv.mkDerivation (
|
||||||
inherit pname version cmakeFlags patches;
|
rec {
|
||||||
|
inherit
|
||||||
|
pname
|
||||||
|
version
|
||||||
|
cmakeFlags
|
||||||
|
patches
|
||||||
|
;
|
||||||
|
|
||||||
src = src';
|
src = src';
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"dev"
|
||||||
|
];
|
||||||
|
|
||||||
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
|
preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
|
||||||
patchShebangs utils/cat_files.py
|
patchShebangs utils/cat_files.py
|
||||||
'';
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ninja python3 ]
|
|
||||||
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
|
|
||||||
++ lib.optional (cxxabi != null) lndir;
|
|
||||||
|
|
||||||
buildInputs = [ cxxabi ]
|
|
||||||
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
|
|
||||||
|
|
||||||
# libc++.so is a linker script which expands to multiple libraries,
|
|
||||||
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
|
|
||||||
# support linker scripts so the external cxxabi needs to be symlinked in
|
|
||||||
postInstall = lib.optionalString (cxxabi != null) ''
|
|
||||||
lndir ${lib.getDev cxxabi}/include $dev/include/c++/v1
|
|
||||||
lndir ${lib.getLib cxxabi}/lib $out/lib
|
|
||||||
libcxxabi=$out/lib/lib${cxxabi.libName}.a
|
|
||||||
''
|
|
||||||
# LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON doesn't work for LLVM < 16 or
|
|
||||||
# external cxxabi libraries so merge libc++abi.a into libc++.a ourselves.
|
|
||||||
|
|
||||||
# GNU binutils emits objects in LIFO order in MRI scripts so after the merge
|
|
||||||
# the objects are in reversed order so a second MRI script is required so the
|
|
||||||
# objects in the archive are listed in proper order (libc++.a, libc++abi.a)
|
|
||||||
+ lib.optionalString (cxxabi != null || lib.versionOlder release_version "16") ''
|
|
||||||
libcxxabi=''${libcxxabi-$out/lib/libc++abi.a}
|
|
||||||
if [[ -f $out/lib/libc++.a && -e $libcxxabi ]]; then
|
|
||||||
$AR -M <<MRI
|
|
||||||
create $out/lib/libc++.a
|
|
||||||
addlib $out/lib/libc++.a
|
|
||||||
addlib $libcxxabi
|
|
||||||
save
|
|
||||||
end
|
|
||||||
MRI
|
|
||||||
$AR -M <<MRI
|
|
||||||
create $out/lib/libc++.a
|
|
||||||
addlib $out/lib/libc++.a
|
|
||||||
save
|
|
||||||
end
|
|
||||||
MRI
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
isLLVM = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
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)":
|
nativeBuildInputs = [
|
||||||
license = with lib.licenses; [ mit ncsa ];
|
cmake
|
||||||
};
|
ninja
|
||||||
} // (if (lib.versionOlder release_version "16" || lib.versionAtLeast release_version "17") then {
|
python3
|
||||||
postPatch = (lib.optionalString (lib.versionAtLeast release_version "14" && lib.versionOlder release_version "15") ''
|
] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames ++ lib.optional (cxxabi != null) lndir;
|
||||||
# fix CMake error when static and LIBCXXABI_USE_LLVM_UNWINDER=ON. aren't
|
|
||||||
# building unwind so don't need to depend on it
|
buildInputs = [ cxxabi ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
|
||||||
substituteInPlace libcxx/src/CMakeLists.txt \
|
|
||||||
--replace-fail "add_dependencies(cxx_static unwind)" "# add_dependencies(cxx_static unwind)"
|
# libc++.so is a linker script which expands to multiple libraries,
|
||||||
'') + ''
|
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
|
||||||
cd runtimes
|
# support linker scripts so the external cxxabi needs to be symlinked in
|
||||||
'';
|
postInstall =
|
||||||
} else {
|
lib.optionalString (cxxabi != null) ''
|
||||||
sourceRoot = "${src'.name}/runtimes";
|
lndir ${lib.getDev cxxabi}/include $dev/include/c++/v1
|
||||||
}))
|
lndir ${lib.getLib cxxabi}/lib $out/lib
|
||||||
|
libcxxabi=$out/lib/lib${cxxabi.libName}.a
|
||||||
|
''
|
||||||
|
# LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON doesn't work for LLVM < 16 or
|
||||||
|
# external cxxabi libraries so merge libc++abi.a into libc++.a ourselves.
|
||||||
|
|
||||||
|
# GNU binutils emits objects in LIFO order in MRI scripts so after the merge
|
||||||
|
# the objects are in reversed order so a second MRI script is required so the
|
||||||
|
# objects in the archive are listed in proper order (libc++.a, libc++abi.a)
|
||||||
|
+ lib.optionalString (cxxabi != null || lib.versionOlder release_version "16") ''
|
||||||
|
libcxxabi=''${libcxxabi-$out/lib/libc++abi.a}
|
||||||
|
if [[ -f $out/lib/libc++.a && -e $libcxxabi ]]; then
|
||||||
|
$AR -M <<MRI
|
||||||
|
create $out/lib/libc++.a
|
||||||
|
addlib $out/lib/libc++.a
|
||||||
|
addlib $libcxxabi
|
||||||
|
save
|
||||||
|
end
|
||||||
|
MRI
|
||||||
|
$AR -M <<MRI
|
||||||
|
create $out/lib/libc++.a
|
||||||
|
addlib $out/lib/libc++.a
|
||||||
|
save
|
||||||
|
end
|
||||||
|
MRI
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
isLLVM = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// (
|
||||||
|
if (lib.versionOlder release_version "16" || lib.versionAtLeast release_version "17") then
|
||||||
|
{
|
||||||
|
postPatch =
|
||||||
|
(lib.optionalString
|
||||||
|
(lib.versionAtLeast release_version "14" && lib.versionOlder release_version "15")
|
||||||
|
''
|
||||||
|
# fix CMake error when static and LIBCXXABI_USE_LLVM_UNWINDER=ON. aren't
|
||||||
|
# building unwind so don't need to depend on it
|
||||||
|
substituteInPlace libcxx/src/CMakeLists.txt \
|
||||||
|
--replace-fail "add_dependencies(cxx_static unwind)" "# add_dependencies(cxx_static unwind)"
|
||||||
|
''
|
||||||
|
)
|
||||||
|
+ ''
|
||||||
|
cd runtimes
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ sourceRoot = "${src'.name}/runtimes"; }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,34 +1,41 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, release_version
|
stdenv,
|
||||||
, patches ? []
|
release_version,
|
||||||
, src ? null
|
patches ? [ ],
|
||||||
, llvm_meta
|
src ? null,
|
||||||
, version
|
llvm_meta,
|
||||||
, monorepoSrc ? null
|
version,
|
||||||
, runCommand
|
monorepoSrc ? null,
|
||||||
, cmake
|
runCommand,
|
||||||
, ninja
|
cmake,
|
||||||
, python3
|
ninja,
|
||||||
, libcxx
|
python3,
|
||||||
, enableShared ? !stdenv.hostPlatform.isStatic
|
libcxx,
|
||||||
|
enableShared ? !stdenv.hostPlatform.isStatic,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
pname = "libunwind";
|
pname = "libunwind";
|
||||||
src' = if monorepoSrc != null then
|
src' =
|
||||||
runCommand "${pname}-src-${version}" {} (''
|
if monorepoSrc != null then
|
||||||
mkdir -p "$out"
|
runCommand "${pname}-src-${version}" { } (
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
''
|
||||||
cp -r ${monorepoSrc}/${pname} "$out"
|
mkdir -p "$out"
|
||||||
mkdir -p "$out/libcxx"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
|
cp -r ${monorepoSrc}/${pname} "$out"
|
||||||
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
|
mkdir -p "$out/libcxx"
|
||||||
mkdir -p "$out/llvm"
|
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
|
||||||
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
|
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
|
||||||
'' + lib.optionalString (lib.versionAtLeast release_version "15") ''
|
mkdir -p "$out/llvm"
|
||||||
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
|
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
|
||||||
cp -r ${monorepoSrc}/runtimes "$out"
|
''
|
||||||
'') else src;
|
+ lib.optionalString (lib.versionAtLeast release_version "15") ''
|
||||||
|
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
|
||||||
|
cp -r ${monorepoSrc}/runtimes "$out"
|
||||||
|
''
|
||||||
|
)
|
||||||
|
else
|
||||||
|
src;
|
||||||
|
|
||||||
hasPatches = builtins.length patches > 0;
|
hasPatches = builtins.length patches > 0;
|
||||||
|
|
||||||
@@ -37,51 +44,70 @@ let
|
|||||||
ln -s ${libcxx.src}/llvm .
|
ln -s ${libcxx.src}/llvm .
|
||||||
'';
|
'';
|
||||||
|
|
||||||
prePatch = lib.optionalString (lib.versionAtLeast release_version "15" && (hasPatches || lib.versionOlder release_version "18")) ''
|
prePatch =
|
||||||
cd ../${pname}
|
lib.optionalString
|
||||||
chmod -R u+w .
|
(lib.versionAtLeast release_version "15" && (hasPatches || lib.versionOlder release_version "18"))
|
||||||
'';
|
''
|
||||||
|
cd ../${pname}
|
||||||
|
chmod -R u+w .
|
||||||
|
'';
|
||||||
|
|
||||||
postPatch = lib.optionalString (lib.versionAtLeast release_version "15" && (hasPatches || lib.versionOlder release_version "18")) ''
|
postPatch =
|
||||||
cd ../runtimes
|
lib.optionalString
|
||||||
'';
|
(lib.versionAtLeast release_version "15" && (hasPatches || lib.versionOlder release_version "18"))
|
||||||
|
''
|
||||||
|
cd ../runtimes
|
||||||
|
'';
|
||||||
|
|
||||||
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
|
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
|
||||||
# libcxxabi wants to link to libunwind_shared.so (?).
|
# libcxxabi wants to link to libunwind_shared.so (?).
|
||||||
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
|
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation (rec {
|
stdenv.mkDerivation (
|
||||||
inherit pname version patches;
|
rec {
|
||||||
|
inherit pname version patches;
|
||||||
|
|
||||||
src = src';
|
src = src';
|
||||||
|
|
||||||
sourceRoot =
|
sourceRoot =
|
||||||
if lib.versionOlder release_version "13" then null
|
if lib.versionOlder release_version "13" then
|
||||||
else if lib.versionAtLeast release_version "15" then "${src.name}/runtimes"
|
null
|
||||||
else "${src.name}/${pname}";
|
else if lib.versionAtLeast release_version "15" then
|
||||||
|
"${src.name}/runtimes"
|
||||||
|
else
|
||||||
|
"${src.name}/${pname}";
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"dev"
|
||||||
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ] ++ lib.optionals (lib.versionAtLeast release_version "15") [
|
nativeBuildInputs =
|
||||||
ninja python3
|
[ cmake ]
|
||||||
];
|
++ lib.optionals (lib.versionAtLeast release_version "15") [
|
||||||
|
ninja
|
||||||
|
python3
|
||||||
|
];
|
||||||
|
|
||||||
cmakeFlags = lib.optional (lib.versionAtLeast release_version "15") "-DLLVM_ENABLE_RUNTIMES=libunwind"
|
cmakeFlags =
|
||||||
++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
|
lib.optional (lib.versionAtLeast release_version "15") "-DLLVM_ENABLE_RUNTIMES=libunwind"
|
||||||
|
++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
|
||||||
|
|
||||||
meta = llvm_meta // {
|
meta = llvm_meta // {
|
||||||
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
|
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
|
||||||
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
|
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
|
||||||
description = "LLVM's unwinder library";
|
description = "LLVM's unwinder library";
|
||||||
longDescription = ''
|
longDescription = ''
|
||||||
The unwind library provides a family of _Unwind_* functions implementing
|
The unwind library provides a family of _Unwind_* functions implementing
|
||||||
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
|
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
|
I). It is a dependency of the C++ ABI library, and sometimes is a
|
||||||
dependency of other runtimes.
|
dependency of other runtimes.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
} // (if postUnpack != "" then { inherit postUnpack; } else {})
|
}
|
||||||
// (if (lib.versionAtLeast release_version "15") then { inherit postInstall; } else {})
|
// (if postUnpack != "" then { inherit postUnpack; } else { })
|
||||||
// (if prePatch != "" then { inherit prePatch; } else {})
|
// (if (lib.versionAtLeast release_version "15") then { inherit postInstall; } else { })
|
||||||
// (if postPatch != "" then { inherit postPatch; } else {}))
|
// (if prePatch != "" then { inherit prePatch; } else { })
|
||||||
|
// (if postPatch != "" then { inherit postPatch; } else { })
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,77 +1,100 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, llvm_meta
|
stdenv,
|
||||||
, release_version
|
llvm_meta,
|
||||||
, patches ? []
|
release_version,
|
||||||
, buildLlvmTools
|
patches ? [ ],
|
||||||
, monorepoSrc ? null
|
buildLlvmTools,
|
||||||
, src ? null
|
monorepoSrc ? null,
|
||||||
, libunwind ? null
|
src ? null,
|
||||||
, runCommand
|
libunwind ? null,
|
||||||
, cmake
|
runCommand,
|
||||||
, ninja
|
cmake,
|
||||||
, libxml2
|
ninja,
|
||||||
, libllvm
|
libxml2,
|
||||||
, version
|
libllvm,
|
||||||
|
version,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
pname = "lld";
|
pname = "lld";
|
||||||
src' =
|
src' =
|
||||||
if monorepoSrc != null then
|
if monorepoSrc != null then
|
||||||
runCommand "lld-src-${version}" {} ''
|
runCommand "lld-src-${version}" { } ''
|
||||||
mkdir -p "$out"
|
mkdir -p "$out"
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
cp -r ${monorepoSrc}/${pname} "$out"
|
cp -r ${monorepoSrc}/${pname} "$out"
|
||||||
mkdir -p "$out/libunwind"
|
mkdir -p "$out/libunwind"
|
||||||
cp -r ${monorepoSrc}/libunwind/include "$out/libunwind"
|
cp -r ${monorepoSrc}/libunwind/include "$out/libunwind"
|
||||||
mkdir -p "$out/llvm"
|
mkdir -p "$out/llvm"
|
||||||
'' else src;
|
''
|
||||||
|
else
|
||||||
|
src;
|
||||||
|
|
||||||
postPatch = lib.optionalString (lib.versions.major release_version == "12") ''
|
postPatch =
|
||||||
substituteInPlace MachO/CMakeLists.txt --replace \
|
lib.optionalString (lib.versions.major release_version == "12") ''
|
||||||
'(''${LLVM_MAIN_SRC_DIR}/' '('
|
substituteInPlace MachO/CMakeLists.txt --replace \
|
||||||
mkdir -p libunwind/include
|
'(''${LLVM_MAIN_SRC_DIR}/' '('
|
||||||
tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/"
|
mkdir -p libunwind/include
|
||||||
'' + lib.optionalString (lib.versions.major release_version == "13" && stdenv.isDarwin) ''
|
tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/"
|
||||||
substituteInPlace MachO/CMakeLists.txt --replace \
|
''
|
||||||
'(''${LLVM_MAIN_SRC_DIR}/' '(../'
|
+ lib.optionalString (lib.versions.major release_version == "13" && stdenv.isDarwin) ''
|
||||||
'';
|
substituteInPlace MachO/CMakeLists.txt --replace \
|
||||||
in
|
'(''${LLVM_MAIN_SRC_DIR}/' '(../'
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
inherit pname version patches;
|
|
||||||
|
|
||||||
src = src';
|
|
||||||
|
|
||||||
sourceRoot =
|
|
||||||
if lib.versionOlder release_version "13" then null
|
|
||||||
else "${src.name}/${pname}";
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ] ++ lib.optional (lib.versionAtLeast release_version "15") ninja;
|
|
||||||
buildInputs = [ libllvm libxml2 ];
|
|
||||||
|
|
||||||
cmakeFlags = lib.optionals (lib.versionOlder release_version "14") [
|
|
||||||
"-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
|
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
|
|
||||||
"-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld"
|
|
||||||
] ++ 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), Mach-O (macOS), and
|
|
||||||
WebAssembly in descending order of completeness. Internally, LLD consists
|
|
||||||
of several different linkers.
|
|
||||||
'';
|
'';
|
||||||
};
|
in
|
||||||
} // (if (postPatch == "" && lib.versions.major release_version != "13") then {} else { inherit postPatch; }))
|
stdenv.mkDerivation (
|
||||||
|
rec {
|
||||||
|
inherit pname version patches;
|
||||||
|
|
||||||
|
src = src';
|
||||||
|
|
||||||
|
sourceRoot = if lib.versionOlder release_version "13" then null else "${src.name}/${pname}";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake ] ++ lib.optional (lib.versionAtLeast release_version "15") ninja;
|
||||||
|
buildInputs = [
|
||||||
|
libllvm
|
||||||
|
libxml2
|
||||||
|
];
|
||||||
|
|
||||||
|
cmakeFlags =
|
||||||
|
lib.optionals (lib.versionOlder release_version "14") [
|
||||||
|
"-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${
|
||||||
|
lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"
|
||||||
|
}"
|
||||||
|
]
|
||||||
|
++ lib.optionals (lib.versionAtLeast release_version "15") [
|
||||||
|
"-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld"
|
||||||
|
]
|
||||||
|
++ 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), Mach-O (macOS), and
|
||||||
|
WebAssembly in descending order of completeness. Internally, LLD consists
|
||||||
|
of several different linkers.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// (
|
||||||
|
if (postPatch == "" && lib.versions.major release_version != "13") then
|
||||||
|
{ }
|
||||||
|
else
|
||||||
|
{ inherit postPatch; }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, fetchFromGitHub
|
stdenv,
|
||||||
, makeWrapper
|
fetchFromGitHub,
|
||||||
, lldb
|
makeWrapper,
|
||||||
|
lldb,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, llvm_meta
|
stdenv,
|
||||||
, release_version
|
llvm_meta,
|
||||||
, cmake
|
release_version,
|
||||||
, zlib
|
cmake,
|
||||||
, ncurses
|
zlib,
|
||||||
, swig3
|
ncurses,
|
||||||
, swig4
|
swig3,
|
||||||
, which
|
swig4,
|
||||||
, libedit
|
which,
|
||||||
, libxml2
|
libedit,
|
||||||
, libllvm
|
libxml2,
|
||||||
, libclang
|
libllvm,
|
||||||
, python3
|
libclang,
|
||||||
, version
|
python3,
|
||||||
, darwin
|
version,
|
||||||
, lit
|
darwin,
|
||||||
, makeWrapper
|
lit,
|
||||||
, lua5_3
|
makeWrapper,
|
||||||
, ninja
|
lua5_3,
|
||||||
, runCommand
|
ninja,
|
||||||
, src ? null
|
runCommand,
|
||||||
, monorepoSrc ? null
|
src ? null,
|
||||||
, patches ? [ ]
|
monorepoSrc ? null,
|
||||||
, enableManpages ? false
|
patches ? [ ],
|
||||||
, ...
|
enableManpages ? false,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@@ -34,7 +35,9 @@ let
|
|||||||
mkdir -p "$out"
|
mkdir -p "$out"
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
cp -r ${monorepoSrc}/lldb "$out"
|
cp -r ${monorepoSrc}/lldb "$out"
|
||||||
'' else src;
|
''
|
||||||
|
else
|
||||||
|
src;
|
||||||
vscodeExt = {
|
vscodeExt = {
|
||||||
name = if lib.versionAtLeast release_version "18" then "lldb-dap" else "lldb-vscode";
|
name = if lib.versionAtLeast release_version "18" then "lldb-dap" else "lldb-vscode";
|
||||||
version = if lib.versionAtLeast release_version "18" then "0.2.0" else "0.1.0";
|
version = if lib.versionAtLeast release_version "18" then "0.2.0" else "0.1.0";
|
||||||
@@ -42,177 +45,198 @@ let
|
|||||||
swig = if lib.versionAtLeast release_version "18" then swig4 else swig3;
|
swig = if lib.versionAtLeast release_version "18" then swig4 else swig3;
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
stdenv.mkDerivation (
|
||||||
passthru.monorepoSrc = monorepoSrc;
|
rec {
|
||||||
pname = "lldb";
|
passthru.monorepoSrc = monorepoSrc;
|
||||||
inherit version;
|
pname = "lldb";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
src = src';
|
src = src';
|
||||||
inherit patches;
|
inherit patches;
|
||||||
|
|
||||||
outputs = [ "out" "lib" "dev" ];
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"lib"
|
||||||
|
"dev"
|
||||||
|
];
|
||||||
|
|
||||||
sourceRoot = lib.optional (lib.versionAtLeast release_version "13") "${src.name}/${pname}";
|
sourceRoot = lib.optional (lib.versionAtLeast release_version "13") "${src.name}/${pname}";
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs =
|
||||||
cmake
|
[
|
||||||
python3
|
cmake
|
||||||
which
|
python3
|
||||||
swig
|
which
|
||||||
lit
|
swig
|
||||||
makeWrapper
|
lit
|
||||||
lua5_3
|
makeWrapper
|
||||||
] ++ lib.optionals enableManpages [
|
lua5_3
|
||||||
python3.pkgs.sphinx
|
]
|
||||||
] ++ lib.optionals (lib.versionOlder release_version "18" && enableManpages) [
|
++ lib.optionals enableManpages [ python3.pkgs.sphinx ]
|
||||||
python3.pkgs.recommonmark
|
++ lib.optionals (lib.versionOlder release_version "18" && enableManpages) [
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "18" && enableManpages) [
|
python3.pkgs.recommonmark
|
||||||
python3.pkgs.myst-parser
|
]
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "14") [
|
++ lib.optionals (lib.versionAtLeast release_version "18" && enableManpages) [
|
||||||
ninja
|
python3.pkgs.myst-parser
|
||||||
];
|
]
|
||||||
|
++ lib.optionals (lib.versionAtLeast release_version "14") [ ninja ];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs =
|
||||||
ncurses
|
[
|
||||||
zlib
|
ncurses
|
||||||
libedit
|
zlib
|
||||||
libxml2
|
libedit
|
||||||
libllvm
|
libxml2
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "16") [
|
libllvm
|
||||||
# Starting with LLVM 16, the resource dir patch is no longer enough to get
|
]
|
||||||
# libclang into the rpath of the lldb executables. By putting it into
|
++ lib.optionals (lib.versionAtLeast release_version "16") [
|
||||||
# buildInputs cc-wrapper will set up rpath correctly for us.
|
# Starting with LLVM 16, the resource dir patch is no longer enough to get
|
||||||
(lib.getLib libclang)
|
# libclang into the rpath of the lldb executables. By putting it into
|
||||||
] ++ lib.optionals stdenv.isDarwin [
|
# buildInputs cc-wrapper will set up rpath correctly for us.
|
||||||
darwin.libobjc
|
(lib.getLib libclang)
|
||||||
darwin.apple_sdk.libs.xpc
|
]
|
||||||
darwin.apple_sdk.frameworks.Foundation
|
++ lib.optionals stdenv.isDarwin [
|
||||||
darwin.bootstrap_cmds
|
darwin.libobjc
|
||||||
darwin.apple_sdk.frameworks.Carbon
|
darwin.apple_sdk.libs.xpc
|
||||||
darwin.apple_sdk.frameworks.Cocoa
|
darwin.apple_sdk.frameworks.Foundation
|
||||||
]
|
darwin.bootstrap_cmds
|
||||||
# The older libSystem used on x86_64 macOS is missing the
|
darwin.apple_sdk.frameworks.Carbon
|
||||||
# `<bsm/audit_session.h>` header which `lldb` uses.
|
darwin.apple_sdk.frameworks.Cocoa
|
||||||
#
|
]
|
||||||
# We copy this header over from macOS 10.12 SDK.
|
# The older libSystem used on x86_64 macOS is missing the
|
||||||
#
|
# `<bsm/audit_session.h>` header which `lldb` uses.
|
||||||
# See here for context:
|
#
|
||||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
# We copy this header over from macOS 10.12 SDK.
|
||||||
++ lib.optional
|
#
|
||||||
(
|
# See here for context:
|
||||||
stdenv.targetPlatform.isDarwin
|
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||||
&& !stdenv.targetPlatform.isAarch64
|
++
|
||||||
&& (lib.versionAtLeast release_version "15")
|
lib.optional
|
||||||
)
|
(
|
||||||
(
|
stdenv.targetPlatform.isDarwin
|
||||||
runCommand "bsm-audit-session-header" { } ''
|
&& !stdenv.targetPlatform.isAarch64
|
||||||
install -Dm444 \
|
&& (lib.versionAtLeast release_version "15")
|
||||||
"${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \
|
)
|
||||||
"$out/include/bsm/audit_session.h"
|
(
|
||||||
|
runCommand "bsm-audit-session-header" { } ''
|
||||||
|
install -Dm444 \
|
||||||
|
"${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \
|
||||||
|
"$out/include/bsm/audit_session.h"
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
hardeningDisable = [ "format" ];
|
||||||
|
|
||||||
|
cmakeFlags =
|
||||||
|
[
|
||||||
|
"-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}"
|
||||||
|
"-DLLVM_ENABLE_RTTI=OFF"
|
||||||
|
"-DClang_DIR=${lib.getDev libclang}/lib/cmake"
|
||||||
|
"-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
|
||||||
|
]
|
||||||
|
++ lib.optionals stdenv.isDarwin [ "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" ]
|
||||||
|
++ lib.optionals (!stdenv.isDarwin) [
|
||||||
|
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
|
||||||
|
]
|
||||||
|
++ lib.optionals (lib.versionAtLeast release_version "17") [
|
||||||
|
"-DCLANG_RESOURCE_DIR=../../../../${libclang.lib}"
|
||||||
|
]
|
||||||
|
++ lib.optionals enableManpages (
|
||||||
|
[
|
||||||
|
"-DLLVM_ENABLE_SPHINX=ON"
|
||||||
|
"-DSPHINX_OUTPUT_MAN=ON"
|
||||||
|
"-DSPHINX_OUTPUT_HTML=OFF"
|
||||||
|
]
|
||||||
|
++ lib.optionals (lib.versionAtLeast release_version "15") [
|
||||||
|
# docs reference `automodapi` but it's not added to the extensions list when
|
||||||
|
# only building the manpages:
|
||||||
|
# https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54
|
||||||
|
#
|
||||||
|
# so, we just ignore the resulting errors
|
||||||
|
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
++ 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;
|
||||||
|
doInstallCheck = lib.versionOlder release_version "15";
|
||||||
|
|
||||||
|
# TODO: cleanup with mass-rebuild
|
||||||
|
installCheckPhase =
|
||||||
''
|
''
|
||||||
);
|
if [ ! -e $lib/${python3.sitePackages}/lldb/_lldb*.so ] ; then
|
||||||
|
echo "ERROR: python files not installed where expected!";
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
'' # Something lua is built on older versions but this file doesn't exist.
|
||||||
|
+ lib.optionalString (lib.versionAtLeast release_version "14") ''
|
||||||
|
if [ ! -e "$lib/lib/lua/${lua5_3.luaversion}/lldb.so" ] ; then
|
||||||
|
echo "ERROR: lua files not installed where expected!";
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
hardeningDisable = [ "format" ];
|
postInstall = ''
|
||||||
|
wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
|
||||||
|
|
||||||
cmakeFlags = [
|
# Editor support
|
||||||
"-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}"
|
# vscode:
|
||||||
"-DLLVM_ENABLE_RTTI=OFF"
|
install -D ../tools/${vscodeExt.name}/package.json $out/share/vscode/extensions/llvm-org.${vscodeExt.name}-${vscodeExt.version}/package.json
|
||||||
"-DClang_DIR=${lib.getDev libclang}/lib/cmake"
|
mkdir -p $out/share/vscode/extensions/llvm-org.${vscodeExt.name}-${vscodeExt.version}/bin
|
||||||
"-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
|
ln -s $out/bin/*${
|
||||||
] ++ lib.optionals stdenv.isDarwin [
|
if lib.versionAtLeast release_version "18" then vscodeExt.name else "-vscode"
|
||||||
"-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
|
} $out/share/vscode/extensions/llvm-org.${vscodeExt.name}-${vscodeExt.version}/bin
|
||||||
] ++ lib.optionals (!stdenv.isDarwin) [
|
|
||||||
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
|
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "17") [
|
|
||||||
"-DCLANG_RESOURCE_DIR=../../../../${libclang.lib}"
|
|
||||||
] ++ lib.optionals enableManpages ([
|
|
||||||
"-DLLVM_ENABLE_SPHINX=ON"
|
|
||||||
"-DSPHINX_OUTPUT_MAN=ON"
|
|
||||||
"-DSPHINX_OUTPUT_HTML=OFF"
|
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
|
|
||||||
# docs reference `automodapi` but it's not added to the extensions list when
|
|
||||||
# only building the manpages:
|
|
||||||
# https://github.com/llvm/llvm-project/blob/af6ec9200b09039573d85e349496c4f5b17c3d7f/lldb/docs/conf.py#L54
|
|
||||||
#
|
|
||||||
# so, we just ignore the resulting errors
|
|
||||||
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
|
||||||
]) ++ 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;
|
|
||||||
doInstallCheck = lib.versionOlder release_version "15";
|
|
||||||
|
|
||||||
# TODO: cleanup with mass-rebuild
|
|
||||||
installCheckPhase = ''
|
|
||||||
if [ ! -e $lib/${python3.sitePackages}/lldb/_lldb*.so ] ; then
|
|
||||||
echo "ERROR: python files not installed where expected!";
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
'' # Something lua is built on older versions but this file doesn't exist.
|
|
||||||
+ lib.optionalString (lib.versionAtLeast release_version "14") ''
|
|
||||||
if [ ! -e "$lib/lib/lua/${lua5_3.luaversion}/lldb.so" ] ; then
|
|
||||||
echo "ERROR: lua files not installed where expected!";
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/
|
|
||||||
|
|
||||||
# Editor support
|
|
||||||
# vscode:
|
|
||||||
install -D ../tools/${vscodeExt.name}/package.json $out/share/vscode/extensions/llvm-org.${vscodeExt.name}-${vscodeExt.version}/package.json
|
|
||||||
mkdir -p $out/share/vscode/extensions/llvm-org.${vscodeExt.name}-${vscodeExt.version}/bin
|
|
||||||
ln -s $out/bin/*${if lib.versionAtLeast release_version "18" then vscodeExt.name else "-vscode"} $out/share/vscode/extensions/llvm-org.${vscodeExt.name}-${vscodeExt.version}/bin
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru.vscodeExtName = vscodeExt.name;
|
|
||||||
passthru.vscodeExtPublisher = "llvm";
|
|
||||||
passthru.vscodeExtUniqueId = "llvm-org.${vscodeExt.name}-${vscodeExt.version}";
|
|
||||||
|
|
||||||
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.
|
|
||||||
'';
|
'';
|
||||||
# llvm <10 never built on aarch64-darwin since first introduction in nixpkgs
|
|
||||||
broken =
|
passthru.vscodeExtName = vscodeExt.name;
|
||||||
(lib.versionOlder release_version "11" && stdenv.isDarwin && stdenv.isAarch64)
|
passthru.vscodeExtPublisher = "llvm";
|
||||||
|
passthru.vscodeExtUniqueId = "llvm-org.${vscodeExt.name}-${vscodeExt.version}";
|
||||||
|
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
# llvm <10 never built on aarch64-darwin since first introduction in nixpkgs
|
||||||
|
broken =
|
||||||
|
(lib.versionOlder release_version "11" && stdenv.isDarwin && stdenv.isAarch64)
|
||||||
|| (((lib.versions.major release_version) == "13") && stdenv.isDarwin);
|
|| (((lib.versions.major release_version) == "13") && stdenv.isDarwin);
|
||||||
mainProgram = "lldb";
|
mainProgram = "lldb";
|
||||||
};
|
};
|
||||||
} // lib.optionalAttrs enableManpages {
|
}
|
||||||
pname = "lldb-manpages";
|
// lib.optionalAttrs enableManpages {
|
||||||
|
pname = "lldb-manpages";
|
||||||
|
|
||||||
buildPhase = lib.optionalString (lib.versionOlder release_version "15") ''
|
buildPhase = lib.optionalString (lib.versionOlder release_version "15") ''
|
||||||
make ${if (lib.versionOlder release_version "12") then "docs-man" else "docs-lldb-man"}
|
make ${if (lib.versionOlder release_version "12") then "docs-man" else "docs-lldb-man"}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
ninjaFlags = lib.optionals (lib.versionAtLeast release_version "15") [ "docs-lldb-man" ];
|
||||||
|
|
||||||
ninjaFlags = lib.optionals (lib.versionAtLeast release_version "15") [ "docs-lldb-man" ];
|
propagatedBuildInputs = [ ];
|
||||||
|
|
||||||
propagatedBuildInputs = [ ];
|
# manually install lldb man page
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/share/man/man1
|
||||||
|
install docs/man/lldb.1 -t $out/share/man/man1/
|
||||||
|
'';
|
||||||
|
|
||||||
# manually install lldb man page
|
postPatch = null;
|
||||||
installPhase = ''
|
postInstall = null;
|
||||||
mkdir -p $out/share/man/man1
|
|
||||||
install docs/man/lldb.1 -t $out/share/man/man1/
|
|
||||||
'';
|
|
||||||
|
|
||||||
postPatch = null;
|
outputs = [ "out" ];
|
||||||
postInstall = null;
|
|
||||||
|
|
||||||
outputs = [ "out" ];
|
doCheck = false;
|
||||||
|
|
||||||
doCheck = false;
|
meta = llvm_meta // {
|
||||||
|
description = "man pages for LLDB ${version}";
|
||||||
meta = llvm_meta // {
|
};
|
||||||
description = "man pages for LLDB ${version}";
|
}
|
||||||
};
|
)
|
||||||
})
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,20 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, llvm_meta
|
stdenv,
|
||||||
, buildLlvmTools
|
llvm_meta,
|
||||||
, monorepoSrc
|
buildLlvmTools,
|
||||||
, runCommand
|
monorepoSrc,
|
||||||
, cmake
|
runCommand,
|
||||||
, ninja
|
cmake,
|
||||||
, libxml2
|
ninja,
|
||||||
, libllvm
|
libxml2,
|
||||||
, version
|
libllvm,
|
||||||
, doCheck ? (!stdenv.isx86_32 /* TODO: why */) && (!stdenv.hostPlatform.isMusl)
|
version,
|
||||||
|
doCheck ?
|
||||||
|
(
|
||||||
|
!stdenv.isx86_32 # TODO: why
|
||||||
|
)
|
||||||
|
&& (!stdenv.hostPlatform.isMusl),
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
@@ -28,9 +33,7 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
sourceRoot = "${src.name}/mlir";
|
sourceRoot = "${src.name}/mlir";
|
||||||
|
|
||||||
patches = [
|
patches = [ ./gnu-install-dirs.patch ];
|
||||||
./gnu-install-dirs.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cmake
|
cmake
|
||||||
@@ -42,30 +45,42 @@ stdenv.mkDerivation rec {
|
|||||||
libxml2
|
libxml2
|
||||||
];
|
];
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags =
|
||||||
"-DLLVM_BUILD_TOOLS=ON"
|
[
|
||||||
# Install headers as well
|
"-DLLVM_BUILD_TOOLS=ON"
|
||||||
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF"
|
# Install headers as well
|
||||||
"-DMLIR_TOOLS_INSTALL_DIR=${placeholder "out"}/bin/"
|
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF"
|
||||||
"-DLLVM_ENABLE_IDE=OFF"
|
"-DMLIR_TOOLS_INSTALL_DIR=${placeholder "out"}/bin/"
|
||||||
"-DMLIR_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/mlir"
|
"-DLLVM_ENABLE_IDE=OFF"
|
||||||
"-DMLIR_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/mlir"
|
"-DMLIR_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/mlir"
|
||||||
"-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
|
"-DMLIR_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/mlir"
|
||||||
"-DLLVM_ENABLE_FFI=ON"
|
"-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
|
||||||
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
|
"-DLLVM_ENABLE_FFI=ON"
|
||||||
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
|
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
|
||||||
"-DLLVM_ENABLE_DUMP=ON"
|
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
|
||||||
] ++ lib.optionals stdenv.hostPlatform.isStatic [
|
"-DLLVM_ENABLE_DUMP=ON"
|
||||||
# Disables building of shared libs, -fPIC is still injected by cc-wrapper
|
]
|
||||||
"-DLLVM_ENABLE_PIC=OFF"
|
++ lib.optionals stdenv.hostPlatform.isStatic [
|
||||||
"-DLLVM_BUILD_STATIC=ON"
|
# Disables building of shared libs, -fPIC is still injected by cc-wrapper
|
||||||
"-DLLVM_LINK_LLVM_DYLIB=OFF"
|
"-DLLVM_ENABLE_PIC=OFF"
|
||||||
] ++ lib.optionals ((stdenv.hostPlatform != stdenv.buildPlatform) && !(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) [
|
"-DLLVM_BUILD_STATIC=ON"
|
||||||
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
|
"-DLLVM_LINK_LLVM_DYLIB=OFF"
|
||||||
"-DMLIR_TABLEGEN_EXE=${buildLlvmTools.mlir}/bin/mlir-tblgen"
|
]
|
||||||
];
|
++
|
||||||
|
lib.optionals
|
||||||
|
(
|
||||||
|
(stdenv.hostPlatform != stdenv.buildPlatform)
|
||||||
|
&& !(stdenv.buildPlatform.canExecute stdenv.hostPlatform)
|
||||||
|
)
|
||||||
|
[
|
||||||
|
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
|
||||||
|
"-DMLIR_TABLEGEN_EXE=${buildLlvmTools.mlir}/bin/mlir-tblgen"
|
||||||
|
];
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"dev"
|
||||||
|
];
|
||||||
|
|
||||||
meta = llvm_meta // {
|
meta = llvm_meta // {
|
||||||
homepage = "https://mlir.llvm.org/";
|
homepage = "https://mlir.llvm.org/";
|
||||||
|
|||||||
@@ -1,86 +1,91 @@
|
|||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, llvm_meta
|
stdenv,
|
||||||
, release_version
|
llvm_meta,
|
||||||
, patches ? []
|
release_version,
|
||||||
, monorepoSrc ? null
|
patches ? [ ],
|
||||||
, src ? null
|
monorepoSrc ? null,
|
||||||
, runCommand
|
src ? null,
|
||||||
, cmake
|
runCommand,
|
||||||
, ninja
|
cmake,
|
||||||
, llvm
|
ninja,
|
||||||
, targetLlvm
|
llvm,
|
||||||
, lit
|
targetLlvm,
|
||||||
, clang-unwrapped
|
lit,
|
||||||
, perl
|
clang-unwrapped,
|
||||||
, pkg-config
|
perl,
|
||||||
, xcbuild
|
pkg-config,
|
||||||
, version
|
xcbuild,
|
||||||
|
version,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
pname = "openmp";
|
pname = "openmp";
|
||||||
src' =
|
src' =
|
||||||
if monorepoSrc != null then
|
if monorepoSrc != null then
|
||||||
runCommand "${pname}-src-${version}" {} ''
|
runCommand "${pname}-src-${version}" { } ''
|
||||||
mkdir -p "$out"
|
mkdir -p "$out"
|
||||||
cp -r ${monorepoSrc}/cmake "$out"
|
cp -r ${monorepoSrc}/cmake "$out"
|
||||||
cp -r ${monorepoSrc}/${pname} "$out"
|
cp -r ${monorepoSrc}/${pname} "$out"
|
||||||
'' else src;
|
''
|
||||||
|
else
|
||||||
|
src;
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation (rec {
|
stdenv.mkDerivation (
|
||||||
inherit pname version patches;
|
rec {
|
||||||
|
inherit pname version patches;
|
||||||
|
|
||||||
src = src';
|
src = src';
|
||||||
|
|
||||||
sourceRoot =
|
sourceRoot = if lib.versionOlder release_version "13" then null else "${src.name}/${pname}";
|
||||||
if lib.versionOlder release_version "13" then null
|
|
||||||
else "${src.name}/${pname}";
|
|
||||||
|
|
||||||
outputs = [ "out" ]
|
outputs = [ "out" ] ++ lib.optionals (lib.versionAtLeast release_version "14") [ "dev" ];
|
||||||
++ lib.optionals (lib.versionAtLeast release_version "14") [ "dev" ];
|
|
||||||
|
|
||||||
patchFlags =
|
patchFlags = if lib.versionOlder release_version "14" then [ "-p2" ] else null;
|
||||||
if lib.versionOlder release_version "14" then [ "-p2" ]
|
|
||||||
else null;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs =
|
||||||
cmake
|
[ cmake ]
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
|
++ lib.optionals (lib.versionAtLeast release_version "15") [ ninja ]
|
||||||
ninja
|
++ [ perl ]
|
||||||
] ++ [ perl ] ++ lib.optionals (lib.versionAtLeast release_version "14") [
|
++ lib.optionals (lib.versionAtLeast release_version "14") [
|
||||||
pkg-config lit
|
pkg-config
|
||||||
];
|
lit
|
||||||
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [ (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) ];
|
||||||
(if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
|
|
||||||
];
|
|
||||||
|
|
||||||
cmakeFlags = lib.optionals (lib.versions.major release_version == "13") [
|
cmakeFlags =
|
||||||
"-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL fails
|
lib.optionals (lib.versions.major release_version == "13") [
|
||||||
] ++ lib.optionals (lib.versionAtLeast release_version "14") [
|
"-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL fails
|
||||||
"-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
|
]
|
||||||
"-DOPT_TOOL=${llvm}/bin/opt"
|
++ lib.optionals (lib.versionAtLeast release_version "14") [
|
||||||
"-DLINK_TOOL=${llvm}/bin/llvm-link"
|
"-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
|
||||||
];
|
"-DOPT_TOOL=${llvm}/bin/opt"
|
||||||
|
"-DLINK_TOOL=${llvm}/bin/llvm-link"
|
||||||
|
];
|
||||||
|
|
||||||
meta = llvm_meta // {
|
meta = llvm_meta // {
|
||||||
homepage = "https://openmp.llvm.org/";
|
homepage = "https://openmp.llvm.org/";
|
||||||
description = "Support for the OpenMP language";
|
description = "Support for the OpenMP language";
|
||||||
longDescription = ''
|
longDescription = ''
|
||||||
The OpenMP subproject of LLVM contains the components required to build an
|
The OpenMP subproject of LLVM contains the components required to build an
|
||||||
executable OpenMP program that are outside the compiler itself.
|
executable OpenMP program that are outside the compiler itself.
|
||||||
Contains the code for the runtime library against which code compiled by
|
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
|
"clang -fopenmp" must be linked before it can run and the library that
|
||||||
supports offload to target devices.
|
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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// (lib.optionalAttrs (lib.versionAtLeast release_version "14") {
|
||||||
|
doCheck = false;
|
||||||
|
checkTarget = "check-openmp";
|
||||||
|
preCheck = ''
|
||||||
|
patchShebangs ../tools/archer/tests/deflake.bash
|
||||||
'';
|
'';
|
||||||
# "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 ];
|
|
||||||
};
|
|
||||||
} // (lib.optionalAttrs (lib.versionAtLeast release_version "14") {
|
|
||||||
doCheck = false;
|
|
||||||
checkTarget = "check-openmp";
|
|
||||||
preCheck = ''
|
|
||||||
patchShebangs ../tools/archer/tests/deflake.bash
|
|
||||||
'';
|
|
||||||
}))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user