Skip to content

Commit

Permalink
No longer need wasm-ld patch
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-blaeser committed Sep 3, 2024
1 parent d663594 commit 3d0f34e
Showing 1 changed file with 2 additions and 55 deletions.
57 changes: 2 additions & 55 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,10 @@ let ic-ref-run =
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; [
llvmPackages_18.clang
llvm_bintools
patched-wasm-ld
llvmPackages_18.bintools
rustc-nightly
cargo-nightly
wasmtime
Expand Down Expand Up @@ -361,7 +308,7 @@ rec {

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

testDerivation = args:
stdenv.mkDerivation (testDerivationArgs // args);
Expand Down

0 comments on commit 3d0f34e

Please sign in to comment.