Build error with proc_macro crates and cross-compilation #37958
|
This may have been fixed by #37846, unsure. @jseyfried would know for sure |
|
Now that ordinary crates can reexport proc macros, rustc needs to load |
|
Could it just be this typo? |
|
@jseyfried Did the build directory of |
I don't think that's related but it would be a good idea to fix regardless.
No, but the @alexcrichton said this should be fairly simple to fix on cargo's end. |
|
At Faraday, we're trying to deploy our first Rust-based service into production, and it's blocking on this issue. (We cross-compile from Ubuntu to Docker containers running Alpine Linux, and we need Here's an example. In [package]
name = "cross_proc_macro_example"
version = "0.1.0"
[dependencies]
serde = "0.8"
serde_derive = "0.8"In #![feature(proc_macro)]
#[macro_use]
extern crate serde_derive;
#[derive(Serialize)]
pub struct Point {
x: f64,
y: f64,
}In extern crate cross_proc_macro_example;
fn main() {}This works fine:
This fails:
...with the errors:
Are there any workarounds for this issue that might get us unstuck? If not, we could modify our build system to deploy on an Ubuntu container instead of cross-compiling to Alpine. |
|
I fixed this in #38024 when no proc macros are reexported (this includes both @nox's and @emk's use cases). The fix will probably be in the This is still an issue (opened rust-lang/cargo#3334) when proc macros are reexported, either via |
|
As we wait for #38024 to land, this can be worked around by setting |
|
@jseyfried Thank you for looking into this! I can confirm that your workaround works. I get a clean build using: env RUSTFLAGS="-L dependency=target/debug/deps" cargo build --verbose --example=example --target=x86_64-unknown-linux-musl |
|
Cargo fix submitted as rust-lang/cargo#3335 |
In servo/servo#14292, cross compilation fails with the following log: https://gist.github.com/jdm/ba11e5fe48fcbc186aecb15a857b54a6
xml5ever is a crate that depends on html5ever-atoms, which itself depends on heapsize_derive if the heap_size feature is selected. heapsize_derive defines
#[derive(HeapSizeOf)]which xml5ever makes no use of.