nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

Update Request: roc: update to zig beyond 0.13 and llvm beyond 18

Open whispersofthedawn opened this issue 3 months ago • 7 comments

Nixpkgs version

  • Unstable (26.11)

Package name

roc

Upstream version

none, or 0-unstable-2026-08-25

Nixpkgs version

0-alpha4

Changelog

No response

Additional context

hello! we're currently working on dropping zig 0.13 (which required llvm 18) and llvm 18 in nixpkgs, in order to keep our llvm version maintenance sustainable (having several versions is often extra load for the llvm maintainers when they get old, they often suffer for being long eol upstream and we don't often have the capacity to apply useful bugfix patches, etc.). roc is one of the few remaining dependents of both of these, so we want to update roc past the alpha4 tag (which still requires zig 0.13) to the current state of the main branch (or at least some other suitable newer commit that updates these requirements).

we were working on writing a derivation that worked on a new commit in an attempt to pr an update, but we've been unable to figure out how to do so for the last few days; the build process seems to inevitably hit many linker errors. we've attached the derivation we've been trying to write, as well as the logs we get as we try to build it. we would very much appreciate any help from someone more familiar with roc and the zig build systems in order to get this working so that we can proceed with dropping these old compiler versions without having to remove/break roc. thanks!

pkgs/by-name/ro/roc/package.nix

{
  lib,
  stdenv,
  callPackage,
  fetchFromGitHub,
  llvmPackages,
  zig_0_16,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "roc";
  version = "0-unstable-2026-08-20";

  src = fetchFromGitHub {
    owner = "roc-lang";
    repo = "roc";
    rev = "8ce56ad2d70a3723107988f2dcd96d565739a647";
    hash = "sha256-lmXtCqma5zbQuzZn5aN/CwGNjFhO1xLOxx+javuqc5I=";
  };

  __structuredAttrs = true;
  strictDeps = true;

  nativeBuildInputs = [
    llvmPackages.llvm.dev
    zig_0_16
  ];

  buildInputs = [
    llvmPackages.lld
    llvmPackages.llvm
  ];

  deps = callPackage ./deps.nix { };
  zigBuildFlags = [
    "-Dsystem-llvm=true"
    "--system"
    "${finalAttrs.deps}"
  ];

  meta = {
    description = "Fast, friendly, functional programming language";
    mainProgram = "roc";
    homepage = "https://www.roc-lang.org/";
    changelog = "https://github.com/roc-lang/roc/releases/tag/alpha4-rolling";
    license = lib.licenses.upl;
    maintainers = [
      lib.maintainers.anton-4
      lib.maintainers.bhansconnect
      lib.maintainers.rtfeldman
    ];
    platforms = [ "x86_64-linux" ];
  };
})
pkgs/by-name/ro/roc/deps.nix (collapsed for brevity, click to expand)
# generated by zon2nix (https://github.com/Cloudef/zig2nix)

{
  lib,
  linkFarm,
  runCommand,
  zig,
  name ? "zig-packages",
}:

let
  fetchZig =
    {
      name,
      url,
      hash,
    }:
    runCommand "${name}.tar.gz"
      {
        src = url;
        nativeBuildInputs = [ zig ];
        outputHash = hash;
        outputHashMode = "flat";
      }
      ''
        touch "$TMPDIR/build.zig" # workaround <https://codeberg.org/ziglang/zig/issues/31866>
        mkdir -p "$TMPDIR/tmp" # zig 0.16 writes the downloaded .zip to <cache>/tmp before extracting; it does not create this dir itself
        hash="$(cd "$TMPDIR" && zig fetch --global-cache-dir "$TMPDIR" "${url}")"
        mv "$TMPDIR/p/$hash.tar.gz" "$out"
      '';

  # `zig build --system <dir>` looks packages up by their bare hash and expects
  # each to be an extracted directory, not a tarball. fetchZig produces the
  # canonical `<hash>.tar.gz` (which contains a single `<hash>/` top-level dir),
  # so strip the suffix from the name and unpack into a directory.
  unpackZig = entry: {
    name = lib.removeSuffix ".tar.gz" entry.name;
    path = runCommand (lib.removeSuffix ".tar.gz" entry.name) { } ''
      mkdir -p "$out"
      tar -xf "${entry.path}" -C "$out" --strip-components=1
    '';
  };
in
linkFarm name (
  map unpackZig [
    {
      name = "afl_kit-0.1.0-NdJ3csgfAABGuiQ4P99kFuaVSy4DHMilISiGF_VKX3xl.tar.gz";
      path = fetchZig {
        name = "afl_kit";
        url = "https://github.com/bhansconnect/zig-afl-kit/archive/c1f7353e006cf326ffab0a35b6e454cb5d8a5d7b.tar.gz";
        hash = "sha256-sVnskL0JQgqPWEZxj3XyZSj+0iMK7LY4+CV2ppv0O4U=";
      };
    }
    {
      name = "AFLplusplus-4.21.0-aA1y4ZlxAAAHcA1GykLz0bBAGR5RbAZqUvr3SJ38JaZX.tar.gz";
      path = fetchZig {
        name = "AFLplusplus";
        url = "https://github.com/bhansconnect/AFLplusplus/archive/106e7b61a85b0ee4b226a73c7a6fa0e9361a1664.tar.gz";
        hash = "sha256-12dlYYCRjDMUd7fuD5BNEl9CNtXcIhgPf0OEhYwdQQc=";
      };
    }
    {
      name = "N-V-__8AAKE4uAAJZgEcPdaXnWqoj-IwYf3G2h9YSm-x92gg.tar.gz";
      path = fetchZig {
        name = "AFLplusplus";
        url = "https://github.com/AFLplusplus/AFLplusplus/archive/v4.21c.tar.gz";
        hash = "sha256-XVa9UhZXYzUrD78Xm1epNqiRaqOM+Gfpf88LYU23DHg=";
      };
    }
    {
      name = "N-V-__8AAKS-VRH7JXsaDHpnFPSd-B5fSdtnDbh0XrfnncWc.tar.gz";
      path = fetchZig {
        name = "roc_deps_aarch64_macos_none";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/aarch64-macos-none.tar.xz";
        hash = "sha256-PHSLa/8IAE0rqFVJGqt0NAQxAfcPy8QciTutttiqCTo=";
      };
    }
    {
      name = "N-V-__8AACK4KheKSiltX0PPURTNh0CvJhsopNXzcXpvq9pS.tar.gz";
      path = fetchZig {
        name = "roc_deps_aarch64_linux_musl";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/aarch64-linux-musl.tar.xz";
        hash = "sha256-fQOa0r5EVMenjRH2LhUYN6BKeMKtO5yDRVgOO0+ktIs=";
      };
    }
    {
      name = "N-V-__8AAPEjNhjVXuc6-b70fcyHFGS_ckUIx5_ICD3-3HZk.tar.gz";
      path = fetchZig {
        name = "roc_deps_aarch64_windows_gnu";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/aarch64-windows-gnu.zip";
        hash = "sha256-Pb22bvfTgAgMIShfDxejvvVFE9TBLjGAnzNxt1WlD/c=";
      };
    }
    {
      name = "N-V-__8AAKywPxfY01H2OMTuZllxIuavfyGGm3kpW7-1RmkP.tar.gz";
      path = fetchZig {
        name = "roc_deps_arm_linux_musleabihf";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/arm-linux-musleabihf.tar.xz";
        hash = "sha256-OEvSYrTtt3sroPN2jxcZw7Oqolb6jHeKY7z+7CgnaWs=";
      };
    }
    {
      name = "N-V-__8AAMg8ihSrg9Udc8ZJ1trVVUgglxJg8CbHoYG51dZq.tar.gz";
      path = fetchZig {
        name = "roc_deps_x86_linux_musl";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86-linux-musl.tar.xz";
        hash = "sha256-9jCTSnMCLmEUbqPX+iDQ/KR+04jy6JlX9jb7fPCgQI4=";
      };
    }
    {
      name = "N-V-__8AAGJLMhhn8pu3uyxtKTIlha8CxCjE6TNpLYvvj-cz.tar.gz";
      path = fetchZig {
        name = "roc_deps_x86_64_linux_musl";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86_64-linux-musl.tar.xz";
        hash = "sha256-f7zDjI+VYBAkiBGVRNbSn6FI+2W7zpeoUa1ZuEFibwA=";
      };
    }
    {
      name = "N-V-__8AAJrG0hG7ZWMT8yxRBa17ivn77bWqDpseO904PYT7.tar.gz";
      path = fetchZig {
        name = "roc_deps_x86_64_macos_none";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86_64-macos-none.tar.xz";
        hash = "sha256-quDJkY/ts7Z7UDrqxOxa+DV4AIfidbO6rZRIHRt3sFQ=";
      };
    }
    {
      name = "N-V-__8AADfFZhvsrNly3AbA2PmVP9piXKNto_CmeqLuNNsd.tar.gz";
      path = fetchZig {
        name = "roc_deps_x86_64_windows_gnu";
        url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86_64-windows-gnu.zip";
        hash = "sha256-aWM3aagVe0qgTtHmcpFKniaqVTdsVJwneDfTtcDVWgE=";
      };
    }
    {
      name = "bytebox-0.0.1-SXc2saRyDwDEw8AkDhp4Hfmd9ZhRmMnIzS7FfzDCmc8r.tar.gz";
      path = fetchZig {
        name = "bytebox";
        url = "https://github.com/lukewilliamboswell/bytebox/archive/88a4b79230eece88030e6779f69ed9683906c02a.tar.gz";
        hash = "sha256-Cbkw9Q7JFEQGRS12IjBw581fgth+HJIAo3Ppvd2XvuM=";
      };
    }
    {
      name = "stable_array-0.1.0-3ihgvd9eAAA5ozV4aOQZ6GI3d_gTyiR9tS6mwav2w18o.tar.gz";
      path = fetchZig {
        name = "stable_array";
        url = "git+https://github.com/lukewilliamboswell/zig-stable-array.git#0931a8619b0e5429e1573caf1a1b34a421e4c76a";
        hash = "sha256-n/NV3r5ji4+fW+c/I8AzjnLsGU4nUSzmJtdAI6+TcRk=";
      };
    }
    {
      name = "zstd-1.5.7-1-KEItkAMwAAD6OKY3m0OOmXG7aL-aLUfrDqbP5J5oYapU.tar.gz";
      path = fetchZig {
        name = "zstd";
        url = "https://github.com/allyourcodebase/zstd/archive/e1a501be57f42c541e8a5597e4b59a074dfd09a3.tar.gz";
        hash = "sha256-Za7i8doQDlzwjScm8GGqxwaO7qBVz23+KqhXkyHBti8=";
      };
    }
    {
      name = "N-V-__8AAGxifwAAGwXwvsnl_aOXFGLZTeYCu0WBhuEXr96u.tar.gz";
      path = fetchZig {
        name = "zstd";
        url = "git+https://github.com/facebook/zstd.git?ref=v1.5.7#f8745da6ff1ad1e7bab384bd1f9d742439278e99";
        hash = "sha256-h35u+KqPsc9xZQ7xJu15M4etPnBIM33NUVG4NKzMZHw=";
      };
    }
    {
      name = "kcov-42.0.1-EuAG4XacCwBu0G8YHvv6sFHfbMPZuwyBuZGqcRMi8IXq.tar.gz";
      path = fetchZig {
        name = "kcov";
        url = "https://github.com/roc-lang/zig-kcov/archive/5e1954e53ce775a6ecf65abd03ae67deee64ac3c.tar.gz";
        hash = "sha256-vFZLwp2H04EnMCPOxZYuQoVv84WBzknpmoXURbfmpR0=";
      };
    }
  ]
)

failing build logs: roc.log

failing build logs snippet. there are many more of these errors that i've omitted here (see the logs above for a slightly more comprehensive list). i assume this is some sort of broken interaction with our linker wrapper, but i'm not sure what.

mq install eval-test-runner
   mq compile exe eval-test-runner ReleaseSafe native-native 145 errors
error: ld.lld: undefined symbol: std::__throw_system_error(int)
    note: referenced by ManagedStatic.cpp.o:(llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void (*)(void*)) const (.cold)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by ErrorHandling.cpp.o:(std::mutex::lock()) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by PostRAHazardRecognizer.cpp.o:(llvm::initializePostRAHazardRecognizerLegacyPass(llvm::PassRegistry&) (.cold)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMCodeGen.a
    note: referenced 956 more times
error: ld.lld: undefined symbol: std::__throw_length_error(char const*)
    note: referenced by raw_ostream.cpp.o:(std::vector<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>, std::allocator<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>>>::_M_insert_rval(__gnu_cxx::__normal_iterator<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>> const*, std::vector<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>, std::allocator<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>>>>, std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>&&) (.isra.0.cold)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by raw_ostream.cpp.o:(llvm::raw_string_ostream::write_impl(char const*, unsigned long) (.cold)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by raw_ostream.cpp.o:(std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>& std::vector<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>, std::allocator<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>>>::emplace_back<std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>>(std::unique_ptr<llvm::ErrorInfoBase, std::default_delete<llvm::ErrorInfoBase>>&&) (.isra.0.cold)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced 2989 more times
error: ld.lld: undefined symbol: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_append(char const*, unsigned long)
    note: referenced by raw_ostream.cpp.o:(llvm::raw_string_ostream::write_impl(char const*, unsigned long) (.localalias)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by Threading.cpp.o:(ReportErrnumFatal(char const*, int)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by RISCVAttributeParser.cpp.o:(llvm::RISCVAttributeParser::stackAlign(unsigned int)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced 2021 more times
error: ld.lld: undefined symbol: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::reserve(unsigned long)
    note: referenced by raw_ostream.cpp.o:(llvm::raw_string_ostream::reserveExtraSpace(unsigned long)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by Threading.cpp.o:(ReportErrnumFatal(char const*, int)) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSupport.a
    note: referenced by SystemZTargetMachine.cpp.o:(llvm::SystemZTargetMachine::getSubtargetImpl(llvm::Function const&) const) in archive /nix/store/5kpahz1x5zi3jx7yk44k80ga23mnsrah-llvm-21.1.8-lib/lib/libLLVMSystemZCodeGen.a
    note: referenced 682 more times

thank you for any assistance!

Notify maintainers

@Anton-4 @bhansconnect @rtfeldman


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a :+1: reaction to issues you find important.

whispersofthedawn avatar Aug 25 '26 12:08 whispersofthedawn

Thanks for your efforts @whispersofthedawn :heart: I will finish the derivation.

Anton-4 avatar Aug 25 '26 15:08 Anton-4

I hava a package.nix working on linux x64 and darwin aarch64, I'm going to do cleanup and linux aarch64 next week and will then create a PR.

Anton-4 avatar Aug 26 '26 15:08 Anton-4

thank you so much! i very much appreciate it (and especially how quickly you got to it) <3

whispersofthedawn avatar Aug 26 '26 16:08 whispersofthedawn

I'm going to do cleanup and linux aarch64 next week

I'm not done yet, my raspberry pi 5 was having boot issues, I should be done next week though.

Anton-4 avatar Sep 05 '26 17:09 Anton-4

thank you! and there's no rush, please don't feel pressured to do this quickly. (my personal hope is to get this done before 26.11 (so i guess its breaking change deadline in late october/early november), but there's still quite some time for that.) we'd of course welcome it whenever, but please don't work yourself more on our behalf 😅

whispersofthedawn avatar Sep 06 '26 12:09 whispersofthedawn

@whispersofthedawn would you be able to arrange a review of https://github.com/NixOS/nixpkgs/pull/564994? I'd like to get that merged so that we're ready for releasing Roc 0.1. There would likely be no meaningful structural changes to the package.nix for the nightly and for Roc 0.1.

Anton-4 avatar Oct 01 '26 20:10 Anton-4

oh, so sorry for not seeing it sooner! i didn't get notified that a pr got linked to this issue. I'll try to take a look as soon as i can. it'll probably be some time this weekend.

whispersofthedawn avatar Oct 01 '26 21:10 whispersofthedawn