Merge pull request #218968 from pmiddend/crystfel-aarch64

CrystFEL: support aarch64-linux and HDF5 on Darwin
This commit is contained in:
Weijia Wang 2023-04-26 19:32:54 +03:00 committed by GitHub
commit 7b57f59155
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 62 deletions

View file

@ -1,43 +0,0 @@
Description: Fixing argument mismatches in Fortran code, addressing #957430.
Author: Andrius Merkys <merkys@debian.org>
Forwarded: ccp4-dev@dl.ac.uk
--- a/fortran/pack_f.f
+++ b/fortran/pack_f.f
@@ -106,7 +106,7 @@
endif
10 continue
filnarray(len(filn) + 1) = 0
- call pack_wordimage_f(data, x, y, filnarray)
+ call pack_longimage_f(data, x, y, filnarray)
return
end
@@ -138,7 +138,7 @@
endif
10 continue
filnarray(len(filn) + 1) = 0
- call v2pack_wordimage_f(data, x, y, filnarray)
+ call v2pack_longimage_f(data, x, y, filnarray)
return
end
--- a/fortran/lgglib.f
+++ b/fortran/lgglib.f
@@ -1236,7 +1236,7 @@
B3(2) = XYZ(2) * CELL(2)
B3(3) = XYZ(3) * CELL(3)
C
- CALL matmult(3,3,3,1,ORTH,B3,XYZ,B1)
+ CALL matmult(3,3,3,1,ORTH,B3,XYZ)
END
c
c
@@ -1274,7 +1274,7 @@
B3(1) = XYZ(1)
B3(2) = XYZ(2)
B3(3) = XYZ(3)
- CALL matmult(3,3,3,1,ORTH,B3,XYZ,B1)
+ CALL matmult(3,3,3,1,ORTH,B3,XYZ)
END
character*80 function getnam(filnam)
character*(*) filnam

View file

@ -3,10 +3,10 @@
, fetchurl
, fetchFromGitHub
, fetchpatch
, fetchzip
, cmake
, lz4
, bzip2
, gfortran
, m4
, hdf5
, gsl
@ -38,14 +38,12 @@
let
libccp4 = stdenv.mkDerivation rec {
pname = "libccp4";
version = "6.5.1";
version = "8.0.0";
src = fetchurl {
# Original mirror, now times out
# url = "ftp://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz";
url = "https://deb.debian.org/debian/pool/main/libc/${pname}/${pname}_${version}.orig.tar.gz";
sha256 = "1rfvjliny29vy5bdi6rrjaw9hhhhh72pw536xwvqipqcjlylf2r8";
url = "https://ftp.ccp4.ac.uk/opensource/${pname}-${version}.tar.gz";
hash = "sha256-y4E66GYSoIZjKd6rfO6W6sVz2BvlskA0HUD5rVMi/y0=";
};
nativeBuildInputs = [ gfortran m4 ];
nativeBuildInputs = [ meson ninja ];
buildInputs = [ hdf5 gsl ];
configureFlags = [ "FFLAGS=-fallow-argument-mismatch" ];
@ -53,16 +51,22 @@ let
# libccp4 tries to read syminfo.lib by looking at an environment variable, which hinders reproducibility.
# We hard-code this by providing a little patch and then passing the absolute path to syminfo.lib as a
# preprocessor flag.
preBuild = ''
makeFlagsArray+=(CFLAGS='-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/syminfo.lib\"')
export NIX_LDFLAGS="-L${gfortran.cc}/lib64 -L${gfortran.cc}/lib $NIX_LDFLAGS";
'';
makeFlags = [ "CFLAGS='-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/syminfo.lib\"" ];
env.NIX_CFLAGS_COMPILE = "-DNIX_PROVIDED_SYMOP_FILE=\"${placeholder "out"}/share/ccp4/syminfo.lib\"";
patches = [
./libccp4-use-hardcoded-syminfo-lib.patch
./0002-fix-ftbfs-with-gcc-10.patch
];
postPatch =
let
mesonPatch = fetchzip {
url = "https://wrapdb.mesonbuild.com/v2/libccp4c_8.0.0-1/get_patch#somefile.zip";
hash = "sha256-ohskfKh+972Pl56KtwAeWwHtAaAFNpCzz5vZBAI/vdU=";
};
in
''
cp ${mesonPatch}/meson.build .
'';
};
# This is the statically-linked, pre-built binary of mosflm. Compiling it ourselves turns out to be very difficult
# since the build process is very hard-coded for a specific machine, architecture, and libraries.
@ -145,10 +149,17 @@ let
src = fetchFromGitHub {
owner = "nexusformat";
repo = pname;
rev = "d469f175e5273c1d488e71a6134f84088f57d39c";
sha256 = "1jrzzh75i68ad1yrim7s1nx9wy0s49ghkziahs71mm5azprm6gh9";
rev = "49e3b65eca772bca77af13ba047d8b577673afba";
hash = "sha256-bEzfWdZuHmb0PDzCqy8Dey4tLtq+4coO0sT0GzqrTYI=";
};
patches = [
(fetchpatch {
url = "https://github.com/spanezz/HDF5-External-Filter-Plugins/commit/6b337fe36da97a3ef72354393687ce3386c0709d.patch";
hash = "sha256-wnBEdL/MjEyRHPwaVtuhzY+DW1AFeaUQUmIXh+JaRHo=";
})
];
nativeBuildInputs = [ cmake ];
buildInputs = [ hdf5 lz4 bzip2 ];
@ -184,13 +195,14 @@ stdenv.mkDerivation rec {
] ++ lib.optionals withGui [ gtk3 gdk-pixbuf ]
++ lib.optionals stdenv.isDarwin [
argp-standalone
] ++ lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [
memorymappingHook
]
# hdf5-external-filter-plugins doesn't link on Darwin
++ lib.optionals (withBitshuffle && !stdenv.isDarwin) [ hdf5-external-filter-plugins ];
++ lib.optionals withBitshuffle [ hdf5-external-filter-plugins ];
patches = [
./link-to-argp-standalone-if-needed.patch
./disable-fmemopen-on-aarch64-darwin.patch
(fetchpatch {
url = "https://gitlab.desy.de/thomas.white/crystfel/-/commit/3c54d59e1c13aaae716845fed2585770c3ca9d14.diff";
hash = "sha256-oaJNBQQn0c+z4p1pnW4osRJA2KdKiz4hWu7uzoKY7wc=";
@ -204,7 +216,7 @@ stdenv.mkDerivation rec {
sed -i -e 's#execlp("mosflm"#execl("${mosflm}/bin/mosflm"#' libcrystfel/src/indexers/mosflm.c;
'';
postInstall = lib.optionalString (withBitshuffle && !stdenv.isDarwin) ''
postInstall = lib.optionalString withBitshuffle ''
for file in $out/bin/*; do
wrapProgram $file --set HDF5_PLUGIN_PATH ${hdf5-external-filter-plugins}/lib/plugins
done
@ -224,7 +236,7 @@ stdenv.mkDerivation rec {
downloadPage = "https://www.desy.de/~twhite/crystfel/download.html";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ pmiddend ];
platforms = [ "x86_64-linux" "x86_64-darwin" ];
platforms = platforms.unix;
};
}

View file

@ -0,0 +1,13 @@
diff --git a/libcrystfel/src/image-cbf.c b/libcrystfel/src/image-cbf.c
index b8f09a1f..f8a15c1b 100644
--- a/libcrystfel/src/image-cbf.c
+++ b/libcrystfel/src/image-cbf.c
@@ -287,7 +287,7 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h)
} else {
- #ifdef HAVE_ZLIB
+ #if defined(HAVE_ZLIB) && !(defined(__aarch64__) && defined(__APPLE__))
gzFile gzfh;
int len_read;
size_t len;