core/pkgs/by-name/ll/llvm/common/bintools.nix

63 lines
1.9 KiB
Nix
Raw Normal View History

2024-06-30 08:12:46 +00:00
{
lib,
runCommand,
stdenv,
llvm,
lld,
version,
release_version,
}:
2024-05-02 00:46:19 +00:00
let
2024-06-30 08:12:46 +00:00
targetPrefix = lib.optionalString (
stdenv.hostPlatform != stdenv.targetPlatform
) "${stdenv.targetPlatform.config}-";
2024-05-02 00:46:19 +00:00
in
runCommand "llvm-binutils-${version}"
2024-06-30 08:12:46 +00:00
{
preferLocalBuild = true;
passthru = {
isLLVM = true;
inherit targetPrefix;
};
}
(
''
mkdir -p $out/bin
for prog in ${lld}/bin/*; do
ln -s $prog $out/bin/${targetPrefix}$(basename $prog)
done
for prog in ${llvm}/bin/*; do
ln -sf $prog $out/bin/${targetPrefix}$(basename $prog)
done
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
llvmBin="${llvm}/bin"
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
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}ranlib
ln -s $llvmBin/llvm-cxxfilt $out/bin/${targetPrefix}c++filt
ln -s $llvmBin/llvm-dwp $out/bin/${targetPrefix}dwp
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}strip
ln -s $llvmBin/llvm-objdump $out/bin/${targetPrefix}objdump
ln -s $llvmBin/llvm-readobj $out/bin/${targetPrefix}readelf
ln -s $llvmBin/llvm-size $out/bin/${targetPrefix}size
ln -s $llvmBin/llvm-strings $out/bin/${targetPrefix}strings
ln -s $llvmBin/llvm-symbolizer $out/bin/${targetPrefix}addr2line
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
if [ -e "$llvmBin/llvm-debuginfod" ]; then
ln -s $llvmBin/llvm-debuginfod $out/bin/${targetPrefix}debuginfod
ln -s $llvmBin/llvm-debuginfod-find $out/bin/${targetPrefix}debuginfod-find
fi
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
ln -s ${lld}/bin/lld $out/bin/${targetPrefix}ld
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
# Only >=13 show GNU windres compatible in help
''
+ lib.optionalString (lib.versionAtLeast release_version "13") ''
ln -s $llvmBin/llvm-rc $out/bin/${targetPrefix}windres
''
)