Skip to content

rustc-link-arg wrong order #12833

Closed as not planned
Closed as not planned
@ghost

Description

Problem

I'm trying to link to a static library with an absolute path using build scripts and rustc-link-arg, but I found that its additional arguments are appended to the end instead of in the middle This is different from rustc-link-lib.

CARGO=/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/bin/cargo CARGO_CRATE_NAME=webp_encoder CARGO_MANIFEST_DIR=/home/circleci/project CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='libwebp bindings' CARGO_PKG_HOMEPAGE='https://crates.io/crates/webp_encoder' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=webp_encoder CARGO_PKG_README=README CARGO_PKG_REPOSITORY='https://github.com/zzwxh/webp_encoder' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.6.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=6 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/home/circleci/project/target/debug/deps:/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib:/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib' OUT_DIR=/home/circleci/project/target/debug/build/webp_encoder-0c3cef5dbd1f28c0/out /home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/bin/rustc --crate-name webp_encoder --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --test -C metadata=c4c034865c8a8c44 -C extra-filename=-c4c034865c8a8c44 --out-dir /home/circleci/project/target/debug/deps -C incremental=/home/circleci/project/target/debug/incremental -L dependency=/home/circleci/project/target/debug/deps --extern anyhow=/home/circleci/project/target/debug/deps/libanyhow-a37ff87074167c9e.rlib -C link-arg=/home/circleci/project/lib/aarch64_linux/libwebp.a -C link-arg=/home/circleci/project/lib/aarch64_linux/libsharpyuv.a`
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/bin:/home/circleci/.cargo/bin:/home/circleci/bin:/home/circleci/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "/tmp/rustcn2eHDg/symbols.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.112o565stcsx42k3.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.1402l4488wnfwz7p.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.14a0vgkshv24t96a.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.1df8bj1iwhnbxiya.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.1gclg6ud69kz7r9l.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.1i9n3vfzrfafx7n7.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.1yyves5ncxaxpkyo.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.243dij62b8xkjpv6.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.2hjhdw30iaiygg26.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.2o4uz89asyvh1sbu.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.2q2ipx714ns09xri.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.2sfvofsvl3241egi.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.2xz866bts4ib9upk.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.35y0n1fz63q8tczx.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.39anztfvym4kgo8.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.3be1czdt70qr2bsy.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.3hlaw4a8jjs20bsq.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.3i6txbjf01e5l7lu.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.3iqtshl28lr0pohm.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.3lm7chbphff68930.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.3whybj2iuj7lg0rx.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.3xxx9iul6hggsq89.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.41dob2gpsfkfso90.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.48d1vk8lcw2ni6kw.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.4ay89d2m98eerpl2.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.4b9gaj2u8gfr8gue.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.4ciypgjjw3u9xai5.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.4n1c8i8xc94a3wbf.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.4rgbslz13lbhevqp.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.4szyq1b19rv9uu5y.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.50et8fa0pneyne3v.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.52l3awz6prln2x6z.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.5cd2297fll9y9h39.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.5f9vt4tgg2weyjnk.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.6e98exmdfdai8ru.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.6hrtabypo4xcq78.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.6tp528t6jvyek2w.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.7y3qw53hmvpdurc.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.evbnqyi6x2dryc0.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.icicj590tpqdkqs.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.ulvhf58hkcbjge.rcgu.o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44.1pwmjjgamne63hb8.rcgu.o" "-Wl,--as-needed" "-L" "/home/circleci/project/target/debug/deps" "-L" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libtest-4a0f7947e972e52d.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libgetopts-fe53f665c7592316.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libunicode_width-58c2b5e1ca5d5575.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_std-ec19369c5bbef562.rlib" "/home/circleci/project/target/debug/deps/libanyhow-a37ff87074167c9e.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd-1af56df70101340f.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libpanic_unwind-2d201e9ec773e2b2.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libobject-11edaa83ea3f42ca.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libmemchr-be5d62f450379333.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libaddr2line-48892539e9a2c4de.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libgimli-f8eb1df1397eacbf.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_demangle-2e09868052a8b2d5.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd_detect-a7e259ed513c618c.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libhashbrown-791329d15b754d4d.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-00676b12b0ca4248.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libminiz_oxide-77a22a58722b5fb2.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libadler-e9ab6f5f15790e88.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libunwind-fab82cfa2048cd45.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcfg_if-21f6d61e1c83d48b.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/liblibc-bac7f74953c2c715.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/liballoc-9b674ebb751cb2fa.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_core-088fae249a1081ae.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcore-29f211c7751ad68b.rlib" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcompiler_builtins-26783adfa77949da.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/circleci/.rustup/toolchains/1.73.0-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "/home/circleci/project/target/debug/deps/webp_encoder-c4c034865c8a8c44" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "/home/circleci/project/lib/aarch64_linux/libwebp.a" "/home/circleci/project/lib/aarch64_linux/libsharpyuv.a"
  = note: /usr/bin/ld: /home/circleci/project/lib/aarch64_linux/libwebp.a(picture_csp_enc.o): in function `ImportYUVAFromRGBA':
          picture_csp_enc.c:(.text+0x1cdc): undefined reference to `pow'
          /usr/bin/ld: picture_csp_enc.c:(.text+0x1d34): undefined reference to `pow'
          /usr/bin/ld: /home/circleci/project/lib/aarch64_linux/libwebp.a(webp_enc.o): in function `WebPEncode':
          webp_enc.c:(.text+0x84c): undefined reference to `log10'
          /usr/bin/ld: webp_enc.c:(.text+0x884): undefined reference to `log10'
          /usr/bin/ld: webp_enc.c:(.text+0x8b4): undefined reference to `log10'
          /usr/bin/ld: webp_enc.c:(.text+0x8e8): undefined reference to `log10'
          /usr/bin/ld: webp_enc.c:(.text+0x918): undefined reference to `log10'
          /usr/bin/ld: /home/circleci/project/lib/aarch64_linux/libwebp.a(frame_enc.o):frame_enc.c:(.text+0x1714): more undefined references to `log10' follow
          /usr/bin/ld: /home/circleci/project/lib/aarch64_linux/libwebp.a(quant_enc.o): in function `VP8SetSegmentParams':
          quant_enc.c:(.text+0x2798): undefined reference to `pow'
          /usr/bin/ld: quant_enc.c:(.text+0x27d8): undefined reference to `pow'
          /usr/bin/ld: quant_enc.c:(.text+0x2818): undefined reference to `pow'
          /usr/bin/ld: /home/circleci/project/lib/aarch64_linux/libwebp.a(lossless_enc.o): in function `FastSLog2Slow_C':
          lossless_enc.c:(.text+0x13c8): undefined reference to `log'
          /usr/bin/ld: /home/circleci/project/lib/aarch64_linux/libwebp.a(lossless_enc.o): in function `FastLog2Slow_C':
          lossless_enc.c:(.text+0x1470): undefined reference to `log'
          /usr/bin/ld: /home/circleci/project/lib/aarch64_linux/libsharpyuv.a(sharpyuv_gamma.o): in function `SharpYuvInitGammaTables':
          sharpyuv_gamma.c:(.text+0x88): undefined reference to `pow'
          /usr/bin/ld: sharpyuv_gamma.c:(.text+0x11c): undefined reference to `pow'
          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#cargorustc-link-libkindname)

error: could not compile `webp_encoder` (lib test) due to previous error

In this example, the pow and log10 function exist in libm, but due to the issue, the linker is unable to resolve it.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions