youki icon indicating copy to clipboard operation
youki copied to clipboard

Fails to build on Alpine Linux

Open jirutka opened this issue 3 years ago • 15 comments

cargo build --release
  ...
   Compiling pkg-config v0.3.24
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-gnu` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-gnu`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

Alpine’s rust triplet is x86_64-alpine-linux-musl.


  • youki 0.0.1
  • rust 1.58.0
  • Alpine Linux Edge

jirutka avatar Jan 16 '22 22:01 jirutka

@jirutka Thanks for your report. Maybe you need to modify .cargo/config. Can I ask you to try to modify it?

utam0k avatar Jan 18 '22 12:01 utam0k

Sure, what I should put into .cargo/config?

jirutka avatar Jan 18 '22 12:01 jirutka

@jirutka How about this?

[build]
target = "x86_64-alpine-linux-musl"

utam0k avatar Jan 18 '22 12:01 utam0k

Oh my… I see where’s the problem. Why do you have .cargo/config in the repository? This is a local site-specific config, it shouldn’t be committed into the repository. And you definitely shouldn’t force the target triplet.

jirutka avatar Jan 18 '22 18:01 jirutka

Oh my… I see where’s the problem. Why do you have .cargo/config in the repository? This is a local site-specific config, it shouldn’t be committed into the repository. And you definitely shouldn’t force the target triplet.

@jirutka Youki can only be built with a linux kernel. Therefore, I had to specify it for my environment, but it may not be necessary anymore.

utam0k avatar Jan 20 '22 12:01 utam0k

Youki can only be built with a linux kernel.

And how is this related to linux kernel? Anyway, it shouldn’t be in the repository.

BTW, I successfully built youki on Alpine Linux (musl libc, dynamically linked) aarch64, armhf, armv7, ppc64le, x86, and x86_64 (https://pkgs.alpinelinux.org/packages?name=youki), but a few tests fail (I haven't had time to find out why). I had to patch few things: fix-rlimit-type.patch and libcgroups-workaround-magic-constants.patch. The latter is a workaround for missing constants in the nix crate which is caused by missing constants in the libc crate (https://github.com/rust-lang/libc/pull/2633).

jirutka avatar Jan 20 '22 12:01 jirutka

@jirutka It uses kernel calls that are only available in libseccomp and linux. Therefore, it cannot be built on mac os.

Thanks for your report!

(https://pkgs.alpinelinux.org/packages?name=youki), but a few tests fail (I haven't had time to find out why). I had to patch few things: fix-rlimit-type.patch and libcgroups-workaround-magic-constants.patch. The latter is a workaround for missing constants in the nix crate which is caused by missing constants in the libc crate (rust-lang/libc#2633).

utam0k avatar Jan 20 '22 13:01 utam0k

It uses kernel calls that are only available in libseccomp and linux. Therefore, it cannot be built on mac os.

I know, but again, this is not a reason for forcing target in .cargo/config for everyone.

jirutka avatar Jan 20 '22 13:01 jirutka

It uses kernel calls that are only available in libseccomp and linux. Therefore, it cannot be built on mac os.

Definitely, I agree with you. Do you have any good ideas about it? Maybe we have to use build.rs.

utam0k avatar Jan 20 '22 13:01 utam0k

Do you have any good ideas about it? Maybe we have to use build.rs.

I don’t see any problem that needs to be addressed here, except adding .cargo/ to .gitignore and removing it from the repository. When you have linux-headers, libseccomp dev files and dbus dev files installed on the system (and this is already documented in readme), it just builds (except a few musl/Alpine-specific issues in my case). What OS do you actually use that you had to to explicitly set target to x86_64-unknown-linux-gnu?

jirutka avatar Jan 20 '22 13:01 jirutka

This was to make it easier for macos users to understand the error if they build it.

utam0k avatar Jan 20 '22 13:01 utam0k

It is possible to delete them when the README describes the supported OSes.

utam0k avatar Jan 20 '22 13:01 utam0k

It is possible to delete them when the README describes the supported OSes.

Yes, that’s the correct way.

jirutka avatar Jan 20 '22 13:01 jirutka

Local build is only supported on Linux.

I think it's already addressed in the README.

yujqiao avatar Feb 14 '22 05:02 yujqiao

Seems the issue now is tests failing on Alpine. We probably need to look into this, and figure out why. Until there's some discovery work done I'll leave this ticket open. I may have time in the near future to look into this. @jirutka if you can provide any additional context as to what tests are failing and which architectures they are failing on that would incredibly helpful.

tsturzl avatar Feb 28 '22 06:02 tsturzl

There has been no activity in this issue and youki has changed a lot since this issue has been filed. Please re-open if there is objections.

yihuaf avatar Jul 21 '23 04:07 yihuaf