Skip to content

simplicity-sys: tests with test-utils fail to link on Linux since #393 (static library order) #407

Open

Description

@KyrylR

I have tried to run the https://github.com/apoelstra/local-nix-ci and encountered the issue

Since #393 (82124c7), simplicity-sys's own test binary fails to link on Linux with GNU ld when test-utils is enabled, on Rust 1.88 and newer

If you have Linux you can just run the cd simplicity-sys && cargo test --features test-utils from project root

Commit Rust 1.88, Linux Rust 1.74, Linux
546bafe (parent of 82124c7) passes (12 tests) not tested
82124c7 (#393) link error not tested
7fb2601 (current master) link error passes (14 tests)

Before filing a PR to fix it wanna understand whether anyone else also had the same issue

Activity

  1. delta1 commented on Nov 10, 2026

    @delta1
    Contributor

    I can't reproduce this on Debian 13 with Rust 1.99 . Could it be specific to the Nix setup?

  2. apoelstra commented on Nov 10, 2026

    @apoelstra
    Collaborator

    Lemme try to update my nightly pin and see if it shows up.

  3. KyrylR commented on Nov 11, 2026

    @KyrylR
    CollaboratorAuthor

    I am on MacOS, I used this command:

    docker run --rm rust:1.88-bookworm bash -c '
      git clone -q https://github.com/BlockstreamResearch/rust-simplicity &&
      cd rust-simplicity && git checkout -q 7fb2601 &&
      cd simplicity-sys && cargo test --features test-utils'
    

    To reproduce the bug

    Here is the output (part of it):

    ~  ✔ docker run --rm rust:1.88-bookworm bash -c '
      git clone -q https://github.com/BlockstreamResearch/rust-simplicity &&
      cd rust-simplicity && git checkout -q 7fb2601 &&
      cd simplicity-sys && cargo test --features test-utils'
        Updating crates.io index
         Locking 83 packages to latest compatible versions
          Adding base64 v0.22.1 (available: v0.23.1)
          Adding getrandom v0.2.17 (available: v0.4.3)
          Adding logos v0.15.1 (available: v0.16.1)
          Adding miniscript v12.3.8 (available: v13.2.0)
          Adding simplicity-lang v0.3.1 (available: v0.9.0)
     Downloading crates ...
      Downloaded find-msvc-tools v0.1.15
      Downloaded shlex v2.0.1
      Downloaded bitcoin_hashes v1.2.0
      Downloaded bitcoin-internals v0.7.0
      Downloaded hex-conservative v1.3.0
      Downloaded bitcoin-internals v0.6.0
      Downloaded bitcoin-consensus-encoding v1.3.0
      Downloaded arrayvec v0.7.8
      Downloaded cc v1.11.1
       Compiling bitcoin-internals v0.7.0
       Compiling find-msvc-tools v0.1.15
       Compiling bitcoin-internals v0.6.0
       Compiling shlex v2.0.1
       Compiling cc v1.11.1
       Compiling bitcoin-consensus-encoding v1.3.0
       Compiling bitcoin_hashes v1.2.0
       Compiling simplicity-sys v0.8.0 (/rust-simplicity/simplicity-sys)
    error: linking with `cc` failed: exit status: 1
      |
      = note:  "cc" "/tmp/rustc35KT3C/symbols.o" "<59 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "-lRustSimplicityCommon" "-lBitcoinSimplicity" "-lElementsSimplicity" "<sysroot>/lib/rustlib/aarch64-unknown-linux-gnu/lib/{libtest-*,libgetopts-*,libunicode_width-*,librustc_std_workspace_std-*}.rlib" "/rust-simplicity/target/debug/deps/{libbitcoin_hashes-1d310cbc78435774.rlib,libbitcoin_internals-7f113ae3b67ae29c.rlib,libbitcoin_consensus_encoding-b232453a743fc305.rlib,libbitcoin_internals-5c33f7c60c22912d.rlib}.rlib" "<sysroot>/lib/rustlib/aarch64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustc35KT3C/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/rust-simplicity/target/debug/build/simplicity-sys-86fc4f093920468d/out" "-L" "/rust-simplicity/target/debug/build/simplicity-sys-86fc4f093920468d/out" "-L" "/rust-simplicity/target/debug/build/simplicity-sys-86fc4f093920468d/out" "-L" "<sysroot>/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "/rust-simplicity/target/debug/deps/simplicity_sys-f0cfda2749c1621c" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
      = note: some arguments are omitted. use `--verbose` to show all linker arguments
      = note: /usr/bin/ld: /rust-simplicity/target/debug/build/simplicity-sys-86fc4f093920468d/out/libElementsSimplicity.a(6dfd0380989e1732-primitive.o):(.data.rel.ro.jet_node.0+0x0): undefined reference to `rustsimplicity_0_8_add_16'
              /usr/bin/ld: /rust-simplicity/target/debug/build/simplicity-sys-86fc4f093920468d/out/libElementsSimplicity.a(6dfd0380989e1732-primitive.o):(.data.rel.ro.jet_node.0+0x60): undefined reference to `rustsimplicity_0_8_add_32'
    
    
    ... <a lot of  undefined reference to> ...
    
    
    licity_0_8_xor_xor_64'
              /usr/bin/ld: /rust-simplicity/target/debug/build/simplicity-sys-86fc4f093920468d/out/libElementsSimplicity.a(6dfd0380989e1732-primitive.o):(.data.rel.ro.jet_node.0+0xb040): undefined reference to `rustsimplicity_0_8_xor_xor_8'
              /usr/bin/ld: /rust-simplicity/target/debug/build/simplicity-sys-86fc4f093920468d/out/libElementsSimplicity.a(6dfd0380989e1732-elementsJets.o): in function `rustsimplicity_0_8_build_taptweak':
              /rust-simplicity/simplicity-sys/depend/simplicity/elements/elementsJets.c:870: undefined reference to `rustsimplicity_0_8_generic_taptweak'
              collect2: error: ld returned 1 exit status
    
      = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
      = note: use the `-l` flag to specify native libraries to link
      = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
    
    error: could not compile `simplicity-sys` (lib test) due to 1 previous error
    
    What's next:
        Debug this container error with Gordon → docker ai "help me fix this container error"
    
  4. KyrylR commented on Nov 11, 2026

    @KyrylR
    CollaboratorAuthor

    I can't reproduce this on Debian 13 with Rust 1.99 . Could it be specific to the Nix setup?

    Tried the (rust 1.99)

    docker run --rm rust:1.99-bookworm bash -c '
      git clone -q https://github.com/BlockstreamResearch/rust-simplicity &&
      cd rust-simplicity && git checkout -q 7fb2601 &&
      cd simplicity-sys && cargo test --features test-utils'
    

    also fails

    After looking with AI (Opus 5.5) into it, it says the following


    delta1 tested on x86_64, where Rust 1.90+ links with the bundled rust-lld and hides the bug. The bug affects:

    • every Linux target that still links with GNU ld, such as arm64;
    • x86_64 with Rust older than 1.90 (1.88 fails);
    • x86_64 with Rust 1.90+ when rust-lld is turned off, which some distro and Nix toolchains do;
    • anyone whose cc points at GNU ld.

    Nix isn't the cause: it fails in plain Docker images too. andrew-ci ran under Docker on your Mac, so it was arm64 as well.

    On 7fb2601, cd simplicity-sys && cargo test --features test-utils:

    Target Rust Linker Result
    x86_64-linux 1.99.1 rust-lld (default) passes (14)
    x86_64-linux 1.99.1 GNU ld (RUSTFLAGS="-Clinker-features=-lld") link error
    x86_64-linux 1.88 GNU ld (default) link error
    aarch64-linux 1.99.1 GNU ld (default) link error

  5. KyrylR commented on Nov 11, 2026

    @KyrylR
    CollaboratorAuthor

    Now it looks same weird rabbit hole with linker, do not really see a need to spend time on it

  6. apoelstra commented on Nov 11, 2026

    @apoelstra
    Collaborator

    A long time ago in Liquid we replaced our linker with gold because of weird linker issues like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions