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

bootstrap should rebuild LLVM when it changes #111893

Closed
jyn514 opened this issue May 24, 2023 · 6 comments · Fixed by #118187
Closed

bootstrap should rebuild LLVM when it changes #111893

jyn514 opened this issue May 24, 2023 · 6 comments · Fixed by #118187
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented May 24, 2023

I tried this code:

; ./configure --set llvm.download-ci-llvm=false
; x build --stage 0 rustc_llvm
; (cd src/llvm_project && git apply)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index dd86144d16..43395b1ecd 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -153,6 +153,8 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
                                      StringRef StringSection,
                                      DWARFContext::unit_iterator_range Units,
                                      bool LittleEndian) {
+  OS << "debug: dumpStringOffsetsSection" << "\n";
+
   auto Contributions = collectContributionData(Units);
   DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0);
   DataExtractor StrData(StringSection, LittleEndian, 0);
; x build --stage 0 rustc_llvm

I expected to see this happen: bootstrap rebuilds LLVM, since it's changed.

Instead, this happened: bootstrap does nothing.

The problem is that we 're using a stamp file and assume that if the commit hasn't changed then none of the files have changed either:

rust/src/bootstrap/llvm.rs

Lines 108 to 123 in 95e8b6a

let stamp = out_dir.join("llvm-finished-building");
let stamp = HashStamp::new(stamp, builder.in_tree_llvm_info.sha());
if stamp.is_done() {
if stamp.hash.is_none() {
builder.info(
"Could not determine the LLVM submodule commit hash. \
Assuming that an LLVM rebuild is not necessary.",
);
builder.info(&format!(
"To force LLVM to rebuild, remove the file `{}`",
stamp.path.display()
));
}
return Ok(res);
}

I am not sure why we do that? Are we assuming that CMake rebuilds too frequently? That seems like something we should fix upstream ...

cc @rust-lang/wg-llvm, I think this would make your lives easier.

Meta

HEAD is branched from ba6f5e3.

@jyn514 jyn514 added C-bug Category: This is a bug. A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 24, 2023
@jyn514
Copy link
Member Author

jyn514 commented May 24, 2023

hmm, #64156 looks related. I am not sure why that would be the correct behavior? If CFLAGS has changed we should rebuild; I would expect distros to make sure CFLAGS matches between invocations of bootstrap.

@jyn514
Copy link
Member Author

jyn514 commented May 24, 2023

The stamp checking for the "normal" case, when not building from a source tarball, has been there since the initial commit of bootstrap: 046e687#diff-ddd5cbd996a9fbebe15be7bb2d9254ea4c1336d6c2e47a5da2a76719df572c01R30-R38

@cuviper
Copy link
Member

cuviper commented May 24, 2023

Are you trying to address the git "dirty" case, or the non-git case, or both?

@jyn514
Copy link
Member Author

jyn514 commented May 24, 2023

Both, but primarily the git case since that's how most people are developing I think.

@cuviper
Copy link
Member

cuviper commented May 24, 2023

Ok, I agree the git case is where folks may actually be making changes, and I still think it's ok not to automatically "notice" changes in the non-git case.

LLVM is big enough that checking for dirty git may not be cheap though. On my Linux system with NVME, it takes ~0.5s after dropping page caches, and ~0.15s cached. On systems with slower disks, virus scanners, etc., it may be a lot worse.

@nikic
Copy link
Contributor

nikic commented May 24, 2023

Yeah, I don't think this is particularly important. The main issue with making changes to LLVM is #109070, which prevents the change from being picked up even if you do commit it.

@onur-ozkan onur-ozkan self-assigned this Nov 22, 2023
@bors bors closed this as completed in 7f974b9 Nov 24, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 24, 2023
Rollup merge of rust-lang#118187 - onur-ozkan:recompile-llvm-on-changes, r=clubby789

Recompile LLVM when it changes in the git sources

Utilize a smart hash for 'llvm-finished-building' to enable recompilation of LLVM with each change in the git sources.

Each change generates a unique hash value in 'llvm-finished-building', which ensures LLVM compilations only triggered with further changes.

Resolves rust-lang#111893

cc `@rust-lang/wg-llvm`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants