Darwin ld: symbol(s) not found for architecture arm64

When building this derivation on aarch64-darwin

{ lib, stdenv, fetchFromGitHub, postgresql, buildPgrxExtension_0_11_3, cargo }:

buildPgrxExtension_0_11_3 rec {
  pname = "pg_jsonschema";
  version = "0.3.1";
  inherit postgresql;

  src = fetchFromGitHub {
    owner = "supabase";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-YdKpOEiDIz60xE7C+EzpYjBcH0HabnDbtZl23CYls6g=";
  };

  nativeBuildInputs = [ cargo ];
  
  CARGO="${cargo}/bin/cargo";


  cargoHash = "sha256-VcS+efMDppofuFW2zNrhhsbC28By3lYekDFquHPta2g=";

 
[...]
}

ā€¦I am seeing this error

error: builder for '/nix/store/f2l1mmmdwlfmgi573hxp1f6qx7zihv98-pg_jsonschema-0.3.1.drv' failed with exit code 1;
       last 25 log lines:
       >                 _json_matches_schema_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 _jsonb_matches_schema_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 _jsonschema_is_valid_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 _jsonschema_validation_errors_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 pgrx_pg_sys::submodules::panic::do_ereport::hfe61f19947abbacd in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >             "_errhint", referenced from:
       >                 pgrx_pg_sys::submodules::panic::do_ereport::hfe61f19947abbacd in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >             "_makeArrayResult", referenced from:
       >                 pgrx_pg_sys::submodules::panic::run_guarded::h21cb3d48f146972e in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >             "_CurrentMemoryContext", referenced from:
       >                 pgrx_pg_sys::submodules::panic::run_guarded::h06a14908341f51f0 in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 pgrx_pg_sys::submodules::panic::run_guarded::h21cb3d48f146972e in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 pgrx::fcinfo::pg_12_13_14_15::pg_getarg::hc159b2c765c403b8 in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 _json_matches_schema_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 _jsonb_matches_schema_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 _jsonschema_is_valid_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 _jsonschema_validation_errors_wrapper in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >                 ...
       >             "_jsonb_out", referenced from:
       >                 pgrx_pg_sys::submodules::panic::run_guarded::h06a14908341f51f0 in pg_jsonschema.pg_jsonschema.cd8733de31c8f1ea-cgu.0.rcgu.o
       >           ld: symbol(s) not found for architecture arm64
       >           clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
       >           
       >

I am guessing that this might end up being fixed by a combination of the PRā€™s

and

Although I am not 100% sure.

@reckenrode thought Iā€™d ask and see also if there is anything I can do to help with these fixes?

If you check the whole log, is there an error about an unrecognized file format? Something about a bunch of hex digits? If so, thatā€™s due to broken LTO support. Looking at upstreamā€™s Cargo.toml, they set LTO = fat on release builds, so I assume thatā€™s it.

Iā€™ve been waiting to move forward due to the freeze on breaking changes before the release. Now that staging is open for post-24.05 changes, Iā€™m going to start cherry-picking prerequisite PRs once the Darwin channel blockers finish building locally.

2 Likes