Description
When building from released sources (https://static.rust-lang.org/dist/rustc-<version>-src.tar.xz
), the resulting rustc binary is missing detailed version information like commit hash and commit date.
Looking at the source it seems to only rely on git commands/paths to assemble this information (https://github.com/rust-lang/rust/blob/5a7834050f3a0ebcd117b4ddf0bc1e8459594309/src/bootstrap/channel.rs#L26-L36
), but it could also be obtained/parsed from rustc-<version>-src/version
when compiling from the released source files (and rustc-<version>-src/git-commit-hash
if the entire commit hash is required too).
As far as I know this affects all rust releases that are not obtained via rustup (i.e. packaged by distributions or built from scratch).
Sample output of rustc -vV
:
rustc 1.51.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-pc-windows-gnu
release: 1.51.0
LLVM version: 11.0.0
Activity
tlyu commentedon Jun 24, 2021
What build directions did you follow? Have you looked at these sections of
config.toml.example
?Zapeth commentedon Jun 24, 2021
I haven't tried to build rust from scratch myself to be honest, but as I said the problem is present in practically every distributed non-rustup build.
So either they are all missing some required configuration or the detailed version information is only included when the source is built from the git repository.
Here are some pkg build files for reference:
MinGW: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-rust/PKGBUILD
Arch Linux: https://github.com/archlinux/svntogit-packages/blob/packages/rust/trunk/PKGBUILD
Gentoo: https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/rust/rust-1.53.0.ebuild
And again, as far as I can tell the detailed version information is left unassigned if no git information is found.
rust_info
is used to set theCFG_VER_
environment variables for version hash/date, and it is initalized from the aforelinkedGitInfo
struct:rust/src/bootstrap/lib.rs
Line 362 in 456a032
which returns
None
when no git repository information is found, which ultimately results in theunknown
string in the version information:rust/compiler/rustc_driver/src/lib.rs
Lines 764 to 769 in 456a032
Also, possibly a consequence of this issue: #33286 (I just looked up that issue and totally forgot that I already left a comment there, whoops)
Auto merge of rust-lang#100557 - dawnofmidnight:tarball-commit-info, …