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

0.2.138 breaks FreeBSD build (using cross) of cargo-hack #3025

Closed
taiki-e opened this issue Dec 3, 2022 · 5 comments
Closed

0.2.138 breaks FreeBSD build (using cross) of cargo-hack #3025

taiki-e opened this issue Dec 3, 2022 · 5 comments
Labels
C-bug Category: bug

Comments

@taiki-e
Copy link
Member

taiki-e commented Dec 3, 2022

After updating libc from 0.2.137 to 0.2.138, the FreeBSD build (using cross) of cargo-hack started failing.

Repro

With the following commands:

cargo install cross
git clone https://github.com/taiki-e/cargo-hack.git
cd cargo-hack
git checkout ee05b26a764fe11f33da5e8eee30da7b11e2d8ae
cross build --target x86_64-unknown-freebsd

I get the following error (full log: https://github.com/taiki-e/cargo-hack/actions/runs/3608985912/jobs/6081906097):

error: linking with `x86_64-unknown-freebsd12-gcc` failed: exit status: 1
  |
  = note: "x86_64-unknown-freebsd12-gcc" "-m64" "/tmp/rustcVB3IQA/symbols.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.0.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.1.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.10.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.11.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.12.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.13.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.14.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.15.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.2.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.3.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.4.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.5.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.6.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.7.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.8.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.9.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.591caykrjgsvxhd7.rcgu.o" "-Wl,--as-needed" "-L" "/target/x86_64-unknown-freebsd/debug/deps" "-L" "/target/debug/deps" "-L" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib" "-Wl,-Bstatic" "/target/x86_64-unknown-freebsd/debug/deps/libctrlc-51998d80f6a72864.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libnix-18ba575260dfad93.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libcfg_if-e38878cf087dac5d.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libtoml_edit-28f6cb71c0f6d966.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libitertools-320cf178378eeeaa.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libeither-e7df64a0ed6ac327.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libcombine-23c1f11c3a9ef338.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libmemchr-641fb448d4e1589d.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libbytes-796123aa541d7ea8.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libtoml_datetime-6007df2bfa888181.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libserde_json-25fa7d12aeda0b06.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libryu-c251820d1f9b81c8.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libitoa-88f22cbe8ae56cdb.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libserde-a8313a979998b903.rlib" "/target/x86_64-unknown-freebsd/debug/deps/liblexopt-63123080e1641219.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libindexmap-121d5ed938e48639.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libhashbrown-69ed5b1ddb63db22.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libis_terminal-9dff342a08150e31.rlib" "/target/x86_64-unknown-freebsd/debug/deps/librustix-64848a51b177c873.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libbitflags-2c68063a742fe5a4.rlib" "/target/x86_64-unknown-freebsd/debug/deps/liberrno-3eefe7e4872ad9b4.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libio_lifetimes-f695832c596a10ea.rlib" "/target/x86_64-unknown-freebsd/debug/deps/liblibc-c37ea1fde818e47a.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libtermcolor-b92f43711680adb6.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libanyhow-e4d331e2c107587b.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libstd-2e2ed02d69a9f376.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libpanic_unwind-9833c7b1a3ab3ba0.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libobject-a4819315bc8bd434.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libmemchr-3b3c29eb743e21fd.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libaddr2line-6855750abe51f6eb.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libgimli-3f49948781a939b7.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_demangle-da6d4cb1cee27a7c.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libstd_detect-858666892f335d6e.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libhashbrown-1ad997d3d3a267f6.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libminiz_oxide-2ccf2aa4712c236f.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libadler-418d538a05b92d78.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_std_workspace_alloc-cf5c5dee4dc6005a.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libunwind-71480e653c0efa74.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libcfg_if-bef4f98576d91896.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/liblibc-daed9adcdb4f1c5c.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/liballoc-c461ba80f2ae5f7b.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_std_workspace_core-0f3d942f27fcf4a5.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libcore-b6632458290bd1a1.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libcompiler_builtins-b37c418607db7120.rlib" "-Wl,-Bdynamic" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lmemstat" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-lexecinfo" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib" "-o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/local/lib/gcc/x86_64-unknown-freebsd12/6.4.0/../../../../x86_64-unknown-freebsd12/bin/ld: cannot find -lmemstat
          collect2: error: ld returned 1 exit status

x86_64-unknown-freebsd12/bin/ld: cannot find -lmemstat

It seems this is related to #2998 that added memstat_* functions.

cc @devnexen

@asomers
Copy link
Contributor

asomers commented Dec 3, 2022

cargo-hack builds fine for me in a real FreeBSD environment with libc 0.2.138. But your CI pipeline looks like it cross-builds from Linux. I don't know the cross-build process well enough to go further.

@taiki-e
Copy link
Member Author

taiki-e commented Dec 4, 2022

@asomers Thanks for confirming. I could also build cargo-hack with setup-cross-toolchain-action/rust-cross-toolchain (taiki-e/cargo-hack#176), so this seems to be an issue specific to some cross-compilation environments.

@taiki-e
Copy link
Member Author

taiki-e commented Dec 4, 2022

Filed cross-rs/cross#1166 to fix cross's build image. Also, it seems that a patch has been submitted to rust-lang/rust to make the same fix (rust-lang/rust#105222).

bors bot added a commit to cross-rs/cross that referenced this issue Dec 4, 2022
1166: freebsd: include memstat in build image r=Emilgardis a=taiki-e

libc 0.2.138 added memstat_* functions, but the build with cross fails because the build image does not contain the corresponding library. See rust-lang/libc#3025 for more context. See also rust-lang/rust#105222 which is the same fix to rust-lang/rust's build image.


Co-authored-by: Taiki Endo <[email protected]>
@taiki-e
Copy link
Member Author

taiki-e commented Dec 4, 2022

The fix to cross has been merged -- closing as an issue of the cross-compilation environment.

@taiki-e taiki-e closed this as completed Dec 4, 2022
@asomers
Copy link
Contributor

asomers commented Dec 4, 2022

This does beg the question though: do we really want to put the libmemstat functions in libc? Or is it just bloat? They could always be moved to a new crate.

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

No branches or pull requests

2 participants