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

Compile error using alpine / musl, but not on debian #2036

Closed
pimlie opened this issue Jul 8, 2024 · 5 comments
Closed

Compile error using alpine / musl, but not on debian #2036

pimlie opened this issue Jul 8, 2024 · 5 comments

Comments

@pimlie
Copy link

pimlie commented Jul 8, 2024

Using the rust:alpine based docker image from my other issue about the terminal today, I cannot get past exercise if1 as I keep getting a rustc compile error. All other exercises up to if1 compiled fine using alpine. I tried debugging this myself a bit but I guess I'm still too much of a n00b, so sorry about that ;)

As it works using debian, this can be considered a low prio issue I guess.

# create debian container
$ docker run -d --rm --name rl-debian -v ./rl-data:/data rust:slim sh -c 'cargo install rustlings; rustup component add clippy; echo "READY"; tail -f /.dockerenv'

# create alpine container
$ docker run -d --rm --name rl-alpine -v ./rl-data:/data rust:alpine sh -c 'apk add build-base musl-dev; cargo install rustlings; rustup component add clippy; echo "READY"; tail -f /.dockerenv'

# ... wait for container builds to finish ...

# init rustlings (once, containers share the same folder)
$ docker exec -it -w /data rl-debian rustlings init

# take ownership of local folder
$ sudo chmod 777 ./rl-data -R

# fix if1
$ editor ./rl-data/rustlings/exercises/03_if/if1.rs

# run if1 using the debian container, this should work if you fixed if1 correctly
$ docker exec -it -w /data/rustlings rl-debian rustlings run if1
... shortened ...
✓ Successfully ran exercises/03_if/if1.rs

# run if1 using the alpine container
$ docker exec -it -w /data/rustlings rl-alpine rustlings run if1

The alpine container will show the following error, this ofc prevents you from continuing to the next exercise

error: output of --print=file-names missing when learning about target-specific information from rustc
command was: `/usr/local/rustup/toolchains/1.79.0-x86_64-unknown-linux-musl/bin/rustc - --crate-name ___ --print=file-names -A warnings --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg`

--- stdout
___
lib___.rlib
lib___.a
lib___.so
/usr/local/rustup/toolchains/1.79.0-x86_64-unknown-linux-musl
off
packed
unpacked
___
debug_assertions
panic="unwind"
proc_macro
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="musl"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_os="linux"
target_pointer_width="64"
target_vendor="unknown"
unix
@mo8it
Copy link
Contributor

mo8it commented Jul 8, 2024

The problem why if1 fails is that it is the first exercise with tests. Rustlings currently tests by calling cargo test with RUSTFLAGS="-A warning". It looks like RUSTFLAGS is not handled probably on Alpine.

Closing because Rustlings can't do anything about this issue. It has to be fixed by cargo or rustc. Follow the issue that I opened: rust-lang/rust#127498

Anyway: Just use Debian. Alpine is often problematic and even has worse performance sometimes.

@mo8it mo8it closed this as completed Jul 8, 2024
@pimlie
Copy link
Author

pimlie commented Jul 9, 2024

Thanks :)

I thought indeed that the tests could be the cause of the issue, so I tried removing all the tests from if1 but I guess that it's not possible to toggle https://github.com/rust-lang/rustlings/blob/main/src/exercise.rs dynamically? If I understand correctly it's currently set in the macro config here during the rustlings build and not during the build of the exercise? https://github.com/rust-lang/rustlings/blob/main/rustlings-macros/info.toml

@mo8it
Copy link
Contributor

mo8it commented Jul 9, 2024

Disabling this would either mean disabling tests or having duplicated output of cargo check 😅

@qaqland
Copy link

qaqland commented Jul 14, 2024

works well here

image

  • Alpine Linux 3.20.1
rustc 1.78.0 (9b00956e5 2024-04-29) (Alpine Linux 1.78.0-r0)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-alpine-linux-musl
release: 1.78.0
LLVM version: 17.0.6

i haven't try docker but it seems you can install clippy by apk

apk add rust-clippy

because it has some "special" patches

everything work well on pipeline

https://pkgs.alpinelinux.org/packages?name=rustlings

@mo8it
Copy link
Contributor

mo8it commented Jul 23, 2024

@qaqland Thanks!

I can confirm that both the packaged rustlings and the normal installation after apk add cargo rust-clippy work. Weird how adding rust-clippy fixes the problem 😅

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

No branches or pull requests

3 participants