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

Build fails with debian / alpine based build environment #24

Closed
pwFoo opened this issue Feb 19, 2020 · 14 comments
Closed

Build fails with debian / alpine based build environment #24

pwFoo opened this issue Feb 19, 2020 · 14 comments

Comments

@pwFoo
Copy link

pwFoo commented Feb 19, 2020

Hi,
I tried to built rustybox inside of a docker container, but it fails with debian and alpine based Dockerfiles.

FROM    liuchong/rustup:stable-musl AS build
#FROM   rust:alpine

RUN     apt-get update && apt-get install -y \
        build-essential \
        pkg-config \
        clang \
        git

#RUN    apk --update --no-cache add \
#       build-base \
#       pkgconfig \
#       clang \
#       gcc \
#       git

RUN     git clone https://github.com/samuela/rustybox.git /mnt/gitrepo-rustybox

WORKDIR /mnt/gitrepo-rustybox

RUN     cargo build --all-features

error:

info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2020-02-19, rust version 1.43.0-nightly (e620d0f33 2020-02-18)
warning: Force-skipping unavailable component 'clippy-x86_64-unknown-linux-gnu'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
    Updating crates.io index
 Downloading crates ...
  Downloaded lazy_static v1.4.0
  Downloaded c2rust-bitfields v0.3.0
  Downloaded c2rust-asm-casts v0.1.1
  Downloaded libc v0.2.65
  Downloaded c2rust-bitfields-derive v0.2.0
  Downloaded quote v0.6.13
  Downloaded syn v0.15.44
  Downloaded proc-macro2 v0.4.30
  Downloaded unicode-xid v0.1.0
   Compiling proc-macro2 v0.4.30
   Compiling unicode-xid v0.1.0
   Compiling syn v0.15.44
   Compiling libc v0.2.65
   Compiling rustybox v0.0.0 (/mnt/gitrepo-rustybox)
   Compiling lazy_static v1.4.0
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `lazy_static`.
warning: build failed, waiting for other jobs to finish...
error: build failed
@samuela
Copy link
Owner

samuela commented Feb 19, 2020

Hmm looks like a weird error with the rustup toolchain. It's basically saying the compiler can't find the right toolchain. To me this looks like an issue with the base docker image you're using. Does it work compiling other rust projects?

@pwFoo
Copy link
Author

pwFoo commented Feb 21, 2020

Hi, it works fine for rustysd. That are the only two projects I play with at the moment.

@pwFoo
Copy link
Author

pwFoo commented Feb 25, 2020

Seems to be a alpine / musl problem...?
Anyone successfully built rustybox and could share a dockerfile...?

@pwFoo
Copy link
Author

pwFoo commented Feb 25, 2020

Tried to build with ubuntu host...

[...]
error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3120:19
     |
3120 |       usage: std::include_str!("../usage/wget"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3128:19
     |
3128 |       usage: std::include_str!("../usage/which"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3136:19
     |
3136 |       usage: std::include_str!("../usage/who"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3144:19
     |
3144 |       usage: std::include_str!("../usage/whoami"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3152:19
     |
3152 |       usage: std::include_str!("../usage/whois"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3160:19
     |
3160 |       usage: std::include_str!("../usage/xargs"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3168:19
     |
3168 |       usage: std::include_str!("../usage/xxd"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3176:19
     |
3176 |       usage: std::include_str!("../usage/xz"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3184:19
     |
3184 |       usage: std::include_str!("../usage/xzcat"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3192:19
     |
3192 |       usage: std::include_str!("../usage/yes"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3200:19
     |
3200 |       usage: std::include_str!("../usage/zcat"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0433]: failed to resolve: could not find `include_str` in `std`
    --> applets/applet_tables.rs:3208:19
     |
3208 |       usage: std::include_str!("../usage/zcip"),
     |                   ^^^^^^^^^^^ could not find `include_str` in `std`

error[E0554]: #![feature] may not be used on the stable release channel
 --> rustybox.rs:7:1
  |
7 | #![feature(asm)]
  | ^^^^^^^^^^^^^^^^

error[E0554]: #![feature] may not be used on the stable release channel
 --> rustybox.rs:8:1
  |
8 | #![feature(c_variadic)]
  | ^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: #![feature] may not be used on the stable release channel
 --> rustybox.rs:9:1
  |
9 | #![feature(extern_types)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: #![feature] may not be used on the stable release channel
  --> rustybox.rs:10:1
   |
10 | #![feature(label_break_value)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: #![feature] may not be used on the stable release channel
  --> rustybox.rs:11:1
   |
11 | #![feature(ptr_wrapping_offset_from)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 400 previous errors

Some errors have detailed explanations: E0433, E0554.
For more information about an error, try `rustc --explain E0433`.
error: Could not compile `rustybox`.

So it isn't only musl / alpine dependent... :(

@samuela
Copy link
Owner

samuela commented Feb 25, 2020

Hmm that's peculiar. std::include_str! is a macro that should be available in most any recent rust version: https://doc.rust-lang.org/std/macro.include_str.html. The #![feature] errors are prob a result of using rust stable instead of nightly. Cargo should really be picking up the rust-toolchain file to figure that out though.

What versions of rustc and cargo are you using?

@pwFoo
Copy link
Author

pwFoo commented Feb 26, 2020

I haven't checked the version...

Build environment in docker was based on

  • rust:alpine
  • rust:alpine3.10
  • rust
  • rust:slim
  • fedora
  • alpine

Host environment based on an older lubuntu.

I'm new with rust. Rustysd Just compile and works fine. So any Idea how to debug / configure rust build environment?

@samuela
Copy link
Owner

samuela commented Feb 26, 2020

Could you post the output of

rustup show
cargo --version
rustc --version

in the rustybox/ directory? I'm thinking maybe this is a rust version issue... If not that, then maybe some kind of musl libc problem, but that wouldn't explain some of these errors you're seeing.

@pwFoo
Copy link
Author

pwFoo commented Feb 26, 2020

Rust:alpine based test

/rustybox # cargo build --all-features
info: syncing channel updates for 'nightly-x86_64-unknown-linux-musl'
info: latest update on 2020-02-26, rust version 1.43.0-nightly (6fd8798f4 2020-02-25)
info: downloading component 'cargo'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: installing component 'cargo'
info: installing component 'rust-std'
info: installing component 'rustc'
    Updating crates.io index
  Downloaded libc v0.2.65
  Downloaded lazy_static v1.4.0
  Downloaded c2rust-bitfields v0.3.0
  Downloaded c2rust-asm-casts v0.1.1
  Downloaded c2rust-bitfields-derive v0.2.0
  Downloaded quote v0.6.13
  Downloaded proc-macro2 v0.4.30
  Downloaded syn v0.15.44
  Downloaded unicode-xid v0.1.0
error: cannot produce proc-macro for `c2rust-bitfields-derive v0.2.0` as the target `x86_64-unknown-linux-musl` does not support these crate types

/rustybox # cargo --version
cargo 1.43.0-nightly (e57bd0299 2020-02-21)
/rustybox # rustc --version
rustc 1.43.0-nightly (6fd8798f4 2020-02-25)

@pwFoo
Copy link
Author

pwFoo commented Feb 26, 2020

@samuela
Can't build with fedora because of channel stable. And don't know how to change / install nightly...
Maybe you could help me?

@samuela
Copy link
Owner

samuela commented Feb 26, 2020

error: cannot produce proc-macro for `c2rust-bitfields-derive v0.2.0` as the target `x86_64-unknown-linux-musl` does not support these crate types

This makes it sound like c2rust-bitfields-derive doesn't support musl libc. That makes me sad.

On Fedora, I assume you're using glibc? To install nightly rust you'll need to run rustup toolchain install nightly. Check out https://github.com/rust-lang/rustup#working-with-nightly-rust for more info. The file https://github.com/samuela/rustybox/blob/master/rust-toolchain should tell cargo to automatically use nightly anytime you're working on rustybox. Let me know if that works!

@samuela
Copy link
Owner

samuela commented Feb 26, 2020

@pwFoo Created immunant/c2rust#243 re the alpine/musl libc situation.

@pwFoo
Copy link
Author

pwFoo commented Mar 7, 2020

For the moment I stay with busybox which works fine. Thanks for help debugging here!

@pwFoo pwFoo closed this as completed Mar 7, 2020
@samuela
Copy link
Owner

samuela commented Mar 8, 2020

Ok, sorry we couldn't get to the bottom of this @pwFoo ! Feel free to open a new issue or reach out to me otherwise if you'd every like to revisit it!

@kkysen
Copy link

kkysen commented Jun 29, 2022

By the way, @pwFoo and @samuela, immunant/c2rust#243 should be fixed now, I think since the upstream rust-lang/rust#40174 is fixed, so you might be able to implement this PR now.

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