Skip to content

Linker regression issue in 1.62. #98903

Closed

Description

@sehz

FFI functions used to work fine in Rust 1.61 but fail in 1.62 with this message:

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcfESK1T/symbols.o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571.26ugs4oxijiltl66.rcgu.o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571.3dsuxc2cfpe6wga3.rcgu.o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571.3zcum3kt8ck4rp7g.rcgu.o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571.4uvr1uwzw7utasxk.rcgu.o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571.4vfgza6r72q7y15i.rcgu.o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571.566lb85j27ct6h9r.rcgu.o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571.2rym6uzmdyvbzubm.rcgu.o" "-Wl,--as-needed" "-L" "/home/ubuntu/node-bindgen/target/debug/deps" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-a2439391ec9a67be.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-cec065bf96e73267.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-3dfb9459b538c315.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-de0892f44c2cd6ea.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libnj_build-b55c2c026efb1196.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libnj_core-45b1a85da897ce31.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libuuid-f3fc2ba035472968.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libserde_json-ac8de9945b887ed0.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libryu-3af2e174192d1dbf.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libitoa-d5a45f36d2efbaa4.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libserde-b4a39d24cbeedac1.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libnum_bigint-763d307be2f3da0f.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libnum_integer-12640a110dea6785.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libnum_traits-8f860025f7a6217b.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libinventory-a30297631495ed0b.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libfluvio_future-a14935df47c72ea0.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libtracing_subscriber-a6a0cb5e9d3e016d.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libsmallvec-1577765a48a0307f.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libsharded_slab-c9b8d803ef572a5c.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libmatchers-34aa5755967a922c.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libregex_automata-084dcb17a5dfb518.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libregex-2b53c598713e2b98.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libaho_corasick-ab3d183a1838f536.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libregex_syntax-d2d405453ad07158.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libansi_term-37947e3c9d10903e.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libtracing-aac081cc1c5508f3.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libthread_local-de1a19642393a9f1.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libtracing_log-c86a3244346db03e.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/liblazy_static-e24fcf15b5cab9c8.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libtracing_core-63d2083a6c799614.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libpin_project-771f2334964924d6.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_std-f002e53c88a48261.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_global_executor-71778a5a2c25c44b.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libblocking-639a6540382cbc99.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libatomic_waker-607a9c32869541be.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libnum_cpus-65e66bd3162513d8.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_executor-335419ed63f70faf.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_task-3d454fe263572edf.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libcrossbeam_utils-0f5573d9af98029f.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_process-17476f407107c14e.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libsignal_hook-26c7cd5e5742e6d0.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libsignal_hook_registry-eb911e0e7e5273e1.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_io-4d3c3717dba3dbaf.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libslab-05b833cc21705e34.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libpolling-4f22084341882ceb.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libonce_cell-2bed9e6debd58b36.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libsocket2-e52c7f3d01474a05.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_channel-7707326f684727c7.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libconcurrent_queue-2d7c8908b7e46540.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libcache_padded-9e163dac76edc468.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libasync_lock-c086c8890d2e05d6.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libevent_listener-34deb62a0246d98f.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libpin_utils-b31350adeaace291.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libkv_log_macro-8c6c5d9fc3f69e86.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libfutures_lite-be64eb27373d154d.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libmemchr-eebfddeb4aba3e53.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libfastrand-4b228846577037a9.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libfutures_io-0cca087bb74ff8e9.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libfutures_core-e0348fd6b50c6745.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libwaker_fn-a3fcde984759200f.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libparking-945cbf8138c8e23e.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libpin_project_lite-bc0a06a266f87279.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libnj_sys-d8fced70697e337e.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/liblog-7340455d4d5b0a9a.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libvalue_bag-7d8b832302ce45ab.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/libcfg_if-904ac7e0155b8ce8.rlib" "/home/ubuntu/node-bindgen/target/debug/deps/liblibc-7b0a895c111d8297.rlib" "-Wl,--start-group" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7ca39ac42651c3df.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-62c6d032818141a1.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-50484fc03eb1eb5b.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-758be083b246d9c6.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-3cdf9a3c68f76e2d.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-3a1b74821c25a0e1.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-e046d82ebd84bb7f.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-a61cdd33cfa8394f.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-410c38f8df854235.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-f79d7458e122215f.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-7d24b750ce5b22e8.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-4c2aa1ea3133ab73.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-41220dc85a7f114f.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-230d004276c898f9.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-03ae30169a5438be.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-6f82c44b7818af35.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-1a0b7681f7efa789.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-83735dd4dae9b02c.rlib" "-Wl,--end-group" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-385029872275478f.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/ubuntu/node-bindgen/target/debug/deps/node_bindgen-a1c4ce9a7d148571" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /home/ubuntu/node-bindgen/target/debug/deps/libnj_core-45b1a85da897ce31.rlib(nj_core-45b1a85da897ce31.2mytbr9jjy9arefp.rcgu.o): In function `nj_core::module::init_module':
          /home/ubuntu/node-bindgen/nj-core/src/module.rs:96: undefined reference to `napi_module_register'
          /home/ubuntu/node-bindgen/target/debug/deps/libnj_core-45b1a85da897ce31.rlib(nj_core-45b1a85da897ce31.12sfhlxckxz5e29v.rcgu.o): In function `nj_core::basic::JsExports::define_property':
          /home/ubuntu/node-bindgen/nj-core/src/basic.rs:889: undefined reference to `napi_define_properties'
          collect2: error: ld returned 1 exit status
          
  = help: 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#cargorustc-link-libkindname)

It works fine in Mac OSX but fails in Linux. See original issue filed in the repo:

infinyon/node-bindgen#195

Activity

  1. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 6, 2022
  2. 12101111 commented on Jul 6, 2022

    @12101111
    Contributor

    It don't compile because of 18b53ce

    But it's not a bug of rustc.

    Fix:

    1. use Cargo feature resolver 2
    2. And disable other features for build script:
    [build-dependencies]
    node-bindgen = { path = "../..", default-features = false, features=["build"] }
  3. sehz commented on Jul 7, 2022

    @sehz
    Author
    [build-dependencies]
    node-bindgen = { path = "../..", default-features = false, features=["build"] }
    

    That didn't help.

  4. apiraino commented on Jul 7, 2022

    @apiraino
    Contributor

    @sehz I've tried the following:

    $ git clone --single-branch --depth=1 https://github.com/infinyon/node-bindgen.git
    $ cd node-bindgen && cargo build
    

    and it seems to compile fine. I'm running Rust 1.62 on Linux x86-64.

    Could you provide some more info on how to reproduce? thanks

    @rustbot label e-needs-mcve T-compiler

  5. added
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 7, 2022
  6. 12101111 commented on Jul 7, 2022

    @12101111
    Contributor

    mcve: https://github.com/12101111/rust-mcve-98903

    To reproduce on node-bindgen, run cd node-bindgen/examples/array && cargo build

    How to fix it:

    diff --git a/examples/Cargo.toml b/examples/Cargo.toml
    index 4528a5c..82c6b30 100644
    --- a/examples/Cargo.toml
    +++ b/examples/Cargo.toml
    @@ -1,4 +1,5 @@
     [workspace]
    +resolver = "2"
     members = [
         "function",
         "cb",
    diff --git a/examples/array/Cargo.toml b/examples/array/Cargo.toml
    index b77b02b..8bac645 100644
    --- a/examples/array/Cargo.toml
    +++ b/examples/array/Cargo.toml
    @@ -14,4 +14,4 @@ node-bindgen = { path = "../.."}
    
    
     [build-dependencies]
    -node-bindgen = { path = "../../", features = ["build"] }
    +node-bindgen = { path = "../../", default-features = false, features = ["build"] }
  7. sehz commented on Jul 8, 2022

    @sehz
    Author

    That worked! Thanks for all the help. Mark as resolved

  8. added a commit that references this issue on Jul 8, 2022
  9. removed
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 10, 2022
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

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions