Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Upgrade RTS Dependencies #4677

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 62 additions & 16 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,90 @@ let ic-ref-run =
cp ${ic-hs-pkgs.ic-hs}/bin/ic-ref-run $out/bin
''; in

let
nixos-unstable = import nixpkgs.sources.nixpkgs-unstable {};
in

let haskellPackages = nixpkgs.haskellPackages.override {
overrides = import nix/haskell-packages.nix nixpkgs subpath;
}; in
let llvm_sources = nixpkgs.fetchFromGitHub {
owner = "llvm";
repo = "llvm-project";
rev = "llvmorg-18.1.8";
sha256 = "sha256-iiZKMRo/WxJaBXct9GdAcAT3cz9d9pnAcO1mmR6oPNE=";
}; in
let patched-wasm-ld = stdenv.mkDerivation {
name = "wasm-ld";
src = llvm_sources;
nativeBuildInputs = with nixpkgs; [ cmake ninja ];
buildInputs = with nixpkgs; [ llvmPackages_18.libllvm libxml2 ];

patchPhase = ''
patch lld/wasm/Relocations.cpp << EOF
@@ -104,9 +104,15 @@ void scanRelocations(InputChunk *chunk) {
case R_WASM_TABLE_INDEX_SLEB64:
case R_WASM_TABLE_INDEX_REL_SLEB:
case R_WASM_TABLE_INDEX_REL_SLEB64:
- if (requiresGOTAccess(sym))
- break;
+ if (!sym->isDefined()) {
+ error(toString(file) + ": relocation " + relocTypeToString(reloc.Type) +
+ " cannot be used against an undefined symbol \`" + toString(*sym) +
+ "\`");
+ }
out.elemSec->addEntry(cast<FunctionSymbol>(sym));
+ if (requiresGOTAccess(sym)) {
+ addGOTEntry(sym);
+ }
break;
case R_WASM_GLOBAL_INDEX_LEB:
case R_WASM_GLOBAL_INDEX_I32:
EOF
cd lld
'';

outputs = [ "out" ];
}; in
# Selectively build llvm binary tools.
# Exclude wasm-ld, as this is patched separately.
let llvm_bintools = stdenv.mkDerivation {
name = "llvm_bintools";
src = llvm_sources;
nativeBuildInputs = with nixpkgs; [ cmake ninja python3 ];
buildInputs = with nixpkgs; [ llvmPackages_18.libllvm libxml2 ];

preConfigure = ''
cd llvm
'';

outputs = [ "out" ];
}; in
let
rtsBuildInputs = with nixpkgs; [
# pulls in clang (wrapped) and clang-13 (unwrapped)
llvmPackages_13.clang
# pulls in wasm-ld
llvmPackages_13.lld
llvmPackages_13.bintools
llvmPackages_18.clang
llvm_bintools
patched-wasm-ld
rustc-nightly
cargo-nightly
wasmtime
rust-bindgen
python3
nixos-unstable.emscripten
binaryen
] ++ pkgs.lib.optional pkgs.stdenv.isDarwin [
libiconv
];

llvmEnv = ''
# When compiling to wasm, we want to have more control over the flags,
# so we do not use the nix-provided wrapper in clang
export WASM_CLANG="clang-13"
export WASM_CLANG="clang-18"
export WASM_LD=wasm-ld
# because we use the unwrapped clang, we have to pass in some flags/paths
# that otherwise the wrapped clang would take care for us
export WASM_CLANG_LIB="${nixpkgs.llvmPackages_13.clang-unwrapped.lib}"
export WASM_CLANG_LIB="${nixpkgs.llvmPackages_18.clang-unwrapped.lib}"

# When compiling natively, we want to use `clang` (which is a nixpkgs
# provided wrapper that sets various include paths etc).
# But for some reason it does not handle building for Wasm well, so
# there we use plain clang-13. There is no stdlib there anyways.
export CLANG="${nixpkgs.clang_13}/bin/clang"
# there we use plain clang-18. There is no stdlib there anyways.
export CLANG="${nixpkgs.clang_18}/bin/clang"
'';
in

Expand Down Expand Up @@ -172,7 +218,7 @@ rec {
vendorRustStdDeps = "${cargoVendorTools}/bin/vendor-rust-std-deps";

# SHA256 of Rust std deps
rustStdDepsHash = "sha256-A3WPIx+weu4wIYV7cweGkRxYGAPt7srxBAtMEyPOkhI=";
rustStdDepsHash = "sha256-U4BTr1CzFuOMdyLuhw5ry3/u8bkRiPmnMr4pLo3IdOQ=";

# Vendor directory for Rust std deps
rustStdDeps = nixpkgs.stdenvNoCC.mkDerivation {
Expand Down Expand Up @@ -337,7 +383,7 @@ rec {

# extra deps for test/ld
ldTestDeps =
with nixpkgs; [ llvmPackages_13.bintools llvmPackages_13.clang ];
with nixpkgs; [ patched-wasm-ld llvmPackages_18.clang ];

testDerivation = args:
stdenv.mkDerivation (testDerivationArgs // args);
Expand Down
2 changes: 1 addition & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ let

# Rust nightly
(self: super: let
rust-channel = self.moz_overlay.rustChannelOf { date = "2023-04-21"; channel = "nightly"; };
rust-channel = self.moz_overlay.rustChannelOf { date = "2024-07-28"; channel = "nightly"; };
in rec {
rustc-nightly = rust-channel.rust.override {
targets = [
Expand Down
8 changes: 4 additions & 4 deletions nix/drun.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ EOF

buildInputs = with pkgs; [
openssl
llvm_13
llvmPackages_13.libclang
llvm_18
llvmPackages_18.libclang
lmdb
libunwind
libiconv
] ++ pkgs.lib.optional pkgs.stdenv.isDarwin
pkgs.darwin.apple_sdk.frameworks.Security;

# needed for bindgen
LIBCLANG_PATH = "${pkgs.llvmPackages_13.libclang.lib}/lib";
CLANG_PATH = "${pkgs.llvmPackages_13.clang}/bin/clang";
LIBCLANG_PATH = "${pkgs.llvmPackages_18.libclang.lib}/lib";
CLANG_PATH = "${pkgs.llvmPackages_18.clang}/bin/clang";

# needed for ic-protobuf
PROTOC="${pkgs.protobuf}/bin/protoc";
Expand Down
33 changes: 10 additions & 23 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@
"version": "v1.2.0"
},
"motoko-base": {
"branch": "next-moc",
"branch": "pull/589/head",
"description": "The Motoko base library",
"homepage": "",
"owner": "dfinity",
"repo": "motoko-base",
"rev": "4abc98e92909d7b178629912057473302cf0d8be",
"sha256": "09yhfk17rb9xk2cvi6353hfb43df05pg0x1gw5qrf8n0g0dvd3jx",
"rev": "a391ab0d202537efef90431f53834819ca666c1c",
"sha256": "1nhya2g86l8r70wrai4gzqvdws4waag3d8r2ijbpvgqfkmam5j4r",
"type": "tarball",
"url": "https://github.com/dfinity/motoko-base/archive/4abc98e92909d7b178629912057473302cf0d8be.tar.gz",
"url": "https://github.com/dfinity/motoko-base/archive/a391ab0d202537efef90431f53834819ca666c1c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"motoko-matchers": {
Expand Down Expand Up @@ -108,16 +108,15 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "release-23.11",
"builtin": true,
"description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels",
"homepage": null,
"branch": "release-24.05",
"description": "Nix Packages collection & NixOS",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6a5b92486ae7826c07fbfad302f569ceb187b0eb",
"sha256": "058kf03v7yh1c4ns96af6jq3ymadv71s7ajv9s05ipl9bnkjfrhm",
"rev": "404f983f8c1da3ed403c95df9bd18d7c3b23399d",
"sha256": "025alb35qf1iwmz45615ahp400q54582kqzc0238a51ai2w88pxc",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/6a5b92486ae7826c07fbfad302f569ceb187b0eb.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/404f983f8c1da3ed403c95df9bd18d7c3b23399d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-mozilla": {
Expand All @@ -133,18 +132,6 @@
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/1ca9ee7192f973fd67b0988bdd77b8c11ae245a6.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-unstable": {
"branch": "master",
"description": "Nix Packages collection & NixOS",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9d2864289e65d0dc841123ae86bc7b3f77b6d12d",
"sha256": "0f3bcphzrjm1hs81mhpfx1hqxfnbvhhv5hv82wi1h3f735i279ja",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/9d2864289e65d0dc841123ae86bc7b3f77b6d12d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"ocaml-vlq": {
"branch": "v0.2.0",
"builtin": false,
Expand Down
Loading