NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.32k stars 13.56k forks source link

rPackages.later: False positive atomic detection #173497

Open neosimsim opened 2 years ago

neosimsim commented 2 years ago

rPackages.later does not build on darwin aarch64. IIUC this is because the configure scripts has an atomic detection, which is false possitive.

Steps To Reproduce

nix-build -A rPackages.later

Build log

Build fails with

-latomic linker flag needed.
...
ld: library not found for -latomic
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

Additional context

Applying this patch fixes the issues

--- a/configure 2022-05-18 15:11:29.290465967 +0200
+++ b/configure 2022-05-18 15:11:53.806777256 +0200
@@ -5,21 +5,6 @@
 # Find compiler
 CC=`"${R_HOME}"/bin/R CMD config CC`

-# Detect whether -latomic is needed during linking. This is needed on some
-# platforms, notably ARM (Raspberry Pi).
-echo "#include <stdint.h>
-uint64_t v;
-int main() {
-    return (int)__atomic_load_n(&v, __ATOMIC_ACQUIRE);
-}" | ${CC} -x c - -o /dev/null > /dev/null 2>&1
-
-if [ $? -eq 0 ]; then
-  echo "-latomic linker flag not needed."
-else
-  echo "-latomic linker flag needed."
-  EXTRA_PKG_LIBS=-latomic
-fi
-
 case "$CC" in
   *undefined*)
     echo "Found UBSAN. Will skip tests that raise false positives."
    R =
      let
        rPackages = pkgs.rPackages.override {
          overrides = {
            later = pkgs.rPackages.later.overrideAttrs (old: {
              # atomic detection is false positive on macOS aarch64
              patches = with pkgs; lib.optional (with stdenv; isAarch64 && isDarwin) ./r-later.patch;
            });
          };
        };
      in
      rWrapper.override {
        packages = with rPackages; [
          later
        ];
      };

I would provide a PR adding a patch to pkgs/development/r-modules/patches but since this patch is only required on darwin aarch64 I'm not sure how to proceed. Is this a nixpkgs bug or r-lib/later?

turion commented 2 years ago

I think it might be a bug for r-lib/later at first.

idontgetoutmuch commented 2 years ago

I too have this problem :-(

wegank commented 1 year ago

Cannot be reproduced here.

 - system: `"aarch64-darwin"`
 - host os: `Darwin 22.1.0, macOS 13.0.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.11.0`
 - channels(user): `"darwin, home-manager, nixpkgs, nur-packages"`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/Users/user/.nix-defexpr/channels/nixpkgs`