Skip to content

run powerpc64le assert_instr on CI #1784

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

folkertdev
Copy link
Contributor

@folkertdev folkertdev commented Apr 20, 2025

Two changes to tests were needed

vrfin -> xvrspic (changed in #1713)

So I think that means that this is fine? At least on s390x the rounding mode is not even relevant, this might be the case for powerpc too?

vmaddfp -> xvmaddasp (changed in #1734)

That is just what C generates too now https://godbolt.org/z/5M8oT6fox

cc @lu-zero

@rustbot
Copy link
Collaborator

rustbot commented Apr 20, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Amanieu Amanieu added this pull request to the merge queue Apr 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Apr 20, 2025
@folkertdev folkertdev force-pushed the powerpc64le-assert-instr-ci branch from d206744 to 7f736d2 Compare April 20, 2025 22:21
@folkertdev
Copy link
Contributor Author

Locally I'm running into this problem with docker

error: failed to write /checkout/Cargo.lock

Caused by:
  failed to open: /checkout/Cargo.lock

Caused by:
  Read-only file system (os error 30)
Full command
> TARGET=powerpc64le-unknown-linux-gnu sh ci/run-docker.sh powerpc64le-unknown-linux-gnu

+ [ 1 -lt 1 ]
+ [ -z powerpc64le-unknown-linux-gnu ]
+ run powerpc64le-unknown-linux-gnu
+ echo Building docker container for TARGET=powerpc64le-unknown-linux-gnu
Building docker container for TARGET=powerpc64le-unknown-linux-gnu
+ docker build -t stdarch -f ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile ci/
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  54.78kB
Step 1/3 : FROM ubuntu:25.04
 ---> f51757c148c7
Step 2/3 : RUN apt-get update && apt-get install -y --no-install-recommends         gcc libc6-dev qemu-user ca-certificates         gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross         file make
 ---> Using cache
 ---> c124a3284845
Step 3/3 : ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc     CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -cpu power11 -L /usr/powerpc64le-linux-gnu"     CC=powerpc64le-linux-gnu-gcc     OBJDUMP=powerpc64le-linux-gnu-objdump
 ---> Using cache
 ---> 7c2f831951cd
Successfully built 7c2f831951cd
Successfully tagged stdarch:latest
+ mkdir -p target c_programs rust_programs
+ echo Running docker
Running docker
+ id -u
+ id -g
+ rustc --print sysroot
+ pwd
+ pwd
+ pwd
+ pwd
+ docker run --rm --user 1000:1000 --env CARGO_HOME=/cargo --env CARGO_TARGET_DIR=/checkout/target --env TARGET=powerpc64le-unknown-linux-gnu --env STDARCH_TEST_EVERYTHING --env STDARCH_DISABLE_ASSERT_INSTR --env NOSTD --env NORUN --env RUSTFLAGS --volume /home/folkertdev/.cargo:/cargo --volume /home/folkertdev/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu:/rust:ro --volume /home/folkertdev/rust/stdarch:/checkout:ro --volume /home/folkertdev/rust/stdarch/target:/checkout/target --volume /home/folkertdev/rust/stdarch/c_programs:/checkout/c_programs --volume /home/folkertdev/rust/stdarch/rust_programs:/checkout/rust_programs --init --workdir /checkout --privileged stdarch sh -c HOME=/tmp PATH=$PATH:/rust/bin exec ci/run.sh powerpc64le-unknown-linux-gnu
+ : powerpc64le-unknown-linux-gnu
+ export RUSTFLAGS= -D warnings -Z merge-functions=disabled 
+ export HOST_RUSTFLAGS= -D warnings -Z merge-functions=disabled 
+ export PROFILE=--profile=release
+ echo RUSTFLAGS= -D warnings -Z merge-functions=disabled 
+ echo OBJDUMP=powerpc64le-linux-gnu-objdump
+ echo STDARCH_DISABLE_ASSERT_INSTR=
+ echo STDARCH_TEST_EVERYTHING=
+ echo STDARCH_TEST_SKIP_FEATURE=
+ echo STDARCH_TEST_SKIP_FUNCTION=
+ echo PROFILE=--profile=releaseRUSTFLAGS= -D warnings -Z merge-functions=disabled 
OBJDUMP=powerpc64le-linux-gnu-objdump
STDARCH_DISABLE_ASSERT_INSTR=
STDARCH_TEST_EVERYTHING=
STDARCH_TEST_SKIP_FEATURE=
STDARCH_TEST_SKIP_FUNCTION=
PROFILE=--profile=release

+ CORE_ARCH=--manifest-path=crates/core_arch/Cargo.toml
+ STD_DETECT=--manifest-path=crates/std_detect/Cargo.toml
+ STDARCH_EXAMPLES=--manifest-path=examples/Cargo.toml
+ INTRINSIC_TEST=--manifest-path=crates/intrinsic-test/Cargo.toml
+ cargo_test --manifest-path=crates/core_arch/Cargo.toml --profile=release
+ cmd=cargo
+ subcmd=test
+ [  = 1 ]
+ cmd=cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release
+ cmd=cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release -- 
+ cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release --
error: failed to write /checkout/Cargo.lock

Caused by:
  failed to open: /checkout/Cargo.lock

Caused by:
  Read-only file system (os error 30)

cc @sayantn if you have thoughts on that

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

The docker container is unable to modify Cargo.lock, you need to run cargo generate-lockfile before the docker

@folkertdev
Copy link
Contributor Author

Are there downsides to having the script run that? To me the whole point of that script is that it just works.

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

Idts, except for probably reducing the write access granularity in the docker.

@folkertdev
Copy link
Contributor Author

Ok, well I added that. With that though I still get an error because clang is missing:

+ [  = 1 ]
+ cmd=cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release
+ cmd=cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release -- 
+ cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release --
   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling libc v0.2.172
   Compiling lazy_static v1.5.0
error: linker `clang` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `proc-macro2` (build script) due to 1 previous error

The manual fix here is to install clang in the Dockerfile, but I'm confused why this is not an issue on CI.

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

You are running run-docker.sh right? This one is new for me 😄. Probably check your RUSTFLAGS env var

@folkertdev
Copy link
Contributor Author

Yes, here's the full output

> TARGET=powerpc64le-unknown-linux-gnu sh ci/run-docker.sh powerpc64le-unknown-linux-gnu

+ [ 1 -lt 1 ]
+ [ -z powerpc64le-unknown-linux-gnu ]
+ run powerpc64le-unknown-linux-gnu
+ cargo generate-lockfile
    Updating crates.io index
     Locking 102 packages to latest compatible versions
      Adding quick-xml v0.33.0 (available: v0.37.4)
      Adding rand v0.8.5 (available: v0.9.1)
      Adding serde_with v1.14.0 (available: v3.12.0)
      Adding serde_yaml v0.8.26 (available: v0.9.34+deprecated)
      Adding wasmprinter v0.2.67 (available: v0.2.80)
+ echo Building docker container for TARGET=powerpc64le-unknown-linux-gnu
Building docker container for TARGET=powerpc64le-unknown-linux-gnu
+ docker build -t stdarch -f ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile ci/
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  54.78kB
Step 1/3 : FROM ubuntu:25.04
 ---> f51757c148c7
Step 2/3 : RUN apt-get update && apt-get install -y --no-install-recommends         gcc libc6-dev qemu-user ca-certificates         gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross         file make
 ---> Using cache
 ---> c124a3284845
Step 3/3 : ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc     CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -cpu power11 -L /usr/powerpc64le-linux-gnu"     CC=powerpc64le-linux-gnu-gcc     OBJDUMP=powerpc64le-linux-gnu-objdump
 ---> Using cache
 ---> 7c2f831951cd
Successfully built 7c2f831951cd
Successfully tagged stdarch:latest
+ mkdir -p target c_programs rust_programs
+ echo Running docker
Running docker
+ id -u
+ id -g
+ rustc --print sysroot
+ pwd
+ pwd
+ pwd
+ pwd
+ docker run --rm --user 1000:1000 --env CARGO_HOME=/cargo --env CARGO_TARGET_DIR=/checkout/target --env TARGET=powerpc64le-unknown-linux-gnu --env STDARCH_TEST_EVERYTHING --env STDARCH_DISABLE_ASSERT_INSTR --env NOSTD --env NORUN --env RUSTFLAGS --volume /home/folkertdev/.cargo:/cargo --volume /home/folkertdev/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu:/rust:ro --volume /home/folkertdev/rust/stdarch:/checkout:ro --volume /home/folkertdev/rust/stdarch/target:/checkout/target --volume /home/folkertdev/rust/stdarch/c_programs:/checkout/c_programs --volume /home/folkertdev/rust/stdarch/rust_programs:/checkout/rust_programs --init --workdir /checkout --privileged stdarch sh -c HOME=/tmp PATH=$PATH:/rust/bin exec ci/run.sh powerpc64le-unknown-linux-gnu
RUSTFLAGS= -D warnings -Z merge-functions=disabled 
OBJDUMP=powerpc64le-linux-gnu-objdump
STDARCH_DISABLE_ASSERT_INSTR=
STDARCH_TEST_EVERYTHING=
STDARCH_TEST_SKIP_FEATURE=
STDARCH_TEST_SKIP_FUNCTION=
PROFILE=--profile=release
+ : powerpc64le-unknown-linux-gnu
+ export RUSTFLAGS= -D warnings -Z merge-functions=disabled 
+ export HOST_RUSTFLAGS= -D warnings -Z merge-functions=disabled 
+ export PROFILE=--profile=release
+ echo RUSTFLAGS= -D warnings -Z merge-functions=disabled 
+ echo OBJDUMP=powerpc64le-linux-gnu-objdump
+ echo STDARCH_DISABLE_ASSERT_INSTR=
+ echo STDARCH_TEST_EVERYTHING=
+ echo STDARCH_TEST_SKIP_FEATURE=
+ echo STDARCH_TEST_SKIP_FUNCTION=
+ echo PROFILE=--profile=release
+ CORE_ARCH=--manifest-path=crates/core_arch/Cargo.toml
+ STD_DETECT=--manifest-path=crates/std_detect/Cargo.toml
+ STDARCH_EXAMPLES=--manifest-path=examples/Cargo.toml
+ INTRINSIC_TEST=--manifest-path=crates/intrinsic-test/Cargo.toml
+ cargo_test --manifest-path=crates/core_arch/Cargo.toml --profile=release
+ cmd=cargo
+ subcmd=test
+ [  = 1 ]
+ cmd=cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release
+ cmd=cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release -- 
+ cargo test --target=powerpc64le-unknown-linux-gnu --manifest-path=crates/core_arch/Cargo.toml --profile=release --
   Compiling proc-macro2 v1.0.95
   Compiling libc v0.2.172
error: linker `clang` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `proc-macro2` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `libc` (build script) due to 1 previous error

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

Honestly, I have no idea. I have never encountered this. Are you on x86? That might explain why I haven't seen this yet

@folkertdev
Copy link
Contributor Author

ok, I got it I think. In my global ~/.cargo/config.toml I specify

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"]

Somehow, the linker field gets used from the docker container. When I remove these lines the docker script works.

Maybe the build script for libc still runs with target x86_64-unknown-linux-gnu?

Obviously I'd like to continue to use mold as my linker for standard rust projects, so is there any way we can get docker to ignore this configuration?

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

The more I look at this, the more it feels like a cargo bug. The doc specifies that target.<triple>.linker behaves exactly as setting CARGO_TARGET_<TRIPLE>_LINKER (https://doc.rust-lang.org/cargo/reference/config.html#targettriplelinker), but this doesn't repro with the env variable, only with the config file

@folkertdev
Copy link
Contributor Author

They just don't account for what docker does right? which is to just not propagate these environment variables, but cargo will still read the global config file.

I'm trying to see if the config can somehow be ignored by the docker script, but not having much luck so far.

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

But at each invocation of cargo in the script, we still have --target=powerpc64le-unknown-linux-gnu, so that config shouldn't even be triggered

@folkertdev
Copy link
Contributor Author

Yeah that's why I'm suspecting a build.rs to be the cause here. Those, I believe, are compiled for the host platform.

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

Ok yes, that is most probably the culprit. I believe the solution is as easy as putting an empty config.toml in the stdarch directory

@folkertdev
Copy link
Contributor Author

Apparently, that does not actually override the linker value. Putting this in the local .cargo/config.toml does work:

[target.x86_64-unknown-linux-gnu]
linker = "cc"

But something like this does not work:

[target.'cfg(all())']
linker = "cc"

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

Unfortunately, I don't think anything else will work. There is an internals thread on this https://internals.rust-lang.org/t/problems-of-cargo-config-files-and-possible-solutions/12987, there are a few old open issues in the cargo repo about this too 😞

@folkertdev
Copy link
Contributor Author

What does seem to work is to set CARGO_HOME=/tmp or similar in ci/run.sh. But that probably messes with the caching on CI.

@folkertdev
Copy link
Contributor Author

Maybe better, I can add this to the run.sh script

# Set the linker that is used for the host (e.g. when compiling a build.rs)
# This overrides any configuration in e.g. `.cargo/config.toml`, which will
# probably not work within the docker container.
HOST_TUPLE_UPPERCASE=$(rustc --print host-tuple | tr a-z A-Z | tr '-' '_')
HOST_LINKER="CARGO_TARGET_${HOST_TUPLE_UPPERCASE}_LINKER"
eval 'export ${HOST_LINKER}="cc"'

@sayantn
Copy link
Contributor

sayantn commented Apr 21, 2025

I feel like this should be in run-docker.sh, because the problem is only in docker

@folkertdev folkertdev force-pushed the powerpc64le-assert-instr-ci branch from f1762db to f00793d Compare April 21, 2025 14:55
The host's linker is used to compile build.rs files (e.g. for libc).
When the user configures a custom liker (e.g. mold) in their own
.cargo/config.toml or ~/.cargo/config.toml, that linker will likely not
work when running run-docker.sh. So, we now reset it to `cc`, which
should always be installed in the docker container.
@folkertdev folkertdev force-pushed the powerpc64le-assert-instr-ci branch from f00793d to f7c228c Compare April 21, 2025 14:58
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 this pull request may close these issues.

4 participants