From b1c609e2a6716cb76d2690d86d2d9c255cacbb18 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 21 Aug 2023 20:43:04 +0000 Subject: Fix elided lifetimes in rust-lang/rust --- src/bootstrap/tool.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index e6d27757ac6..07ff3da6b4a 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -601,7 +601,7 @@ pub struct RustAnalyzer { } impl RustAnalyzer { - pub const ALLOW_FEATURES: &str = + pub const ALLOW_FEATURES: &'static str = "proc_macro_internals,proc_macro_diagnostic,proc_macro_span,proc_macro_span_shrink"; } -- cgit 1.4.1-3-g733a5 From 28de139d3545ec7e98dcb0e56349c0d5af0c3909 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 22 Aug 2023 08:48:39 +0200 Subject: bootstrap/miri: respect config_locked_deps --- src/bootstrap/test.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/bootstrap') diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index d0d62db0807..db3b7ffbea4 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -630,6 +630,10 @@ impl Step for Miri { cargo.env("MIRI_SYSROOT", &miri_sysroot); cargo.env("MIRI_HOST_SYSROOT", sysroot); cargo.env("MIRI", &miri); + if builder.config.locked_deps { + // enforce lockfiles + cargo.env("CARGO_EXTRA_FLAGS", "--locked"); + } // Set the target. cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg()); @@ -675,6 +679,9 @@ impl Step for Miri { ); cargo.add_rustc_lib_path(builder, compiler); cargo.arg("--").arg("miri").arg("test"); + if builder.config.locked_deps { + cargo.arg("--locked"); + } cargo .arg("--manifest-path") .arg(builder.src.join("src/tools/miri/test-cargo-miri/Cargo.toml")); -- cgit 1.4.1-3-g733a5 From 0e070aa548e32f6ba8dd4cc28e9c71d9ccfb7ff3 Mon Sep 17 00:00:00 2001 From: Ethan Brierley Date: Tue, 22 Aug 2023 09:09:12 +0100 Subject: Always use `os-release` rather than `/lib` to detect `NixOS` [Two users over on zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Bootstrapping.20on.20NixOS) bumped into issues where NixOS wasn't being properly detected. I believe this was caused by the presence of `/lib` on their machines. `/lib` is not standard on NixOS but can still be created by users or scripts. We are already checking `/etc/os-release`. The presence of `ID=nixos` in it's output should be trustworthy and we shouldn't then go on to also check for `/lib`. --- src/bootstrap/bootstrap.py | 9 ++------- src/bootstrap/download.rs | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index f44a05a6b28..c5c70f2e18a 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -644,7 +644,7 @@ class RustBuild(object): return False # If the user has asked binaries to be patched for Nix, then - # don't check for NixOS or `/lib`. + # don't check for NixOS. if self.get_toml("patch-binaries-for-nix", "build") == "true": return True @@ -652,14 +652,9 @@ class RustBuild(object): # The latter one does not exist on NixOS when using tmpfs as root. try: with open("/etc/os-release", "r") as f: - if not any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f): - return False + return any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f) except FileNotFoundError: return False - if os.path.exists("/lib"): - return False - - return True answer = self._should_fix_bins_and_dylibs = get_answer() if answer: diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index a4135b06e9d..52162bf42ea 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -105,7 +105,7 @@ impl Config { matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"") }), }; - is_nixos && !Path::new("/lib").exists() + is_nixos }); if val { eprintln!("info: You seem to be using Nix."); -- cgit 1.4.1-3-g733a5 From 6aef5b331ffcb6816fb8900f5e2d87948e7cff84 Mon Sep 17 00:00:00 2001 From: David Koloski Date: Tue, 22 Aug 2023 15:29:10 +0000 Subject: Disable bootstrap rustc version check Mitigates #115065 --- src/bootstrap/config.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 4821d20a898..762e66ac7cc 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1276,7 +1276,8 @@ impl Config { } config.initial_rustc = if let Some(rustc) = build.rustc { - config.check_build_rustc_version(&rustc); + // FIXME(#115065): re-enable this check + // config.check_build_rustc_version(&rustc); PathBuf::from(rustc) } else { config.download_beta_toolchain(); -- cgit 1.4.1-3-g733a5 From 35187c7e6474d346eea3113c4ae34d26d6b18756 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 22 Aug 2023 10:42:12 -0700 Subject: Skip ExpandYamlAnchors when the config is missing The dist-src tarball does not include `.github/` at all, so we can't check whether it needs to be regenerated. --- src/bootstrap/test.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/bootstrap') diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index db3b7ffbea4..d1018978f78 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1174,6 +1174,11 @@ impl Step for ExpandYamlAnchors { /// appropriate configuration for all our CI providers. This step ensures the tool was called /// by the user before committing CI changes. fn run(self, builder: &Builder<'_>) { + // Note: `.github/` is not included in dist-src tarballs + if !builder.src.join(".github/workflows/ci.yml").exists() { + builder.info("Skipping YAML anchors check: GitHub Actions config not found"); + return; + } builder.info("Ensuring the YAML anchors in the GitHub Actions config were expanded"); builder.run_delaying_failure( &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src), -- cgit 1.4.1-3-g733a5 From 4332e8417d15f304741208e82ab969768f0dc11d Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 22 Aug 2023 16:16:44 -0400 Subject: drive-by fix to Python doc comment. --- src/bootstrap/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index c5c70f2e18a..c71ecc0a139 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -623,7 +623,7 @@ class RustBuild(object): def should_fix_bins_and_dylibs(self): """Whether or not `fix_bin_or_dylib` needs to be run; can only be True - on NixOS. + on NixOS or if config.toml has `build.patch-binaries-for-nix` set. """ if self._should_fix_bins_and_dylibs is not None: return self._should_fix_bins_and_dylibs -- cgit 1.4.1-3-g733a5 From 3c6f4cc743316ff4b7f76a6492f78d6eb83dcf50 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 22 Aug 2023 17:45:54 -0400 Subject: Better diagnostics for people using nix subshell on non-NixOS. 1. Turned patch-binaries-for-nix from a boolean into a ternary flag: true, false, and unset. 2. When patch-binaries-for-nix is unset, we continue with the existing NixOS detection heuristic (look for nixos in /etc/os-release, if present), but if we are not atop NixOS, then issue a note if we see the IN_NIX_SHELL environment variable telling the user to consider setting patch-binaries-for-nix explicitly. --- src/bootstrap/bootstrap.py | 23 +++++++++++++++++++---- src/bootstrap/config.rs | 4 ++-- src/bootstrap/download.rs | 13 +++++++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index c71ecc0a139..588164e4a85 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -643,18 +643,33 @@ class RustBuild(object): if ostype != "Linux": return False - # If the user has asked binaries to be patched for Nix, then - # don't check for NixOS. + # If the user has explicitly indicated whether binaries should be + # patched for Nix, then don't check for NixOS. if self.get_toml("patch-binaries-for-nix", "build") == "true": return True + if self.get_toml("patch-binaries-for-nix", "build") == "false": + return False + + # Assume we should fix until we see evidence that it is not NixOS + should_fix_retval = True # Use `/etc/os-release` instead of `/etc/NIXOS`. # The latter one does not exist on NixOS when using tmpfs as root. try: with open("/etc/os-release", "r") as f: - return any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f) + should_fix_retval = any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f) except FileNotFoundError: - return False + should_fix_retval = False + + # If not on NixOS, then warn if user seems to be atop Nix shell + if not should_fix_retval: + in_nix_shell = os.getenv('IN_NIX_SHELL') + if in_nix_shell: + print("The IN_NIX_SHELL environment variable is set to `{}`;".format(in_nix_shell), + "you may need to set `patch-binaries-for-nix=true` in your config.toml", + file=sys.stderr) + + return should_fix_retval answer = self._should_fix_bins_and_dylibs = get_answer() if answer: diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 4821d20a898..fc2c91f76b4 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -137,7 +137,7 @@ pub struct Config { pub json_output: bool, pub test_compare_mode: bool, pub color: Color, - pub patch_binaries_for_nix: bool, + pub patch_binaries_for_nix: Option, pub stage0_metadata: Stage0Metadata, pub stdout_is_tty: bool, @@ -1338,7 +1338,7 @@ impl Config { set(&mut config.local_rebuild, build.local_rebuild); set(&mut config.print_step_timings, build.print_step_timings); set(&mut config.print_step_rusage, build.print_step_rusage); - set(&mut config.patch_binaries_for_nix, build.patch_binaries_for_nix); + config.patch_binaries_for_nix = build.patch_binaries_for_nix; config.verbose = cmp::max(config.verbose, flags.verbose as usize); diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index 52162bf42ea..bf8cb4bd768 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -91,8 +91,8 @@ impl Config { // NOTE: this intentionally comes after the Linux check: // - patchelf only works with ELF files, so no need to run it on Mac or Windows // - On other Unix systems, there is no stable syscall interface, so Nix doesn't manage the global libc. - if self.patch_binaries_for_nix { - return true; + if let Some(explicit_value) = self.patch_binaries_for_nix { + return explicit_value; } // Use `/etc/os-release` instead of `/etc/NIXOS`. @@ -105,6 +105,15 @@ impl Config { matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"") }), }; + if !is_nixos { + let in_nix_shell = env::var("IN_NIX_SHELL"); + if let Ok(in_nix_shell) = in_nix_shell { + eprintln!( + "The IN_NIX_SHELL environment variable is set to `{in_nix_shell}`; \ + you may need to set `patch-binaries-for-nix=true` in your config.toml" + ); + } + } is_nixos }); if val { -- cgit 1.4.1-3-g733a5 From ec2c95e0932312c994ee8c5d52b7ee93b5ae65b9 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 23 Aug 2023 23:29:34 -0400 Subject: Accommodate tidy. In addition: Incorporated some review feedback (namely, removed a useless initial assignment to True that was never read), and unified code a bit more between bootstrap.py and download.rs (by using the same variable name for the same concept). --- src/bootstrap/bootstrap.py | 16 +++++++--------- src/bootstrap/download.rs | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 588164e4a85..9dbc87c337c 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -650,26 +650,24 @@ class RustBuild(object): if self.get_toml("patch-binaries-for-nix", "build") == "false": return False - # Assume we should fix until we see evidence that it is not NixOS - should_fix_retval = True - # Use `/etc/os-release` instead of `/etc/NIXOS`. # The latter one does not exist on NixOS when using tmpfs as root. try: with open("/etc/os-release", "r") as f: - should_fix_retval = any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f) + is_nixos = any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') + for ln in f) except FileNotFoundError: - should_fix_retval = False + is_nixos = False # If not on NixOS, then warn if user seems to be atop Nix shell - if not should_fix_retval: + if not is_nixos: in_nix_shell = os.getenv('IN_NIX_SHELL') if in_nix_shell: - print("The IN_NIX_SHELL environment variable is set to `{}`;".format(in_nix_shell), - "you may need to set `patch-binaries-for-nix=true` in your config.toml", + print("The IN_NIX_SHELL environment variable is `{}`;".format(in_nix_shell), + "you may need to set `patch-binaries-for-nix=true` in config.toml", file=sys.stderr) - return should_fix_retval + return is_nixos answer = self._should_fix_bins_and_dylibs = get_answer() if answer: diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index bf8cb4bd768..17c308e915b 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -109,8 +109,8 @@ impl Config { let in_nix_shell = env::var("IN_NIX_SHELL"); if let Ok(in_nix_shell) = in_nix_shell { eprintln!( - "The IN_NIX_SHELL environment variable is set to `{in_nix_shell}`; \ - you may need to set `patch-binaries-for-nix=true` in your config.toml" + "The IN_NIX_SHELL environment variable is `{in_nix_shell}`; \ + you may need to set `patch-binaries-for-nix=true` in config.toml" ); } } -- cgit 1.4.1-3-g733a5