serene/nix/libunwind/default.nix

70 lines
1.7 KiB
Nix

# Serene Programming Language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ lib,
stdenv,
cmake,
ninja,
python3,
utils,
runCommand,
llvm_source,
}:
stdenv.mkDerivation rec{
pname = "llvm_libunwind";
inherit (llvm_source) version;
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${llvm_source}/cmake "$out"
cp -r ${llvm_source}/libunwind "$out"
mkdir -p "$out/libcxx"
cp -r ${llvm_source}/libcxx/cmake "$out/libcxx"
cp -r ${llvm_source}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${llvm_source}/llvm/cmake "$out/llvm"
cp -r ${llvm_source}/llvm/utils "$out/llvm"
cp -r ${llvm_source}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
prePatch = ''
cd ../libunwind
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
];
postPatch = ''
cd ../runtimes
'';
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ninja python3 ];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=libunwind"
"-DLIBUNWIND_ENABLE_SHARED=OFF"
"-DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
];
inherit (utils) meta;
}