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

Won't compile on musl without libstd #684

Closed
clarfonthey opened this issue Jul 20, 2017 · 7 comments
Closed

Won't compile on musl without libstd #684

clarfonthey opened this issue Jul 20, 2017 · 7 comments

Comments

@clarfonthey
Copy link
Contributor

See the linked thread at rust-lang/rust#37406.

I tried compiling my loop-forever crate on musl to reduce binary size, but it failed to compile due to an error that appears to be a bug; the link_cfg feature should never be called outside of the std build.

@alexcrichton
Copy link
Member

I think we just need to put the relevant attributes behind a #[cfg_attr]

@clarfonthey
Copy link
Contributor Author

This also might be worth looking at the CI setup to see what platforms were missed during testing in addition to musl.

@alexcrichton
Copy link
Member

Looks like that was diagnosed in #685

@Others
Copy link

Others commented Jul 24, 2017

This is currently blocking something I'm working on, and I'd be happy to work on a fix if I understood what that would look like. If the solution is #[cfg_attr(some_check, ...)], what would some_check look like?

My error for reference:

ubuntu@ubuntu-xenial:~/rust2cos/lib_composite$ RUSTFLAGS='-C relocation-model=dynamic-no-pic -C link-args=-no-pie -L /usr/lib/i386-linux-musl/' xargo build --target i686-unknown-linux-musl --release
   Compiling libc v0.2.27
error: is feature gated (see issue #37406)
   --> /home/ubuntu/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/libc-0.2.27/src/unix/mod.rs:234:9
    |
234 |         #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add #![feature(link_cfg)] to the crate attributes to enable

error: is feature gated (see issue #37406)
   --> /home/ubuntu/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/libc-0.2.27/src/unix/mod.rs:235:9
    |
235 |         #[link(name = "c", cfg(not(target_feature = "crt-static")))]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add #![feature(link_cfg)] to the crate attributes to enable

error: aborting due to 2 previous errors

error: Could not compile `libc`.

To learn more, run the command again with --verbose.

@alexcrichton
Copy link
Member

@Others yes these can all be #[cfg_attr(stdbuild, ...)]

Others added a commit to Others/libc that referenced this issue Jul 25, 2017
Fixes rust-lang#684. Previously building libc for musl would fail, because we don't want to use #[link(...)] outside a stdbuild. This commit fixes that issue. (Although it may leave other targets broken, I'm not sure.)
@kristate
Copy link
Contributor

Hi @clarcharr ! I am trying to clean-up issues: is this still an issue for you?

bors added a commit that referenced this issue Feb 28, 2018
Fix --no-default-features builds

Closes #928 #929 #684
@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 28, 2018

This was fixed in #930

@alexcrichton can you close this?

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 a pull request may close this issue.

5 participants