Skip to content

rules_rust does not set CARGO_PKG_VERSION to the package version for build script rustc #3250

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

Closed
mikn opened this issue Feb 9, 2025 · 5 comments · Fixed by #3260
Closed

Comments

@mikn
Copy link

mikn commented Feb 9, 2025

This was relatively tricky to figure out. We have a dependency on aws-lc-rs which in turn depends on a FFI wrapper called aws-lc-sys - it works fine building with Cargo, but if built with Bazel we get linker errors similar to this:

mikn@hal8999 ~/d/m/s/t/w/rust ((8018770e))> bazel build -s //tools/wrap/rust:wrap --verbose_failures
INFO: Analyzed target //tools/wrap/rust:wrap (0 packages loaded, 0 targets configured).
SUBCOMMAND: # @@rules_rust++crate+crate_index__aws-lc-sys-0.25.1//:_bs [action 'Running Cargo build script aws-lc-sys', configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b, execution platform: @@platforms//host:host, mnemonic: CargoBuildScriptRun]
(cd /home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main && \
  exec env - \
    AR=/usr/bin/ar \
    AWS_LC_SYS_NO_VENDOR=0 \
    AWS_LC_SYS_STATIC=1 \
    AWS_LC_SYS_VENDORED=1 \
    CARGO='${pwd}/bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/cargo' \
    CARGO_CRATE_NAME=aws_lc_sys \
    CARGO_ENCODED_RUSTFLAGS='--sysroot=${pwd}/bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain\x1f--cap-lints=allow' \
    CARGO_FEATURE_STATIC=1 \
    CARGO_MANIFEST_DIR=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.cargo_runfiles/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/ \
    CARGO_MANIFEST_LINKS=aws_lc_0_25_1 \
    CARGO_PKG_NAME=aws-lc-sys \
    CARGO_PKG_VERSION=0.25.1 \
    CARGO_PKG_VERSION_MAJOR=0 \
    CARGO_PKG_VERSION_MINOR=25 \
    CARGO_PKG_VERSION_PATCH=1 \
    CARGO_PKG_VERSION_PRE='' \
    CC=/usr/bin/gcc \
    CFLAGS='-U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted"' \
    CXX=/usr/bin/gcc \
    CXXFLAGS='-U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c++17 -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted"' \
    DEBUG=true \
    HOST=x86_64-unknown-linux-gnu \
    LD=/usr/bin/gcc \
    LDFLAGS='-fuse-ld=gold -B/usr/bin -Wl,-no-as-needed -Wl,-z,relro,-z,now -pass-exit-codes -Wl,--push-state,-as-needed -lstdc++ -Wl,--pop-state -Wl,--push-state,-as-needed -lm -Wl,--pop-state' \
    NUM_JOBS=1 \
    OPT_LEVEL=0 \
    PATH=/home/mikn/.cache/bazelisk/downloads/sha256/48ea0ff9d397a48add6369c261c5a4431fe6d5d5348cfb81411782fb80c388d3/bin:/home/mikn/devel/molnett/src/tools/path:/home/mikn/.cargo/bin:/home/mikn/go/bin:/home/mikn/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin \
    PROFILE=debug \
    RUSTC=bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/rustc \
    TARGET=x86_64-unknown-linux-gnu \
    ZERO_AR_DATE=1 \
  bazel-out/k8-opt-exec/bin/external/rules_rust+/cargo/cargo_build_script_runner/runner '--script=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs-' '--links=aws_lc_0_25_1' '--out_dir=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.out_dir' '--env_out=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.env' '--flags_out=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.flags' '--link_flags=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.linkflags' '--link_search_paths=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.linksearchpaths' '--dep_env_out=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.depenv' '--rundir=' '--cargo_manifest_args=@bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.out_dir-0.params')
# Configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b
# Execution platform: @@platforms//host:host
INFO: From Running Cargo build script aws-lc-sys:
Build Script Warning: Building with: CC
Build Script Warning: Symbol Prefix: Some("aws_lc_0_0_0")
Build Script Warning: Compilation of 'c11.c' succeeded - Ok(["/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/sandbox/linux-sandbox/142/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.out_dir/out-c11/23ee85b27211b1c8-c11.o"]).
Build Script Warning: CC environment variable set: /usr/bin/gcc
Build Script Warning: CXX environment variable set: /usr/bin/gcc
Build Script Warning: Compilation of 'stdalign_check.c' succeeded - Ok(["/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/sandbox/linux-sandbox/142/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.out_dir/out-stdalign_check/23ee85b27211b1c8-stdalign_check.o"]).
Build Script Warning: Compilation of 'builtin_swap_check.c' succeeded - Ok(["/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/sandbox/linux-sandbox/142/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.out_dir/out-builtin_swap_check/23ee85b27211b1c8-builtin_swap_check.o"]).
SUBCOMMAND: # @@rules_rust++crate+crate_index__aws-lc-sys-0.25.1//:aws_lc_sys [action 'Compiling Rust rlib aws_lc_sys v0.25.1 (25 files)', configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b, execution platform: @@platforms//host:host, mnemonic: Rustc]
(cd /home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main && \
  exec env - \
    CARGO_CFG_TARGET_ARCH=x86_64 \
    CARGO_CFG_TARGET_OS=linux \
    CARGO_CRATE_NAME=aws_lc_sys \
    CARGO_MANIFEST_DIR='${pwd}/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1' \
    CARGO_PKG_AUTHORS='' \
    CARGO_PKG_DESCRIPTION='' \
    CARGO_PKG_HOMEPAGE='' \
    CARGO_PKG_NAME=aws_lc_sys \
    CARGO_PKG_VERSION=0.25.1 \
    CARGO_PKG_VERSION_MAJOR=0 \
    CARGO_PKG_VERSION_MINOR=25 \
    CARGO_PKG_VERSION_PATCH=1 \
    CARGO_PKG_VERSION_PRE='' \
    OUT_DIR='${pwd}/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.out_dir' \
    REPOSITORY_NAME=rules_rust++crate+crate_index__aws-lc-sys-0.25.1 \
  bazel-out/k8-opt-exec/bin/external/rules_rust+/util/process_wrapper/process_wrapper --env-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.env --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.linksearchpaths --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.flags --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.linkflags --subst 'pwd=${pwd}' -- bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/rustc external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/src/lib.rs '--crate-name=aws_lc_sys' '--crate-type=rlib' '--error-format=human' '--codegen=metadata=-197097846' '--codegen=extra-filename=-197097846' '--out-dir=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--codegen=strip=none' '--remap-path-prefix=${pwd}=' '--emit=dep-info,link' '--color=always' '--target=x86_64-unknown-linux-gnu' -L bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib '--edition=2021' '-Cembed-bitcode=no' '--extern=paste=bazel-out/k8-opt-exec/bin/external/rules_rust++crate+crate_index__paste-1.0.15/libpaste-3412690010.so' '-Ldependency=bazel-out/k8-opt-exec/bin/external/rules_rust++crate+crate_index__paste-1.0.15' '--sysroot=bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain' '--cap-lints=allow')
# Configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b
# Execution platform: @@platforms//host:host
SUBCOMMAND: # @@rules_rust++crate+crate_index__aws-lc-rs-1.12.2//:_bs [action 'Running Cargo build script aws-lc-rs', configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b, execution platform: @@platforms//host:host, mnemonic: CargoBuildScriptRun]
(cd /home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main && \
  exec env - \
    AR=/usr/bin/ar \
    CARGO='${pwd}/bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/cargo' \
    CARGO_CRATE_NAME=aws_lc_rs \
    CARGO_ENCODED_RUSTFLAGS='--sysroot=${pwd}/bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain\x1f--cap-lints=allow' \
    CARGO_FEATURE_ALLOC=1 \
    CARGO_FEATURE_AWS_LC_SYS=1 \
    CARGO_FEATURE_DEFAULT=1 \
    CARGO_FEATURE_RING_IO=1 \
    CARGO_FEATURE_RING_SIG_VERIFY=1 \
    CARGO_MANIFEST_DIR=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.cargo_runfiles/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/ \
    CARGO_MANIFEST_LINKS=aws_lc_rs_1_12_1_sys \
    CARGO_PKG_NAME=aws-lc-rs \
    CARGO_PKG_VERSION=1.12.2 \
    CARGO_PKG_VERSION_MAJOR=1 \
    CARGO_PKG_VERSION_MINOR=12 \
    CARGO_PKG_VERSION_PATCH=2 \
    CARGO_PKG_VERSION_PRE='' \
    CC=/usr/bin/gcc \
    CFLAGS='-U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted"' \
    CXX=/usr/bin/gcc \
    CXXFLAGS='-U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c++17 -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted"' \
    DEBUG=true \
    HOST=x86_64-unknown-linux-gnu \
    LD=/usr/bin/gcc \
    LDFLAGS='-fuse-ld=gold -B/usr/bin -Wl,-no-as-needed -Wl,-z,relro,-z,now -pass-exit-codes -Wl,--push-state,-as-needed -lstdc++ -Wl,--pop-state -Wl,--push-state,-as-needed -lm -Wl,--pop-state' \
    NUM_JOBS=1 \
    OPT_LEVEL=0 \
    PATH=/home/mikn/.cache/bazelisk/downloads/sha256/48ea0ff9d397a48add6369c261c5a4431fe6d5d5348cfb81411782fb80c388d3/bin:/home/mikn/devel/molnett/src/tools/path:/home/mikn/.cargo/bin:/home/mikn/go/bin:/home/mikn/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin \
    PROFILE=debug \
    RUSTC=bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/rustc \
    TARGET=x86_64-unknown-linux-gnu \
    ZERO_AR_DATE=1 \
  bazel-out/k8-opt-exec/bin/external/rules_rust+/cargo/cargo_build_script_runner/runner '--script=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs-' '--links=aws_lc_rs_1_12_1_sys' '--out_dir=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.out_dir' '--env_out=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.env' '--flags_out=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.flags' '--link_flags=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.linkflags' '--link_search_paths=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.linksearchpaths' '--dep_env_out=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.depenv' '--rundir=' '--input_dep_env_path=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.depenv' '--cargo_manifest_args=@bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.out_dir-0.params')
# Configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b
# Execution platform: @@platforms//host:host
SUBCOMMAND: # @@rules_rust++crate+crate_index__aws-lc-rs-1.12.2//:aws_lc_rs [action 'Compiling Rust rlib aws_lc_rs v1.12.2 (90 files)', configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b, execution platform: @@platforms//host:host, mnemonic: Rustc]
(cd /home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main && \
  exec env - \
    CARGO_CFG_TARGET_ARCH=x86_64 \
    CARGO_CFG_TARGET_OS=linux \
    CARGO_CRATE_NAME=aws_lc_rs \
    CARGO_MANIFEST_DIR='${pwd}/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2' \
    CARGO_PKG_AUTHORS='' \
    CARGO_PKG_DESCRIPTION='' \
    CARGO_PKG_HOMEPAGE='' \
    CARGO_PKG_NAME=aws_lc_rs \
    CARGO_PKG_VERSION=1.12.2 \
    CARGO_PKG_VERSION_MAJOR=1 \
    CARGO_PKG_VERSION_MINOR=12 \
    CARGO_PKG_VERSION_PATCH=2 \
    CARGO_PKG_VERSION_PRE='' \
    OUT_DIR='${pwd}/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.out_dir' \
    REPOSITORY_NAME=rules_rust++crate+crate_index__aws-lc-rs-1.12.2 \
  bazel-out/k8-opt-exec/bin/external/rules_rust+/util/process_wrapper/process_wrapper --env-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.env --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.linksearchpaths --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.linksearchpaths --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.flags --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.linkflags --subst 'pwd=${pwd}' -- bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/rustc external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/src/lib.rs '--crate-name=aws_lc_rs' '--crate-type=rlib' '--error-format=human' '--codegen=metadata=-1920110354' '--codegen=extra-filename=-1920110354' '--out-dir=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--codegen=strip=none' '--remap-path-prefix=${pwd}=' '--emit=dep-info,link' '--color=always' '--target=x86_64-unknown-linux-gnu' --cfg 'feature="alloc"' --cfg 'feature="aws-lc-sys"' --cfg 'feature="default"' --cfg 'feature="ring-io"' --cfg 'feature="ring-sig-verify"' -L bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib '--edition=2021' '-Cembed-bitcode=no' '--extern=aws_lc_sys=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/libaws_lc_sys-197097846.rlib' '--extern=untrusted=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__untrusted-0.7.1/libuntrusted-1977104640.rlib' '--extern=zeroize=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__zeroize-1.8.1/libzeroize-856108999.rlib' '--extern=paste=bazel-out/k8-opt-exec/bin/external/rules_rust++crate+crate_index__paste-1.0.15/libpaste-3412690010.so' '-Ldependency=bazel-out/k8-opt-exec/bin/external/rules_rust++crate+crate_index__paste-1.0.15' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__untrusted-0.7.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__zeroize-1.8.1' '--sysroot=bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain' '--cap-lints=allow')
# Configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b
# Execution platform: @@platforms//host:host
SUBCOMMAND: # //tools/wrap/rust:wrap [action 'Compiling Rust bin wrap (1 files)', configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b, execution platform: @@platforms//host:host, mnemonic: Rustc]
(cd /home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main && \
  exec env - \
    CARGO_CFG_TARGET_ARCH=x86_64 \
    CARGO_CFG_TARGET_OS=linux \
    CARGO_CRATE_NAME=wrap \
    CARGO_MANIFEST_DIR='${pwd}/tools/wrap/rust' \
    CARGO_PKG_AUTHORS='' \
    CARGO_PKG_DESCRIPTION='' \
    CARGO_PKG_HOMEPAGE='' \
    CARGO_PKG_NAME=wrap \
    CARGO_PKG_VERSION=0.1.0 \
    CARGO_PKG_VERSION_MAJOR=0 \
    CARGO_PKG_VERSION_MINOR=0 \
    CARGO_PKG_VERSION_PATCH=0 \
    CARGO_PKG_VERSION_PRE='' \
    REPOSITORY_NAME='' \
    ZERO_AR_DATE=1 \
  bazel-out/k8-opt-exec/bin/external/rules_rust+/util/process_wrapper/process_wrapper --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.linksearchpaths --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.linksearchpaths --subst 'pwd=${pwd}' -- bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/rustc tools/wrap/rust/src/main.rs '--crate-name=wrap' '--crate-type=bin' '--error-format=human' '--out-dir=bazel-out/k8-fastbuild/bin/tools/wrap/rust' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--codegen=strip=none' '--remap-path-prefix=${pwd}=' '--emit=link=bazel-out/k8-fastbuild/bin/tools/wrap/rust/wrap' '--emit=dep-info' '--color=always' '--target=x86_64-unknown-linux-gnu' -L bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib '--edition=2021' '-Cembed-bitcode=no' '--codegen=linker=/usr/bin/gcc' '--codegen=link-arg=-fuse-ld=gold' '--codegen=link-arg=-B/usr/bin' '--codegen=link-arg=-Wl,-no-as-needed' '--codegen=link-arg=-Wl,-z,relro,-z,now' '--codegen=link-arg=-pass-exit-codes' '--codegen=link-arg=-Wl,--push-state,-as-needed' '--codegen=link-arg=-lstdc++' '--codegen=link-arg=-Wl,--pop-state' '--codegen=link-arg=-Wl,--push-state,-as-needed' '--codegen=link-arg=-lm' '--codegen=link-arg=-Wl,--pop-state' '--extern=aws_lc_rs=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/libaws_lc_rs-1920110354.rlib' '-Ldependency=bazel-out/k8-opt-exec/bin/external/rules_rust++crate+crate_index__paste-1.0.15' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__untrusted-0.7.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__zeroize-1.8.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2' '--sysroot=bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain' '--cfg=aws_lc_sys_static' '--cfg=aws_lc_sys_vendored')
# Configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b
# Execution platform: @@platforms//host:host
ERROR: /home/mikn/devel/molnett/src/tools/wrap/rust/BUILD.bazel:3:12: Compiling Rust bin wrap (1 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from target //tools/wrap/rust:wrap) 
  (cd /home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/sandbox/linux-sandbox/146/execroot/_main && \
  exec env - \
    CARGO_CFG_TARGET_ARCH=x86_64 \
    CARGO_CFG_TARGET_OS=linux \
    CARGO_CRATE_NAME=wrap \
    CARGO_MANIFEST_DIR='${pwd}/tools/wrap/rust' \
    CARGO_PKG_AUTHORS='' \
    CARGO_PKG_DESCRIPTION='' \
    CARGO_PKG_HOMEPAGE='' \
    CARGO_PKG_NAME=wrap \
    CARGO_PKG_VERSION=0.1.0 \
    CARGO_PKG_VERSION_MAJOR=0 \
    CARGO_PKG_VERSION_MINOR=0 \
    CARGO_PKG_VERSION_PATCH=0 \
    CARGO_PKG_VERSION_PRE='' \
    REPOSITORY_NAME='' \
    ZERO_AR_DATE=1 \
  bazel-out/k8-opt-exec/bin/external/rules_rust+/util/process_wrapper/process_wrapper --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/_bs.linksearchpaths --arg-file bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.linksearchpaths --subst 'pwd=${pwd}' -- bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/rustc tools/wrap/rust/src/main.rs '--crate-name=wrap' '--crate-type=bin' '--error-format=human' '--out-dir=bazel-out/k8-fastbuild/bin/tools/wrap/rust' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--codegen=strip=none' '--remap-path-prefix=${pwd}=' '--emit=link=bazel-out/k8-fastbuild/bin/tools/wrap/rust/wrap' '--emit=dep-info' '--color=always' '--target=x86_64-unknown-linux-gnu' -L bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib '--edition=2021' '-Cembed-bitcode=no' '--codegen=linker=/usr/bin/gcc' '--codegen=link-arg=-fuse-ld=gold' '--codegen=link-arg=-B/usr/bin' '--codegen=link-arg=-Wl,-no-as-needed' '--codegen=link-arg=-Wl,-z,relro,-z,now' '--codegen=link-arg=-pass-exit-codes' '--codegen=link-arg=-Wl,--push-state,-as-needed' '--codegen=link-arg=-lstdc++' '--codegen=link-arg=-Wl,--pop-state' '--codegen=link-arg=-Wl,--push-state,-as-needed' '--codegen=link-arg=-lm' '--codegen=link-arg=-Wl,--pop-state' '--extern=aws_lc_rs=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/libaws_lc_rs-1920110354.rlib' '-Ldependency=bazel-out/k8-opt-exec/bin/external/rules_rust++crate+crate_index__paste-1.0.15' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__untrusted-0.7.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__zeroize-1.8.1' '-Ldependency=bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2' '--sysroot=bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain' '--cfg=aws_lc_sys_static' '--cfg=aws_lc_sys_vendored')
# Configuration: 56833fe102986854185f016d53ea38b55ccf4cf54fac962fdcef4d6b6659e13b
# Execution platform: @@platforms//host:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: linking with `/usr/bin/gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/bin" VSLANG="1033" "/usr/bin/gcc" "-m64" "/tmp/rustccoh3MJ/symbols.o" "bazel-out/k8-fastbuild/bin/tools/wrap/rust/wrap.wrap.5f5207416ff5665b-cgu.0.rcgu.o" "bazel-out/k8-fastbuild/bin/tools/wrap/rust/wrap.ar6pgwup643npgb9od09lq7bd.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/libaws_lc_rs-1920110354.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__untrusted-0.7.1/libuntrusted-1977104640.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__zeroize-1.8.1/libzeroize-856108999.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/libaws_lc_sys-197097846.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f060101dda10b7a.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-70f71d9a6d284c89.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-3dc783e4d6e04b19.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-4fffc92fe380873a.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-c572ac12fe8cba29.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-fc5479163f049547.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-abc6fce37da6e535.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-454117f0927a89af.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-302800adacdaa375.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-0b365bbc25bb52b1.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-ee3a5cb2982a2a9f.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-521236c0a42ef1a3.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-541d85b154f80ded.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-380aa0852ecf2621.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-099427f186ab3f66.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-1c29bac7d035f466.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-d193bce3b6600c65.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-75c6c8b4d83dd0d3.rlib" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ad7808ee138565ae.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/sandbox/linux-sandbox/146/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-sys-0.25.1/_bs.out_dir" "-L" "bazel-out/k8-fastbuild/bin/external/rules_rust++rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "bazel-out/k8-fastbuild/bin/tools/wrap/rust/wrap" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-fuse-ld=gold" "-B/usr/bin" "-Wl,-no-as-needed" "-Wl,-z,relro,-z,now" "-pass-exit-codes" "-Wl,--push-state,-as-needed" "-lstdc++" "-Wl,--pop-state" "-Wl,--push-state,-as-needed" "-lm" "-Wl,--pop-state"
  = note: /home/mikn/.cache/bazel/_bazel_mikn/2c3f33a86f4a406b8ffa9b29662db437/execroot/_main/bazel-out/k8-fastbuild/bin/external/rules_rust++crate+crate_index__aws-lc-rs-1.12.2/libaws_lc_rs-1920110354.rlib(aws_lc_rs-1920110354.aws_lc_rs.a12b076d0078a9e0-cgu.6.rcgu.o):aws_lc_rs.a12b076d0078a9e0-cgu.6:function aws_lc_rs::init::{{closure}}:(.text._ZN9aws_lc_rs4init28_$u7b$$u7b$closure$u7d$$u7d$17hc62389663bef17d6E+0x3): error: undefined reference to 'aws_lc_0_25_1_CRYPTO_library_init'
          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: aborting due to 1 previous error

Target //tools/wrap/rust:wrap failed to build
INFO: Elapsed time: 52.566s, Critical Path: 52.41s
INFO: 10 processes: 6 internal, 4 linux-sandbox.
ERROR: Build did NOT complete successfully
mikn@hal8999 ~/d/m/s/t/w/rust ((8018770e)) [1]>

The problem stems from this line; https://github.com/aws/aws-lc-rs/blob/aws-lc-sys/v0.25.1/aws-lc-sys/builder/main.rs#L211C1-L211C49
where they embed the version during compilation of the build script.
This depends on the version of the package being set during build rule compilation as well as build rule execution.

Strangely, it seems that CARGO_PKG_VERSION is set to 0.0.0 during rustc execution, otherwise this line:

Build Script Warning: Symbol Prefix: Some("aws_lc_0_0_0")

should've been: aws_lc_

I could fix it by doing this:

crate.annotation(
    crate = "aws-lc-sys",
    build_script_rustc_env = {
        "CARGO_PKG_VERSION": "0.25.1",
    },
)

But I assume this should be aligned with Cargo's behaviour, hence making the report.

@UebelAndre
Copy link
Collaborator

Setting the environment variable is pretty trivial but it will be on users to ensure the version they pass actually matches the consuming crate. I’d be happy to review a PR that sets this 😄

@mikn
Copy link
Author

mikn commented Feb 24, 2025

Funny, I found this one too, which struggles with the same issue: #3139

@bazaah
Copy link

bazaah commented Mar 2, 2025

This is trivially fixed via annotation:

ANNOTATIONS = {
  "aws-lc-sys" : [
      crate.annotation(
          patches = [
              Label("patch/aws-lc-sys/fix-symbol-versioning.patch")
          ],
          patch_args = ["-p1"],
      ),
  ],
  # <snipped>
}

crates_repository(
    name            = "crates_io",
    packages        = CRATES,
    annotations     = ANNOTATIONS,
    # other fields...
)
  • patch/aws-lc-sys/fix-symbol-versioning.patch
diff --git a/builder/main.rs b/builder/main.rs
index 3619a421d1..4bebe1ac57 100644
--- a/builder/main.rs
+++ b/builder/main.rs
@@ -210,7 +210,9 @@ impl OutputLib {
 const VERSION: &str = env!("CARGO_PKG_VERSION");
 
 fn prefix_string() -> String {
-    format!("aws_lc_{}", VERSION.to_string().replace('.', "_"))
+    let version = std::env::var("CARGO_PKG_VERSION")
+        .expect("CARGO_PKG_VERSION to be set when running the build script");
+    format!("aws_lc_{}", version.replace('.', "_"))
 }
 
 #[cfg(feature = "bindgen")]

(which is why I never bothered to report it upstream)

@roman-kashitsyn
Copy link
Contributor

I can still reproduce this issue with a Cargo-workspace setup even if I use 0.59.2 release that includes the fix from #3260. This repository contains the minimal reproduction.

@illicitonion
Copy link
Collaborator

Thanks for the repro @roman-kashitsyn - #3370 should fix it!

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

Successfully merging a pull request may close this issue.

5 participants