-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Refactor opt-dist
to simplify local building
#115795
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
074fb2c
Store target triple in environment
Kobzol 95500f4
Make executable extension platform, rather than environment dependent
Kobzol f17047b
Refactor Environment
Kobzol a2ed508
Fix `reset_directory` function
Kobzol 11f9283
Add a Local environment to `opt-dist`
Kobzol 6c718b5
Refactor rustc-perf building
Kobzol f13b545
Resolve clippy warnings
Kobzol ee451f8
Fix build on Windows
Kobzol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
use camino::Utf8PathBuf; | ||
use derive_builder::Builder; | ||
|
||
#[derive(Builder)] | ||
pub struct Environment { | ||
host_triple: String, | ||
python_binary: String, | ||
/// The rustc checkout, where the compiler source is located. | ||
checkout_dir: Utf8PathBuf, | ||
/// The main directory where the build occurs. Stage0 rustc and cargo have to be available in | ||
/// this directory before `opt-dist` is started. | ||
build_dir: Utf8PathBuf, | ||
/// Directory where the optimization artifacts (PGO/BOLT profiles, etc.) | ||
/// will be stored. | ||
artifact_dir: Utf8PathBuf, | ||
/// Path to the host LLVM used to compile LLVM in `src/llvm-project`. | ||
host_llvm_dir: Utf8PathBuf, | ||
/// List of test paths that should be skipped when testing the optimized artifacts. | ||
skipped_tests: Vec<String>, | ||
/// Directory containing a pre-built rustc-perf checkout. | ||
#[builder(default)] | ||
prebuilt_rustc_perf: Option<Utf8PathBuf>, | ||
use_bolt: bool, | ||
shared_llvm: bool, | ||
} | ||
|
||
impl Environment { | ||
pub fn host_triple(&self) -> &str { | ||
&self.host_triple | ||
} | ||
|
||
pub fn python_binary(&self) -> &str { | ||
&self.python_binary | ||
} | ||
|
||
pub fn checkout_path(&self) -> Utf8PathBuf { | ||
self.checkout_dir.clone() | ||
} | ||
|
||
pub fn build_root(&self) -> Utf8PathBuf { | ||
self.build_dir.clone() | ||
} | ||
|
||
pub fn build_artifacts(&self) -> Utf8PathBuf { | ||
self.build_root().join("build").join(&self.host_triple) | ||
} | ||
|
||
pub fn artifact_dir(&self) -> Utf8PathBuf { | ||
self.artifact_dir.clone() | ||
} | ||
|
||
pub fn cargo_stage_0(&self) -> Utf8PathBuf { | ||
self.build_artifacts() | ||
.join("stage0") | ||
.join("bin") | ||
.join(format!("cargo{}", executable_extension())) | ||
} | ||
|
||
pub fn rustc_stage_0(&self) -> Utf8PathBuf { | ||
self.build_artifacts() | ||
.join("stage0") | ||
.join("bin") | ||
.join(format!("rustc{}", executable_extension())) | ||
} | ||
|
||
pub fn rustc_stage_2(&self) -> Utf8PathBuf { | ||
self.build_artifacts() | ||
.join("stage2") | ||
.join("bin") | ||
.join(format!("rustc{}", executable_extension())) | ||
} | ||
|
||
pub fn prebuilt_rustc_perf(&self) -> Option<Utf8PathBuf> { | ||
self.prebuilt_rustc_perf.clone() | ||
} | ||
|
||
/// Path to the built rustc-perf benchmark suite. | ||
pub fn rustc_perf_dir(&self) -> Utf8PathBuf { | ||
self.artifact_dir.join("rustc-perf") | ||
} | ||
|
||
pub fn host_llvm_dir(&self) -> Utf8PathBuf { | ||
self.host_llvm_dir.clone() | ||
} | ||
|
||
pub fn use_bolt(&self) -> bool { | ||
self.use_bolt | ||
} | ||
|
||
pub fn supports_shared_llvm(&self) -> bool { | ||
self.shared_llvm | ||
} | ||
|
||
pub fn skipped_tests(&self) -> &[String] { | ||
&self.skipped_tests | ||
} | ||
} | ||
|
||
/// What is the extension of binary executables on this platform? | ||
#[cfg(target_family = "unix")] | ||
pub fn executable_extension() -> &'static str { | ||
"" | ||
} | ||
|
||
#[cfg(target_family = "windows")] | ||
pub fn executable_extension() -> &'static str { | ||
".exe" | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.