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

error: unsupported linker arg: --undefined #162

Open
NobodyXu opened this issue Aug 21, 2023 · 7 comments
Open

error: unsupported linker arg: --undefined #162

NobodyXu opened this issue Aug 21, 2023 · 7 comments

Comments

@NobodyXu
Copy link

In CI of cargo-bins/cargo-quickinstall#225 :

error: linking with `/home/runner/.cache/cargo-zigbuild/0.17.1/zigcc-aarch64-unknown-linux-gnu.sh` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib/llvm-17/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" VSLANG="1033" "/home/runner/.cache/cargo-zigbuild/0.17.1/zigcc-aarch64-unknown-linux-gnu.sh" "/tmp/rustcyQOQeV/symbols.o" "/tmp/cargo-installYEv6Xb/aarch64-unknown-linux-gnu/release/deps/cargo_quickinstall-f5fa84c441e696c6.cargo_quickinstall.b0e05ecc437846b8-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/tmp/cargo-installYEv6Xb/aarch64-unknown-linux-gnu/release/deps" "-L" "/tmp/cargo-installYEv6Xb/release/deps" "-L" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcompiler_builtins-c1be0fe9bd14e073.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "/tmp/cargo-installYEv6Xb/aarch64-unknown-linux-gnu/release/deps/cargo_quickinstall-f5fa84c441e696c6" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "/tmp/cargo-installYEv6Xb/aarch64-unknown-linux-gnu/release/deps/cargo_quickinstall_audit_data.o" "-Wl,--undefined=AUDITABLE_VERSION_INFO"
  = note: error: unsupported linker arg: --undefined

It runs the command:

export CARGO_ROOT=/tmp/tmp.NcnCOgGQVC
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO=fat
export OPENSSL_STATIC=1
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse

cargo-auditable auditable install cargo-quickinstall --version 0.2.9 --target aarch64-unknown-linux-gnu --root /tmp/tmp.NcnCOgGQVC
@messense
Copy link
Member

See ziglang/zig#11906, consider open a PR to filter it out like #97.

@messense
Copy link
Member

So the flag is added by cargo-auditable, simply remove it might have other unintended effects?

https://github.com/rust-secure-code/cargo-auditable/blob/da85607fb1a09435d77288ccf05a92b2e8ec3f71/cargo-auditable/src/rustc_wrapper.rs#L56

@NobodyXu
Copy link
Author

Hmmm, it seems like so.

Not sure how this to approach this problem, cc @Shnatsel

@Shnatsel
Copy link

The flag is needed to make sure the audit info is not removed by the linker. Without --undefined the linker would notice that the symbol is never used and remove it.

It does seem like an instance of ziglang/zig#11906. The flag should be simply forwarded to the linker as-is.

@NobodyXu
Copy link
Author

NobodyXu commented Jan 12, 2024

Is there any workaround? cc @Shnatsel @messense

We want to update ziglang v0.11 cargo-bins/cargo-binstall#1564 but failed.

@Shnatsel
Copy link

I believe this is an issue with Zig, and it needs to be modified to recognize this flag and pass it along to the linker. Other similar PRs dealing with linker flags:

ziglang/zig#11679
ziglang/zig#11875
ziglang/zig#11874

I am not aware of any workarounds.

@NobodyXu
Copy link
Author

I will probably have to stay on ziglang v0.10 and instead zlib-ng on aarch64 to fix the error mentioned in #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants