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

"target doesn't support these crate types" error on x86_64-unknown-linux-musl host #7154

Closed
a-rodin opened this issue Jul 20, 2019 · 2 comments
Closed
Labels

Comments

@a-rodin
Copy link

@a-rodin a-rodin commented Jul 20, 2019

Problem

I'm trying to build an library with proc-macro for x86_64-unknown-linux-musl target.

When the host is x86_64-unknown-linux-gnu it can be compiled successfully.

However, when the host is x86_64-unknown-linux-gnu, Cargo outputs this error:

error: cannot produce proc-macro for `proc_macro_lib v0.1.0 (/proc-macro-lib)` as the target `x86_64-unknown-linux-musl` does not support these crate types

As I understand, there should be no difference, as the target is the same and no C libraries from the host are used.

Steps

I've created this repository to reproduce the problem using Docker.

Running

docker-compose up --build host-gnu

runs cargo build for a library with proc-macro = true with host x86_64-unknown-linux-gnu and target x86_64-unknown-linux-musl, it builds the library successfully.

However, running

docker-compose up --build host-must

outputs the error mentioned above.
Notes

Output of cargo version:

cargo 1.36.0 (c4fcfb725 2019-05-15)
@a-rodin a-rodin added the C-bug label Jul 20, 2019
@a-rodin a-rodin changed the title Target doesn't support these crate types error on x86_64-unknown-linux-musl host "target doesn't support these crate types" error on x86_64-unknown-linux-musl host Jul 20, 2019
@ehuss

This comment has been minimized.

Copy link
Contributor

@ehuss ehuss commented Jul 20, 2019

Thanks for the detailed repro! I think the issue is that rustc for musl does not support dynamic linking. Proc-macros have to be dynamic libraries as they are loaded by rustc. I'm not up-to-speed on what is blocking this, but I think rust-lang/rust#59302 is the main issue for tracking this.

One option is to use the gnu host with --target for musl.

I'm going to close this as this is a rustc issue.

@viniciusd

This comment has been minimized.

Copy link

@viniciusd viniciusd commented Dec 5, 2019

In case someone else hits this page, my build worked using the flags commented at rust-lang/rust#59302
i.e.: RUSTFLAGS="-C target-feature=-crt-static"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.