Skip to content

A rustc compiled from the rust-*-src tarballs can't be used with the std binaries from s.r-l.o/dist #33286

Closed
@japaric

Description

@japaric

Originally reported here

In the reported case the rust package provided by Arch Linux was compiled from the rustc-1.8.0-src.tar.gz tarball. Thus their rustc binary doesn't have a git commit hash encoded in it:

$ rustc -V
rust-1.8.0

And if you try to use this rustc to cross compile using the std binaries from s.r-l.o you get the following error:

$ cargo build --target=i686-pc-windows-gnu`
error: the crate `std` has been compiled with rustc 1.8.0 (db2939409 2016-04-11), which is incompatible with this version of rustc [E0514]

At the center of this issue is this check, this rustc_version function and this CFG_VERSION env variable which is set by the build system.

In the case of the std crate since it was compiled from a git checkout the value returned by rustc_version is 1.8.0 ($SOME_HASH $SOME_DATE) whereas the same function just returns 1.8.0 in the case of a rustc that was compiled from a source tarball. The mismatch between these two strings is what causes the error reported above. But the error message is wrong because both binaries where compiled from the exact same source code and can be used together.

How to fix this? Possible solutions:

  • Ask package maintaners to always build from a git checkout. This way the "rustc_version" string always contains a git commit hash.
  • Tweak our build system so that building from a git checkout and from a source tarball yield the same "rustc_version" string. Two possible implementations:
    • Drop the commit hash/date part from the "rustc_version" string. This may be OK for the stable and beta channels because you can tell them apart from looking at the version number (e.g. 1.7.0 vs 1.8.0) but that's not the case for nightlies -- two consecutive nightlies would have the same version number (e.g. 1.10.0-nightly).
    • Include the commit hash part in the rustc-*-src.tar.gz tarballs, perhaps as a .commit-hash file and tweak the build system to use the contents of this file in the "rustc_version" string when one is not building from a git checkout.

Thoughts? @alexcrichton @brson

Metadata

Metadata

Labels

C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions