Package build depending on openMP failing on MacOS, certainly due to not using Apple's clang #449
-
Hello, I am trying to install a R package from a github repository using rix, and it seems like I'm having troubles compiling it because of the openMP lib, which is a common issue on macOS, but whose solution does not seem ot work when combined with nix. That is why I come here to find some help after trying some stuff that did not work out: I have the following rix generated config rix::rix(
system_pkgs = NULL,
r_ver = paste0(R.version$major, ".", R.version$minor),
r_pkgs = NULL,
git_pkgs = list(
list(package_name = "adaptiveFTS", repo_url = "https://github.com/hmaissoro/adaptiveFTS", commit = "af5a9859165a7f95046a7c57683e7094e3f4de9f")
),
tex_pkgs = NULL,
ide = "none",
project_path = ".",
overwrite = TRUE,
print = FALSE,
message_type = "verbose"
) giving # This file was generated by the {rix} R package v0.15.5 on 2025-03-12
# with following call:
# >rix(r_ver = "4.4.2",
# > r_pkgs = NULL,
# > system_pkgs = NULL,
# > git_pkgs = list(list(package_name = "adaptiveFTS",
# > repo_url = "https://github.com/hmaissoro/adaptiveFTS",
# > commit = "af5a9859165a7f95046a7c57683e7094e3f4de9f")),
# > tex_pkgs = NULL,
# > ide = "none",
# > project_path = ".",
# > overwrite = TRUE,
# > print = FALSE,
# > message_type = "verbose")
# It uses the `rstats-on-nix` fork of `nixpkgs` which provides improved
# compatibility with older R versions and R packages for Linux/WSL and
# Apple Silicon computers.
# Report any issues to https://github.com/ropensci/rix
let
pkgs = import (fetchTarball "https://github.com/rstats-on-nix/nixpkgs/archive/2025-02-24.tar.gz") {};
adaptiveFTS = (pkgs.rPackages.buildRPackage {
name = "adaptiveFTS";
src = pkgs.fetchgit {
url = "https://github.com/hmaissoro/adaptiveFTS";
rev = "af5a9859165a7f95046a7c57683e7094e3f4de9f";
sha256 = "sha256-cWjDmKBy2bxukl4lsDPHyLreRyPnCz/mcBfFUagGjAo=";
};
propagatedBuildInputs = builtins.attrValues {
inherit (pkgs.rPackages)
caret
data_table
fastmatrix
MASS
Rcpp
Rdpack
RcppArmadillo;
};
});
system_packages = builtins.attrValues {
inherit (pkgs)
glibcLocales
nix
R;
};
in
pkgs.mkShell {
LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
LANG = "en_US.UTF-8";
LC_ALL = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
buildInputs = [ adaptiveFTS system_packages ];
} which led to the following error once entering nix-shell
giving the following error :
here is why I tried :
# default.nix
buildInputs = [ adaptiveFTS system_packages pkgs.llvmPackages.openmp ]; same when adding
adaptiveFTS = (pkgs.rPackages.buildRPackage {
name = "adaptiveFTS";
src = pkgs.fetchgit {
url = "https://github.com/hmaissoro/adaptiveFTS";
rev = "af5a9859165a7f95046a7c57683e7094e3f4de9f";
sha256 = "sha256-cWjDmKBy2bxukl4lsDPHyLreRyPnCz/mcBfFUagGjAo=";
};
propagatedBuildInputs = builtins.attrValues {
inherit (pkgs.rPackages)
caret
data_table
fastmatrix
MASS
Rcpp
Rdpack
RcppArmadillo;
};
postPatch = ''
echo "CPPFLAGS += -Xclang -fopenmp" >> src/Makevars
echo "LDFLAGS += -lomp" >> src/Makevars
'';
}); I really don't know how to solve it, any idea ? thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
and can leave the rest as-is. This type of fix is exactly what we (by "we" I mean the R packagers for Nix) do for packages released on CRAN and Bioconductor, so users don’t have to deal with it. But unfortunately, we can’t do that for every package released on Github...
as this would generate a different expression if executed on a different version of R. Instead, I recommend you hardcode the version of R, or even better, set a date with |
Beta Was this translation helpful? Give feedback.
pkgs.llvmPackages.openmp
is a dependency ofadaptiveFTS
, but you added it as a dependency of the shell. You need to change the expression like so: