cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.49k stars 365 forks source link

use cargo-zigbuild 0.17.3 instead of 0.17.2 #1349

Closed thomas725 closed 10 months ago

thomas725 commented 11 months ago

to solve this problem: https://github.com/rust-cross/cargo-zigbuild/issues/151

Emilgardis commented 10 months ago

bors try --target zig

Can you add a changelog entry? See https://github.com/cross-rs/cross/blob/main/.changes/README.md

bors[bot] commented 10 months ago

try

Build failed:

Emilgardis commented 10 months ago
  > [9/9] RUN /zig.sh linux/amd64:
5.302 + local version=0.17.3
5.302 + local dst=/opt/zig
5.302 + local filename=zig-linux-x86_64-0.17.3.tar.xz
5.302 + local td
5.303 ++ mktemp -d
5.304 + td=/tmp/tmp.hg3QrDA9EJ
5.304 + pushd /tmp/tmp.hg3QrDA9EJ
5.304 /tmp/tmp.hg3QrDA9EJ /
5.304 + curl --retry 3 -sSfL https://ziglang.org/download/0.17.3/zig-linux-x86_64-0.17.3.tar.xz -O
he requested URL returned error: 403 

sorry! I was a bit hasty in my response in matrix, it's line 121 that needs to be updated. We probably also should update zig itself

thomas725 commented 10 months ago

hey there! I just checked https://ziglang.org/download/ and it looks like 0.11.0 is still the latest stable version, the only newer one is 0.12.0.dev, and this "dev" suffix and the block header "master" seem's to suggest this is an unstable version.

I'll research how to modify my pull request to undo the wrong change and do the correct one you suggested.

thomas725 commented 10 months ago

okey, and now about the changelog, if I understand the README correctly we'd need to first create an issue for this in the "cross" project, we probably can't just reference the one that exists for the "cargo-zigbuild" project, right?

thomas725 commented 10 months ago

Okey, looking at the previous changelog entries I see the issue property is optional, so I created one without.

Emilgardis commented 10 months ago

perfect!

bors try --target zig

Emilgardis commented 10 months ago

also, I totally forgot about https://github.com/cross-rs/cross/pull/1330

so I think the problem is solved already on main since https://github.com/rust-cross/cargo-zigbuild/commit/79e53f4c36f2d8466ed3b13968b5d61a7ec16f93 exists in 0.17.2 :3

thomas725 commented 10 months ago

Ah, you're right! https://github.com/rust-cross/cargo-zigbuild/issues/151 has been solved by https://github.com/rust-cross/cargo-zigbuild/commit/79e53f4c36f2d8466ed3b13968b5d61a7ec16f93 from 2023-07-29_0604, the first release containing that commit was https://github.com/rust-cross/cargo-zigbuild/releases/tag/v0.17.0 from 2023-07-29_0656.

And since before this pull request we're already using 0.17.2 upgrading is not required to solve this issue.

My open question then is: Why did I ran into this issue and how can I use a version of cross-rs new enough to not have this issue?

Emilgardis commented 10 months ago

You'd want to use a newer image, a versioned cross installed like cargo install cross or cargo install cross --version a.b.c will use images with the tag :a.b.c. To use another image you'd either set the image manually to be image = "ghcr.io/cross-rs/zig:main", install cross from our main branch cargo install cross --git https://github.com/cross-rs/cross or install cross with a locally checked out clone.

We should probably update zigbuild to 0.17.3 anyway, can you change the changelog-file to be named 1330-1349.json and then squash the changes, see https://rustc-dev-guide.rust-lang.org/git.html#squash-your-commits if you're not familiar how to do it

thomas725 commented 10 months ago

changelog entry renamed & squash done

about my environment, I installed using cargo install cross a few weeks ago and got:

$ cross --version
cross 0.2.5 (3c21f9e 2023-10-11)
[cross] note: Falling back to `cargo` on the host.
cargo 1.73.0 (9c4383fb5 2023-08-26)

this reads like it should already contain / use zigbuild 0.17.2 - but it still shows the described problem.

after adding this block to my Cross.toml:

[target.powerpc-unknown-linux-gnu]
zig = "1.2"

I get this:

cross build  --release --target powerpc-unknown-linux-gnu                                                                        ✔ 
   Compiling my-project v0.1.0 (/home/user/Development/git/my-project)
error: linking with `/target/.zig-cache/cargo-zigbuild/0.14.1/zigcc-powerpc-unknown-linux-gnu.1.2.sh` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/zig:/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" VSLANG="1033" "/target/.zig-cache/cargo-zigbuild/0.14.1/zigcc-powerpc-unknown-linux-gnu.1.2.sh" "-m32" "/tmp/rustc1VnBRd/symbols.o" "/target/powerpc-unknown-linux-gnu/release/deps/rust_p2p_chat-30ee95bc05c6ef92.rust_p2p_chat.d55998c031241692-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/target/powerpc-unknown-linux-gnu/release/deps" "-L" "/target/release/deps" "-L" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-gnu/lib/libcompiler_builtins-5c68d6108c0313cf.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-gnu/lib" "-o" "/target/powerpc-unknown-linux-gnu/release/deps/rust_p2p_chat-30ee95bc05c6ef92" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-all" "-nodefaultlibs"
  = note: error: unable to find or provide libc for target 'powerpc-linux.3.16...5.10.81-gnu.1.2'
          info: zig can provide libc for related target powerpc-linux-gnueabi
          info: zig can provide libc for related target powerpc-linux-gnueabihf
          info: zig can provide libc for related target powerpc-linux-musl

error: could not compile `my-project` (bin "my-project") due to previous error

which read's exactly like the problem described here: https://github.com/rust-cross/cargo-zigbuild/issues/151 but whose fix should already be contained in what I'm using. I'm confused.

Emilgardis commented 10 months ago

there is no glibc 1.2 so that's the reason you're getting an error :)

edit: you can find a list of versions here

bors[bot] commented 10 months ago

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here. For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

thomas725 commented 10 months ago

there is no glibc 1.2 so that's the reason you're getting an error :)

edit: you can find a list of versions here

ah, thanks for the link to the existing glibc versions. my PowerPC OpenWRT device says it has:

$ opkg info libc
Package: libc
Version: 1.2.3-4

But I guess that's not glibc?

Also, changing my Cross.toml section to read zig = true instead gives nearly the same error:

error: unable to find or provide libc for target 'powerpc-linux.3.16...5.10.81-gnu.2.19'

So the default seems to be glib 2.19 and there's no powerpc target for that either, correct? How can I view what's available for powerpc?

I've also tried 2.18, 2.15, 2.1, 1.0, 1.9, ... all gave the same schema of error, saying that 'powerpc-linux.3.16...5.10.81-gnu.* was not available.

Versions like 1.09.5 & 1.9.5 instead give this error:

Error: Malformed zig target abi suffix.
Emilgardis commented 10 months ago

yes @thomas725 , as I explained vaguely, 1.2 is musl libc, the libc package on openwrt is a metapackage that is either musl or glibc

I'm not sure about the zig error, maybe it's the linux version (5.10) it's having issues with :/

thomas725 commented 10 months ago

I don't know where the linux kernel version 5.10 is coming from, my physical machine is running on 6.1.55