Skip to content

Commit

Permalink
rPackages.rhdf5: fix build
Browse files Browse the repository at this point in the history
use nixpkgs provided hdf5 instead of vendored library
  • Loading branch information
jbedo committed Mar 21, 2023
1 parent 442e1b8 commit 14db22f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkgs/development/r-modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,9 @@ let
propagatedBuildInputs = with pkgs; attrs.propagatedBuildInputs ++ [ (hdf5-blosc.override {hdf5 = hdf5_1_10;}) ];
patches = [ ./patches/rhdf5filters.patch ];
});

rhdf5= old.rhdf5.overrideAttrs (attrs: {
patches = [ ./patches/rhdf5.patch ];
});
};
in
Expand Down
46 changes: 46 additions & 0 deletions pkgs/development/r-modules/patches/rhdf5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/src/Makevars b/src/Makevars
index 713b44c..704ac17 100644
--- a/src/Makevars
+++ b/src/Makevars
@@ -1,5 +1,5 @@
RHDF5_LIBS = $(shell "$(R_HOME)/bin${R_ARCH_BIN}/Rscript" -e 'Rhdf5lib::pkgconfig("PKG_C_LIBS")')
-PKG_LIBS = $(RHDF5_LIBS)
+PKG_LIBS = $(RHDF5_LIBS) -lhdf5

#PKG_CFLAGS = -Wall

diff --git a/src/h5testLock.c b/src/h5testLock.c
index b326444..5d58b4a 100644
--- a/src/h5testLock.c
+++ b/src/h5testLock.c
@@ -8,16 +8,16 @@ SEXP _h5fileLock(SEXP _file_name) {
int lk = -1;

/* create the temporary file */
- fd = HDopen(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = open(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666);

/* try to lock file */
- lk = HDflock(fd, LOCK_EX | LOCK_NB);
+ lk = flock(fd, LOCK_EX | LOCK_NB);

/* unlock so we can remove */
- HDflock(fd, LOCK_UN);
+ flock(fd, LOCK_UN);

/* close */
- HDclose(fd);
+ close(fd);

/* return value of lock attempt */
PROTECT(Rval = allocVector(INTSXP, 1));
diff --git a/src/h5testLock.h b/src/h5testLock.h
index 2c1c5e4..660c747 100644
--- a/src/h5testLock.h
+++ b/src/h5testLock.h
@@ -1,5 +1,4 @@
#include <fcntl.h>
#include "myhdf5.h"
-#include <H5private.h>

SEXP _h5fileLock();

0 comments on commit 14db22f

Please sign in to comment.