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

Produced binaries don't (all) run if linked by lld or mold #10523

Closed
nagisa opened this issue Jan 29, 2024 · 1 comment
Closed

Produced binaries don't (all) run if linked by lld or mold #10523

nagisa opened this issue Jan 29, 2024 · 1 comment
Labels
A-build Area: Anything related to the build and configuration process for nearcore.

Comments

@nagisa
Copy link
Collaborator

nagisa commented Jan 29, 2024

Using mold or lld as a linker is desirable over the default ld.bfd or whatever gcc uses nowadays as at the very least these tools link binaries up faster. However after setting either of the following environment variables:

RUSTFLAGS="-Clink-arg=-fuse-ld=lld"
RUSTFLAGS="-Clink-arg=-fuse-ld=mold"

and then running just nextest stable will not work with an error along the lines of:

...
   Compiling near-fork-network v0.0.0 (.../nearcore/tools/fork-network)
    Finished dev-release [optimized] target(s) in 2m 50s
warning: the following packages contain code that will be rejected by a future version of Rust: fs_extra v1.2.0, wasmer-singlepass-backend-near v0.18.1, wasmparser v0.78.2
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
error: creating test list failed

Caused by:
  for `genesis-csv-to-json::bin/genesis-csv-to-json`, command `.../nearcore/target/dev-release/deps/genesis_csv_to_json-0f02e52b48fd6303 --list --format terse` exited with code 127
--- stdout:

--- stderr:
.../nearcore/target/dev-release/deps/genesis_csv_to_json-0f02e52b48fd6303: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

Usually I would suspect a system configuration problem, but:

  1. Things work fine with the default linker gcc uses;
  2. I know that gcc's linker is pretty lax about its interface and e.g. getting order of -largs wrong will fly past it but not past other linkers.
@nagisa nagisa added the A-build Area: Anything related to the build and configuration process for nearcore. label Jan 29, 2024
@nagisa
Copy link
Collaborator Author

nagisa commented Jan 29, 2024

This may be a NixOS specific problem -- it enables rpath by default for the usual linker but if you ask for a plain mold or lld packages, you'll get the unwrapped stuff, it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build Area: Anything related to the build and configuration process for nearcore.
Projects
None yet
Development

No branches or pull requests

1 participant