Skip to content

Commit

Permalink
python3Packages.llvmlite: make it statically link to llvm
Browse files Browse the repository at this point in the history
Llvmlite doc says that they link to llvm statically, but it's not. Check

- numba/llvmlite#1027.
- https://github.com/numba/llvmlite/blob/ca123c3ae2a6f7db865661ae509862277ec5d692/docs/source/faqs.rst#why-static-linking-to-llvm

This behavior causes problems when python uses another version of llvm,
for example, mesa llvmpipe. This PR force llvmlite statically link to llvm.

Besides, this PR also use llvm as buildInputs rather than nativeBuildInputs
since it's a library that llvmlite use rather than a part of build system.

This PR also cleans outdated patches.
  • Loading branch information
wrvsrx committed Sep 7, 2024
1 parent e0fbd93 commit 62fae87
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions pkgs/development/python-modules/llvmlite/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
isPyPy,
pythonAtLeast,

# build-system
llvm,
setuptools,

# tests
pytestCheckHook,
llvm,
libxml2,

withStaticLLVM ? true,
}:

buildPythonPackage rec {
Expand All @@ -28,32 +30,27 @@ buildPythonPackage rec {
hash = "sha256-5QBSRDb28Bui9IOhGofj+c7Rk7J5fNv5nPksEPY/O5o=";
};

nativeBuildInputs = [
llvm
setuptools
];
build-system = [ setuptools ];

postPatch = ''
substituteInPlace llvmlite/tests/test_binding.py \
--replace-fail "test_linux" "nope"
buildInputs = [ llvm ] ++ lib.optionals withStaticLLVM [ libxml2.dev ];

postPatch = lib.optionalString withStaticLLVM ''
substituteInPlace ffi/build.py --replace-fail "--system-libs --libs all" "--system-libs --libs --link-static all"
'';

# Set directory containing llvm-config binary
preConfigure = ''
export LLVM_CONFIG=${llvm.dev}/bin/llvm-config
'';
env.LLVM_CONFIG = "${llvm.dev}/bin/llvm-config";

nativeCheckInputs = [ pytestCheckHook ];

nativeCheckInputs = [
pytestCheckHook
];
# https://github.com/NixOS/nixpkgs/issues/255262
preCheck = ''
cd $out
'';

__impureHostDeps = lib.optionals stdenv.isDarwin [ "/usr/lib/libm.dylib" ];

passthru.llvm = llvm;
passthru = lib.optionalAttrs (!withStaticLLVM) { inherit llvm; };

meta = {
changelog = "https://github.com/numba/llvmlite/blob/v${version}/CHANGE_LOG";
Expand Down

0 comments on commit 62fae87

Please sign in to comment.