Skip to content

bootstrap: Document that setting description changes the version hash #103557

Open
@mikebenfield

Description

@mikebenfield

If I change description = in config.toml, the Crate IDs change, which leads to different name mangling. In particular this means it's not possible to use PGO profiles produced by a compiler with one description to build a compiler with a different description. Is this intentional?

I'm not sure if v0 mangling actually has anything to do with this, but that's where it was convenient for me to insert the code to print IDs.

To see this, apply this patch:

From 705dac4190d0e1c67a848b5af4ba6fc51e3aaa56 Mon Sep 17 00:00:00 2001
From: Michael Benfield <mbenfield@google.com>
Date: Wed, 26 Oct 2022 01:11:29 +0000
Subject: [PATCH] print

---
 compiler/rustc_symbol_mangling/src/v0.rs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs
index ecfe6861e84..ee21131970f 100644
--- a/compiler/rustc_symbol_mangling/src/v0.rs
+++ b/compiler/rustc_symbol_mangling/src/v0.rs
@@ -739,6 +739,9 @@ fn path_crate(self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
         let stable_crate_id = self.tcx.def_path_hash(cnum.as_def_id()).stable_crate_id();
         self.push_disambiguator(stable_crate_id.to_u64());
         let name = self.tcx.crate_name(cnum);
+        if name.as_str().contains("rustc_serialize") {
+            println!("XXX {} : {:X}", name.as_str(), stable_crate_id.to_u64());
+        }
         self.push_ident(name.as_str());
         Ok(self)
     }
-- 

and make these two files:

% cat configA.toml 
[rust]
description = "A"
new-symbol-mangling = true
~/Code/rust3  [ mbenfield ]
% cat configB.toml 
[rust]
description = "B"
new-symbol-mangling = true

then do

./x.py build --stage 2 --config configA.toml | grep XXX

and

./x.py build --stage 2 --config configB.toml | grep XXX

and you'll get different outputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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