Skip to content

Commit fb94aa5

Browse files
committed
Auto merge of rust-lang#78141 - pietroalbini:beta-rollup, r=pietroalbini
[beta] Rollup backports Cherry-picked: * Always use the Rust version in package names rust-lang#77336 * rustc_parse: More precise spans for `tuple.0.0` rust-lang#77774 * Update crossbeam-channel to avoid UB rust-lang#77819 * build-manifest: stop generating numbered channel names except for stable rust-lang#77854 * Dist build manifest rust-lang#77762 * bootstrap: set correct path for the build-manifest binary rust-lang#77909 r? `@ghost`
2 parents 4708ac7 + 8918415 commit fb94aa5

File tree

16 files changed

+187
-189
lines changed

16 files changed

+187
-189
lines changed

Cargo.lock

+4-3
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ dependencies = [
243243
"anyhow",
244244
"flate2",
245245
"hex 0.4.2",
246+
"num_cpus",
246247
"rayon",
247248
"serde",
248249
"serde_json",
@@ -728,12 +729,12 @@ dependencies = [
728729

729730
[[package]]
730731
name = "crossbeam-channel"
731-
version = "0.4.3"
732+
version = "0.4.4"
732733
source = "registry+https://github.com/rust-lang/crates.io-index"
733-
checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6"
734+
checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87"
734735
dependencies = [
735-
"cfg-if",
736736
"crossbeam-utils 0.7.2",
737+
"maybe-uninit",
737738
]
738739

739740
[[package]]

compiler/rustc_parse/src/parser/expr.rs

+33-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc_ast_pretty::pprust;
1616
use rustc_errors::{Applicability, DiagnosticBuilder, PResult};
1717
use rustc_span::source_map::{self, Span, Spanned};
1818
use rustc_span::symbol::{kw, sym, Ident, Symbol};
19+
use rustc_span::{BytePos, Pos};
1920
use std::mem;
2021
use tracing::debug;
2122

@@ -839,9 +840,10 @@ impl<'a> Parser<'a> {
839840
}
840841
use FloatComponent::*;
841842

843+
let float_str = float.as_str();
842844
let mut components = Vec::new();
843845
let mut ident_like = String::new();
844-
for c in float.as_str().chars() {
846+
for c in float_str.chars() {
845847
if c == '_' || c.is_ascii_alphanumeric() {
846848
ident_like.push(c);
847849
} else if matches!(c, '.' | '+' | '-') {
@@ -857,30 +859,54 @@ impl<'a> Parser<'a> {
857859
components.push(IdentLike(ident_like));
858860
}
859861

860-
// FIXME: Make the span more precise.
862+
// With proc macros the span can refer to anything, the source may be too short,
863+
// or too long, or non-ASCII. It only makes sense to break our span into components
864+
// if its underlying text is identical to our float literal.
861865
let span = self.token.span;
866+
let can_take_span_apart =
867+
|| self.span_to_snippet(span).as_deref() == Ok(float_str).as_deref();
868+
862869
match &*components {
863870
// 1e2
864871
[IdentLike(i)] => {
865872
self.parse_tuple_field_access_expr(lo, base, Symbol::intern(&i), suffix, None)
866873
}
867874
// 1.
868875
[IdentLike(i), Punct('.')] => {
876+
let (ident_span, dot_span) = if can_take_span_apart() {
877+
let (span, ident_len) = (span.data(), BytePos::from_usize(i.len()));
878+
let ident_span = span.with_hi(span.lo + ident_len);
879+
let dot_span = span.with_lo(span.lo + ident_len);
880+
(ident_span, dot_span)
881+
} else {
882+
(span, span)
883+
};
869884
assert!(suffix.is_none());
870885
let symbol = Symbol::intern(&i);
871-
self.token = Token::new(token::Ident(symbol, false), span);
872-
let next_token = Token::new(token::Dot, span);
886+
self.token = Token::new(token::Ident(symbol, false), ident_span);
887+
let next_token = Token::new(token::Dot, dot_span);
873888
self.parse_tuple_field_access_expr(lo, base, symbol, None, Some(next_token))
874889
}
875890
// 1.2 | 1.2e3
876891
[IdentLike(i1), Punct('.'), IdentLike(i2)] => {
892+
let (ident1_span, dot_span, ident2_span) = if can_take_span_apart() {
893+
let (span, ident1_len) = (span.data(), BytePos::from_usize(i1.len()));
894+
let ident1_span = span.with_hi(span.lo + ident1_len);
895+
let dot_span = span
896+
.with_lo(span.lo + ident1_len)
897+
.with_hi(span.lo + ident1_len + BytePos(1));
898+
let ident2_span = self.token.span.with_lo(span.lo + ident1_len + BytePos(1));
899+
(ident1_span, dot_span, ident2_span)
900+
} else {
901+
(span, span, span)
902+
};
877903
let symbol1 = Symbol::intern(&i1);
878-
self.token = Token::new(token::Ident(symbol1, false), span);
879-
let next_token1 = Token::new(token::Dot, span);
904+
self.token = Token::new(token::Ident(symbol1, false), ident1_span);
905+
let next_token1 = Token::new(token::Dot, dot_span);
880906
let base1 =
881907
self.parse_tuple_field_access_expr(lo, base, symbol1, None, Some(next_token1));
882908
let symbol2 = Symbol::intern(&i2);
883-
let next_token2 = Token::new(token::Ident(symbol2, false), span);
909+
let next_token2 = Token::new(token::Ident(symbol2, false), ident2_span);
884910
self.bump_with(next_token2); // `.`
885911
self.parse_tuple_field_access_expr(lo, base1, symbol2, suffix, None)
886912
}

src/bootstrap/builder.rs

+22-21
Original file line numberDiff line numberDiff line change
@@ -193,37 +193,37 @@ impl StepDescription {
193193
);
194194
}
195195

196-
if paths.is_empty() {
197-
for (desc, should_run) in v.iter().zip(should_runs) {
196+
if paths.is_empty() || builder.config.include_default_paths {
197+
for (desc, should_run) in v.iter().zip(&should_runs) {
198198
if desc.default && should_run.is_really_default {
199199
for pathset in &should_run.paths {
200200
desc.maybe_run(builder, pathset);
201201
}
202202
}
203203
}
204-
} else {
205-
for path in paths {
206-
// strip CurDir prefix if present
207-
let path = match path.strip_prefix(".") {
208-
Ok(p) => p,
209-
Err(_) => path,
210-
};
204+
}
211205

212-
let mut attempted_run = false;
213-
for (desc, should_run) in v.iter().zip(&should_runs) {
214-
if let Some(suite) = should_run.is_suite_path(path) {
215-
attempted_run = true;
216-
desc.maybe_run(builder, suite);
217-
} else if let Some(pathset) = should_run.pathset_for_path(path) {
218-
attempted_run = true;
219-
desc.maybe_run(builder, pathset);
220-
}
221-
}
206+
for path in paths {
207+
// strip CurDir prefix if present
208+
let path = match path.strip_prefix(".") {
209+
Ok(p) => p,
210+
Err(_) => path,
211+
};
222212

223-
if !attempted_run {
224-
panic!("error: no rules matched {}", path.display());
213+
let mut attempted_run = false;
214+
for (desc, should_run) in v.iter().zip(&should_runs) {
215+
if let Some(suite) = should_run.is_suite_path(path) {
216+
attempted_run = true;
217+
desc.maybe_run(builder, suite);
218+
} else if let Some(pathset) = should_run.pathset_for_path(path) {
219+
attempted_run = true;
220+
desc.maybe_run(builder, pathset);
225221
}
226222
}
223+
224+
if !attempted_run {
225+
panic!("error: no rules matched {}", path.display());
226+
}
227227
}
228228
}
229229
}
@@ -462,6 +462,7 @@ impl<'a> Builder<'a> {
462462
dist::LlvmTools,
463463
dist::RustDev,
464464
dist::Extended,
465+
dist::BuildManifest,
465466
dist::HashSign
466467
),
467468
Kind::Install => describe!(

src/bootstrap/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub struct Config {
6161
pub profiler: bool,
6262
pub ignore_git: bool,
6363
pub exclude: Vec<PathBuf>,
64+
pub include_default_paths: bool,
6465
pub rustc_error_format: Option<String>,
6566
pub json_output: bool,
6667
pub test_compare_mode: bool,
@@ -532,6 +533,7 @@ impl Config {
532533

533534
let mut config = Config::default_opts();
534535
config.exclude = flags.exclude;
536+
config.include_default_paths = flags.include_default_paths;
535537
config.rustc_error_format = flags.rustc_error_format;
536538
config.json_output = flags.json_output;
537539
config.on_fail = flags.on_fail;

src/bootstrap/dist.rs

+68-19
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,7 @@ use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
2626
use time::{self, Timespec};
2727

2828
pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
29-
if component == "cargo" {
30-
format!("{}-{}", component, builder.cargo_package_vers())
31-
} else if component == "rls" {
32-
format!("{}-{}", component, builder.rls_package_vers())
33-
} else if component == "rust-analyzer" {
34-
format!("{}-{}", component, builder.rust_analyzer_package_vers())
35-
} else if component == "clippy" {
36-
format!("{}-{}", component, builder.clippy_package_vers())
37-
} else if component == "miri" {
38-
format!("{}-{}", component, builder.miri_package_vers())
39-
} else if component == "rustfmt" {
40-
format!("{}-{}", component, builder.rustfmt_package_vers())
41-
} else if component == "llvm-tools" {
42-
format!("{}-{}", component, builder.llvm_tools_package_vers())
43-
} else {
44-
assert!(component.starts_with("rust"));
45-
format!("{}-{}", component, builder.rust_package_vers())
46-
}
29+
format!("{}-{}", component, builder.rust_package_vers())
4730
}
4831

4932
pub(crate) fn distdir(builder: &Builder<'_>) -> PathBuf {
@@ -2370,7 +2353,6 @@ impl Step for HashSign {
23702353
cmd.arg(today.trim());
23712354
cmd.arg(addr);
23722355
cmd.arg(&builder.config.channel);
2373-
cmd.arg(&builder.src);
23742356
cmd.env("BUILD_MANIFEST_LEGACY", "1");
23752357

23762358
builder.create_dir(&distdir(builder));
@@ -2601,3 +2583,70 @@ impl Step for RustDev {
26012583
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
26022584
}
26032585
}
2586+
2587+
/// Tarball containing a prebuilt version of the build-manifest tool, intented to be used by the
2588+
/// release process to avoid cloning the monorepo and building stuff.
2589+
///
2590+
/// Should not be considered stable by end users.
2591+
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
2592+
pub struct BuildManifest {
2593+
pub target: TargetSelection,
2594+
}
2595+
2596+
impl Step for BuildManifest {
2597+
type Output = PathBuf;
2598+
const DEFAULT: bool = false;
2599+
const ONLY_HOSTS: bool = true;
2600+
2601+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2602+
run.path("src/tools/build-manifest")
2603+
}
2604+
2605+
fn make_run(run: RunConfig<'_>) {
2606+
run.builder.ensure(BuildManifest { target: run.target });
2607+
}
2608+
2609+
fn run(self, builder: &Builder<'_>) -> PathBuf {
2610+
let build_manifest = builder.tool_exe(Tool::BuildManifest);
2611+
2612+
let name = pkgname(builder, "build-manifest");
2613+
let tmp = tmpdir(builder);
2614+
2615+
// Prepare the image.
2616+
let image = tmp.join("build-manifest-image");
2617+
let image_bin = image.join("bin");
2618+
let _ = fs::remove_dir_all(&image);
2619+
t!(fs::create_dir_all(&image_bin));
2620+
builder.install(&build_manifest, &image_bin, 0o755);
2621+
2622+
// Prepare the overlay.
2623+
let overlay = tmp.join("build-manifest-overlay");
2624+
let _ = fs::remove_dir_all(&overlay);
2625+
builder.create_dir(&overlay);
2626+
builder.create(&overlay.join("version"), &builder.rust_version());
2627+
for file in &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"] {
2628+
builder.install(&builder.src.join(file), &overlay, 0o644);
2629+
}
2630+
2631+
// Create the final tarball.
2632+
let mut cmd = rust_installer(builder);
2633+
cmd.arg("generate")
2634+
.arg("--product-name=Rust")
2635+
.arg("--rel-manifest-dir=rustlib")
2636+
.arg("--success-message=build-manifest installed.")
2637+
.arg("--image-dir")
2638+
.arg(&image)
2639+
.arg("--work-dir")
2640+
.arg(&tmpdir(builder))
2641+
.arg("--output-dir")
2642+
.arg(&distdir(builder))
2643+
.arg("--non-installed-overlay")
2644+
.arg(&overlay)
2645+
.arg(format!("--package-name={}-{}", name, self.target.triple))
2646+
.arg("--legacy-manifest-dirs=rustlib,cargo")
2647+
.arg("--component-name=build-manifest");
2648+
2649+
builder.run(&mut cmd);
2650+
distdir(builder).join(format!("{}-{}.tar.gz", name, self.target.triple))
2651+
}
2652+
}

src/bootstrap/flags.rs

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct Flags {
2929
pub cmd: Subcommand,
3030
pub incremental: bool,
3131
pub exclude: Vec<PathBuf>,
32+
pub include_default_paths: bool,
3233
pub rustc_error_format: Option<String>,
3334
pub json_output: bool,
3435
pub dry_run: bool,
@@ -133,6 +134,11 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
133134
opts.optmulti("", "host", "host targets to build", "HOST");
134135
opts.optmulti("", "target", "target targets to build", "TARGET");
135136
opts.optmulti("", "exclude", "build paths to exclude", "PATH");
137+
opts.optflag(
138+
"",
139+
"include-default-paths",
140+
"include default paths in addition to the provided ones",
141+
);
136142
opts.optopt("", "on-fail", "command to run on failure", "CMD");
137143
opts.optflag("", "dry-run", "dry run; don't build anything");
138144
opts.optopt(
@@ -601,6 +607,7 @@ Arguments:
601607
.into_iter()
602608
.map(|p| p.into())
603609
.collect::<Vec<_>>(),
610+
include_default_paths: matches.opt_present("include-default-paths"),
604611
deny_warnings: parse_deny_warnings(&matches),
605612
llvm_skip_rebuild: matches.opt_str("llvm-skip-rebuild").map(|s| s.to_lowercase()).map(
606613
|s| s.parse::<bool>().expect("`llvm-skip-rebuild` should be either true or false"),

src/bootstrap/lib.rs

-34
Original file line numberDiff line numberDiff line change
@@ -1051,40 +1051,6 @@ impl Build {
10511051
self.package_vers(&self.version)
10521052
}
10531053

1054-
/// Returns the value of `package_vers` above for Cargo
1055-
fn cargo_package_vers(&self) -> String {
1056-
self.package_vers(&self.release_num("cargo"))
1057-
}
1058-
1059-
/// Returns the value of `package_vers` above for rls
1060-
fn rls_package_vers(&self) -> String {
1061-
self.package_vers(&self.release_num("rls"))
1062-
}
1063-
1064-
/// Returns the value of `package_vers` above for rust-analyzer
1065-
fn rust_analyzer_package_vers(&self) -> String {
1066-
self.package_vers(&self.release_num("rust-analyzer/crates/rust-analyzer"))
1067-
}
1068-
1069-
/// Returns the value of `package_vers` above for clippy
1070-
fn clippy_package_vers(&self) -> String {
1071-
self.package_vers(&self.release_num("clippy"))
1072-
}
1073-
1074-
/// Returns the value of `package_vers` above for miri
1075-
fn miri_package_vers(&self) -> String {
1076-
self.package_vers(&self.release_num("miri"))
1077-
}
1078-
1079-
/// Returns the value of `package_vers` above for rustfmt
1080-
fn rustfmt_package_vers(&self) -> String {
1081-
self.package_vers(&self.release_num("rustfmt"))
1082-
}
1083-
1084-
fn llvm_tools_package_vers(&self) -> String {
1085-
self.package_vers(&self.version)
1086-
}
1087-
10881054
fn llvm_tools_vers(&self) -> String {
10891055
self.rust_version()
10901056
}

src/bootstrap/run.rs

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ impl Step for BuildManifest {
7777
cmd.arg(today.trim());
7878
cmd.arg(addr);
7979
cmd.arg(&builder.config.channel);
80-
cmd.arg(&builder.src);
8180

8281
builder.create_dir(&distdir(builder));
8382
builder.run(&mut cmd);

src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ ENV RUST_CONFIGURE_ARGS \
9898
--set llvm.thin-lto=true \
9999
--set llvm.ninja=false \
100100
--set rust.jemalloc
101-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
101+
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS \
102+
--include-default-paths \
103+
src/tools/build-manifest
102104
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
103105

104106
# This is the only builder which will create source tarballs

0 commit comments

Comments
 (0)