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

Rollup of 13 pull requests #77212

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
73ada2d
Explicitly document the size guarantees that Option makes.
ltratt Aug 12, 2020
f5118a5
Clarify and add guarantee about `transmute`.
ltratt Aug 12, 2020
83f47aa
Be clear about the reverse `transmute` guarantees.
ltratt Aug 12, 2020
f3d7196
Be clearer about Some/None transmute.
ltratt Aug 12, 2020
8cb8955
Change notation.
ltratt Aug 12, 2020
55802e3
Add Rust function pointers.
ltratt Aug 12, 2020
68209c3
Rename the types for clarity.
ltratt Aug 17, 2020
9bac577
Grammar tweak.
ltratt Aug 17, 2020
2ac89ff
Point at named argument not found when using `format_args_capture` in…
estebank Sep 8, 2020
094d67a
Add accessors to Command.
ehuss Sep 21, 2020
945a732
Update mdBook
camelid Sep 23, 2020
50d9663
Update cargo
ehuss Sep 24, 2020
9baa601
Add `x.py setup`
jyn514 Sep 12, 2020
bab15f7
Remove std::io::lazy::Lazy in favour of SyncOnceCell
m-ou-se Sep 24, 2020
e9b25f5
Add test to check stdout flushing during shutdown.
m-ou-se Sep 24, 2020
45700a9
Drop use of Arc from Stdin and Stdout.
m-ou-se Sep 24, 2020
12ada5c
Remove TrustedLen requirement from BuilderMethods::switch
est31 Sep 24, 2020
6f9c132
Call ReentrantMutex::init() in stdout().
m-ou-se Sep 24, 2020
47843f5
update Miri
RalfJung Sep 24, 2020
257f6e5
Reopen standard streams when they are closed on Unix
tmiasko Sep 25, 2020
187162e
Add missing code examples on slice iter types
GuillaumeGomez Sep 22, 2020
900daba
Remove stray word from `ClosureKind::extends` docs
LingMan Sep 25, 2020
aa6a2f4
Rename `whence` to `span`
camelid Sep 25, 2020
41e8c8c
Rollup merge of #75295 - tmiasko:fds, r=Amanieu
jonas-schievink Sep 26, 2020
d00ca17
Rollup merge of #75454 - ltratt:option_optimisation_guarantees, r=dto…
jonas-schievink Sep 26, 2020
f0caf1d
Rollup merge of #76485 - estebank:format_arg_capture_spans, r=davidtwco
jonas-schievink Sep 26, 2020
73c3a67
Rollup merge of #76631 - jyn514:x.py-setup, r=Mark-Simulacrum
jonas-schievink Sep 26, 2020
df98bae
Rollup merge of #77029 - ehuss:command-access, r=Mark-Simulacrum
jonas-schievink Sep 26, 2020
1f38dba
Rollup merge of #77076 - GuillaumeGomez:missing-code-examples-slice-i…
jonas-schievink Sep 26, 2020
81945dc
Rollup merge of #77127 - camelid:update-mdbook, r=Dylan-DPC
jonas-schievink Sep 26, 2020
d421d4e
Rollup merge of #77129 - ehuss:update-cargo, r=ehuss
jonas-schievink Sep 26, 2020
0206cfc
Rollup merge of #77154 - fusion-engineering-forks:lazy-stdio, r=dtolnay
jonas-schievink Sep 26, 2020
216ed7b
Rollup merge of #77161 - est31:swich_len_already_trusted, r=petrochenkov
jonas-schievink Sep 26, 2020
7776d68
Rollup merge of #77166 - RalfJung:miri, r=RalfJung
jonas-schievink Sep 26, 2020
7e160b6
Rollup merge of #77204 - LingMan:patch-3, r=jonas-schievink
jonas-schievink Sep 26, 2020
bfb0d2d
Rollup merge of #77207 - camelid:whence-to-span, r=jyn514
jonas-schievink Sep 26, 2020
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/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Non-breaking changes since the last major version]

- Add `x.py setup` [#76631](https://github.com/rust-lang/rust/pull/76631)
- Add a changelog for x.py [#76626](https://github.com/rust-lang/rust/pull/76626)
- Optionally, download LLVM from CI on Linux and NixOS
+ [#76439](https://github.com/rust-lang/rust/pull/76349)
Expand Down
19 changes: 16 additions & 3 deletions src/bootstrap/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,34 @@

use std::env;

use bootstrap::{Build, Config};
use bootstrap::{Build, Config, Subcommand};

fn main() {
let args = env::args().skip(1).collect::<Vec<_>>();
let config = Config::parse(&args);

let changelog_suggestion = check_version(&config);
if let Some(suggestion) = &changelog_suggestion {

// NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
// changelog warning, not the `x.py setup` message.
let suggest_setup = !config.config.exists() && !matches!(config.cmd, Subcommand::Setup { .. });
if suggest_setup {
println!("warning: you have not made a `config.toml`");
println!("help: consider running `x.py setup` or copying `config.toml.example`");
} else if let Some(suggestion) = &changelog_suggestion {
println!("{}", suggestion);
}

Build::new(config).build();

if let Some(suggestion) = changelog_suggestion {
if suggest_setup {
println!("warning: you have not made a `config.toml`");
println!("help: consider running `x.py setup` or copying `config.toml.example`");
} else if let Some(suggestion) = &changelog_suggestion {
println!("{}", suggestion);
}

if suggest_setup || changelog_suggestion.is_some() {
println!("note: this message was printed twice to make it more likely to be seen");
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@ impl<'a> Builder<'a> {
Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]),
Subcommand::Install { ref paths } => (Kind::Install, &paths[..]),
Subcommand::Run { ref paths } => (Kind::Run, &paths[..]),
Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(),
Subcommand::Format { .. } | Subcommand::Clean { .. } | Subcommand::Setup { .. } => {
panic!()
}
};

Self::new_internal(build, kind, paths.to_owned())
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub struct Config {
pub keep_stage: Vec<u32>,
pub keep_stage_std: Vec<u32>,
pub src: PathBuf,
// defaults to `config.toml`
pub config: PathBuf,
pub jobs: Option<u32>,
pub cmd: Subcommand,
pub incremental: bool,
Expand Down Expand Up @@ -513,6 +515,7 @@ impl Config {
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
config.deny_warnings = true;
config.missing_tools = false;
config.config = PathBuf::from("config.toml");

// set by bootstrap.py
config.build = TargetSelection::from_user(&env!("BUILD_TRIPLE"));
Expand Down Expand Up @@ -558,7 +561,7 @@ impl Config {
let get_toml = |file: PathBuf| {
use std::process;

let contents = t!(fs::read_to_string(&file), "configuration file did not exist");
let contents = t!(fs::read_to_string(&file), "`include` config not found");
match toml::from_str(&contents) {
Ok(table) => table,
Err(err) => {
Expand Down Expand Up @@ -644,6 +647,7 @@ impl Config {
| Subcommand::Clippy { .. }
| Subcommand::Fix { .. }
| Subcommand::Run { .. }
| Subcommand::Setup { .. }
| Subcommand::Format { .. } => flags.stage.unwrap_or(0),
};

Expand All @@ -668,6 +672,7 @@ impl Config {
| Subcommand::Clippy { .. }
| Subcommand::Fix { .. }
| Subcommand::Run { .. }
| Subcommand::Setup { .. }
| Subcommand::Format { .. } => {}
}
}
Expand Down
32 changes: 31 additions & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::env;
use std::path::PathBuf;
use std::process;

use build_helper::t;
use getopts::Options;

use crate::builder::Builder;
Expand Down Expand Up @@ -89,6 +90,9 @@ pub enum Subcommand {
Run {
paths: Vec<PathBuf>,
},
Setup {
path: String,
},
}

impl Default for Subcommand {
Expand Down Expand Up @@ -199,6 +203,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
|| (s == "install")
|| (s == "run")
|| (s == "r")
|| (s == "setup")
});
let subcommand = match subcommand {
Some(s) => s,
Expand Down Expand Up @@ -453,10 +458,21 @@ Arguments:
At least a tool needs to be called.",
);
}
"setup" => {
subcommand_help.push_str(
"\n
Arguments:
This subcommand accepts a 'profile' to use for builds. For example:

./x.py setup library

The profile is optional and you will be prompted interactively if it is not given.",
);
}
_ => {}
};
// Get any optional paths which occur after the subcommand
let paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>();
let mut paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>();

let cfg_file = env::var_os("BOOTSTRAP_CONFIG").map(PathBuf::from);
let verbose = matches.opt_present("verbose");
Expand Down Expand Up @@ -508,6 +524,20 @@ Arguments:
}
Subcommand::Run { paths }
}
"setup" => {
let path = if paths.len() > 1 {
println!("\nat most one profile can be passed to setup\n");
usage(1, &opts, verbose, &subcommand_help)
} else if let Some(path) = paths.pop() {
t!(path.into_os_string().into_string().map_err(|path| format!(
"{} is not a valid UTF8 string",
path.to_string_lossy()
)))
} else {
t!(crate::setup::interactive_path())
};
Subcommand::Setup { path }
}
_ => {
usage(1, &opts, verbose, &subcommand_help);
}
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ mod metadata;
mod native;
mod run;
mod sanity;
mod setup;
mod test;
mod tool;
mod toolstate;
Expand All @@ -165,7 +166,7 @@ mod job {

use crate::cache::{Interned, INTERNER};
pub use crate::config::Config;
use crate::flags::Subcommand;
pub use crate::flags::Subcommand;

const LLVM_TOOLS: &[&str] = &[
"llvm-nm", // used to inspect binaries; it shows symbol names, their sizes and visibility
Expand Down Expand Up @@ -470,6 +471,10 @@ impl Build {
return clean::clean(self, all);
}

if let Subcommand::Setup { path: include_name } = &self.config.cmd {
return setup::setup(&self.config.src, include_name);
}

{
let builder = builder::Builder::new(&self);
if let Some(path) = builder.paths.get(0) {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Step for ExpandYamlAnchors {

/// Runs the `expand-yaml_anchors` tool.
///
/// This tool in `src/tools` read the CI configuration files written in YAML and expands the
/// This tool in `src/tools` reads the CI configuration files written in YAML and expands the
/// anchors in them, since GitHub Actions doesn't support them.
fn run(self, builder: &Builder<'_>) {
builder.info("Expanding YAML anchors in the GitHub Actions configuration");
Expand Down
88 changes: 88 additions & 0 deletions src/bootstrap/setup.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
use crate::t;
use std::path::{Path, PathBuf};
use std::{
env, fs,
io::{self, Write},
};

pub fn setup(src_path: &Path, include_name: &str) {
let cfg_file = env::var_os("BOOTSTRAP_CONFIG").map(PathBuf::from);

if cfg_file.as_ref().map_or(false, |f| f.exists()) {
let file = cfg_file.unwrap();
println!(
"error: you asked `x.py` to setup a new config file, but one already exists at `{}`",
file.display()
);
println!(
"help: try adding `profile = \"{}\"` at the top of {}",
include_name,
file.display()
);
println!(
"note: this will use the configuration in {}/src/bootstrap/defaults/config.toml.{}",
src_path.display(),
include_name
);
std::process::exit(1);
}

let path = cfg_file.unwrap_or_else(|| src_path.join("config.toml"));
let settings = format!(
"# Includes one of the default files in src/bootstrap/defaults\n\
profile = \"{}\"\n",
include_name
);
t!(fs::write(path, settings));

let include_path =
format!("{}/src/bootstrap/defaults/config.toml.{}", src_path.display(), include_name);
println!("`x.py` will now use the configuration at {}", include_path);

let suggestions = match include_name {
"codegen" | "compiler" => &["check", "build", "test"][..],
"library" => &["check", "build", "test library/std", "doc"],
"user" => &["dist", "build"],
_ => return,
};

println!("To get started, try one of the following commands:");
for cmd in suggestions {
println!("- `x.py {}`", cmd);
}

if include_name != "user" {
println!(
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
);
}
}

// Used to get the path for `Subcommand::Setup`
pub fn interactive_path() -> io::Result<String> {
let mut input = String::new();
println!(
"Welcome to the Rust project! What do you want to do with x.py?
a) Contribute to the standard library
b) Contribute to the compiler
c) Contribute to the compiler, and also modify LLVM or codegen
d) Install Rust from source"
);
let template = loop {
print!("Please choose one (a/b/c/d): ");
io::stdout().flush()?;
io::stdin().read_line(&mut input)?;
break match input.trim().to_lowercase().as_str() {
"a" | "lib" | "library" => "library",
"b" | "compiler" => "compiler",
"c" | "llvm" => "llvm",
"d" | "user" | "maintainer" => "maintainer",
_ => {
println!("error: unrecognized option '{}'", input.trim());
println!("note: press Ctrl+C to exit");
continue;
}
};
};
Ok(template.to_owned())
}