Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ impl<'a> Builder<'a> {
dist::Miri,
dist::LlvmTools,
dist::RustDev,
dist::RustDevConfig,
dist::Bootstrap,
dist::Extended,
// It seems that PlainSourceTarball somehow changes how some of the tools
Expand Down
42 changes: 42 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2297,6 +2297,48 @@ impl Step for RustDev {
}
}

// Tarball intended for internal consumption to ease rustc/std development.
//
// Should not be considered stable by end users.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct RustDevConfig {
pub target: TargetSelection,
}

impl Step for RustDevConfig {
type Output = Option<GeneratedTarball>;
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.alias("rust-dev-config")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustDevConfig { target: run.target });
}

fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
let target = self.target;

/* run only if llvm-config isn't used */
if let Some(config) = builder.config.target_config.get(&target) {
if let Some(ref _s) = config.llvm_config {
builder.info(&format!("Skipping RustDevConfig ({}): external LLVM", target));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is true but confusing when llvm_from_ci is set. maybe we can improve it a bit?

Suggested change
builder.info(&format!("Skipping RustDevConfig ({}): external LLVM", target));
let reason = if builder.config.llvm_from_ci { "downloaded LLVM from CI instead of building it" } else { "external llvm" };
builder.info(&format!("Skipping RustDevConfig ({target}): {reason}");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. However, I realized that this shouldn't fail when llvm_from_ci is true? Because this has to succeed when download-ci-llvm is if-identical. We should probably make llvm_from_ci an enum to distinguish these situations?

return None;
}
}
Comment on lines +2324 to +2330
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this a default instead of a skip, so that we can give a hard error if someone runs x dist rust-dev-config when external llvm is set? see #113640 for an example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
        let config = run.builder.config.target_config.get(&<how to get target?>).map(|c| c.llvm_config);
        run.alias("rust-dev-config").default_condition(config.is_none())
    }

I'm not sure how to get the target, because run.builder contains a list of targets.


let mut tarball = Tarball::new(builder, "rust-dev-config", &target.triple);
tarball.set_overlay(OverlayKind::LLVM);

let config = t!(serde_json::to_string_pretty(&builder.build.config.llvm));
t!(std::fs::write(tarball.image_dir().join("llvm-opts.json"), config));

Some(tarball.generate())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this panics when running x dist rust-dev-config before the llvm submodule is checked out. could you add builder.update_submodule somewhere around

for file in self.overlay.legal_and_readme() {
self.builder.install(&self.builder.src.join(file), &self.overlay_dir, 0o644);
}
please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I really update LLVM submodule in a function that creates a tarball? Shouldn't this be in RustDevConfig? It sounds quite LLVM specific to do this in the Tarball struct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, i suppose doing it in this Step is fine. i was imaging you'd check overlay_kind in Tarball so each calling Step doesn't have to worry about it but in practice they're probably all doing the right thing.

}
}

// Tarball intended for internal consumption to ease rustc/std development.
//
// Should not be considered stable by end users.
Expand Down