Skip to content

Commit

Permalink
Do not enable llvm-bitcode-linker in most default bootstrap profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
bors authored and Kobzol committed Jun 14, 2024
2 parents d2ad293 + edd4c97 commit 64da5e9
Show file tree
Hide file tree
Showing 18 changed files with 184 additions and 51 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ jobs:
path-type: inherit
install: >
make
dos2unix
diffutils
- name: disable git crlf conversion
run: git config --global core.autocrlf false
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4205,7 +4205,6 @@ dependencies = [
"rustc_middle",
"rustc_span",
"rustc_target",
"rustc_type_ir",
"smallvec",
"tracing",
]
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ elsa = "=1.7.1"
ena = "0.14.3"
indexmap = { version = "2.0.0" }
jobserver_crate = { version = "0.1.28", package = "jobserver" }
libc = "0.2"
measureme = "11"
rustc-hash = "1.1.0"
rustc-rayon = { version = "0.5.0", optional = true }
Expand Down Expand Up @@ -41,6 +40,11 @@ features = [
"Win32_System_Threading",
]

[target.'cfg(unix)'.dependencies]
# tidy-alphabetical-start
libc = "0.2"
# tidy-alphabetical-end

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# tidy-alphabetical-start
memmap2 = "0.2.1"
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_infer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_type_ir = { path = "../rustc_type_ir" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tracing = "0.1"
# tidy-alphabetical-end
18 changes: 15 additions & 3 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ use rustc_errors::{
codes::*, pluralize, struct_span_code_err, Applicability, Diag, DiagCtxt, DiagStyledString,
ErrorGuaranteed, IntoDiagArg, StringPart,
};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor;
use rustc_hir::lang_items::LangItem;
use rustc_hir::{self as hir, ParamName};
use rustc_macros::extension;
use rustc_middle::bug;
use rustc_middle::dep_graph::DepContext;
Expand Down Expand Up @@ -2429,7 +2429,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let (type_scope, type_param_sugg_span) = match bound_kind {
GenericKind::Param(param) => {
let generics = self.tcx.generics_of(generic_param_scope);
let def_id = generics.type_param(param, self.tcx).def_id.expect_local();
let type_param = generics.type_param(param, self.tcx);
let def_id = type_param.def_id.expect_local();
let scope = self.tcx.local_def_id_to_hir_id(def_id).owner.def_id;
// Get the `hir::Param` to verify whether it already has any bounds.
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
Expand All @@ -2439,7 +2440,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
Some((span, open_paren_sp)) => Some((span, true, open_paren_sp)),
// If `param` corresponds to `Self`, no usable suggestion span.
None if generics.has_self && param.index == 0 => None,
None => Some((self.tcx.def_span(def_id).shrink_to_hi(), false, None)),
None => {
let span = if let Some(param) =
hir_generics.params.iter().find(|param| param.def_id == def_id)
&& let ParamName::Plain(ident) = param.name
{
ident.span.shrink_to_hi()
} else {
let span = self.tcx.def_span(def_id);
span.shrink_to_hi()
};
Some((span, false, None))
}
};
(scope, sugg_span)
}
Expand Down
4 changes: 2 additions & 2 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
# whether to set it as rustc's default linker on `x86_64-unknown-linux-gnu`. This will also only be
# when *not* building an external LLVM (so only when using `download-ci-llvm` or building LLVM from
# the in-tree source): setting `llvm-config` in the `[target.x86_64-unknown-linux-gnu]` section will
# make this default to false.
# make this default to false.
#lld = false in all cases, except on `x86_64-unknown-linux-gnu` as described above, where it is true

# Indicates whether LLD will be used to link Rust crates during bootstrap on
Expand All @@ -676,7 +676,7 @@
#llvm-tools = true

# Indicates whether the `self-contained` llvm-bitcode-linker, will be made available
# in the sysroot
# in the sysroot. It is required for running nvptx tests.
#llvm-bitcode-linker = false

# Whether to deny warnings in crates
Expand Down
21 changes: 2 additions & 19 deletions library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};

#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_vendor = "apple"))]
use crate::sys::weak::syscall;
#[cfg(any(target_os = "android", target_os = "macos", target_os = "solaris"))]
#[cfg(target_os = "android")]
use crate::sys::weak::weak;

use libc::{c_int, mode_t};

#[cfg(any(
target_os = "solaris",
all(target_os = "linux", target_env = "gnu"),
target_vendor = "apple",
))]
#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_vendor = "apple"))]
use libc::c_char;
#[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
Expand Down Expand Up @@ -1753,19 +1749,6 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
// Android has `linkat` on newer versions, but we happen to know `link`
// always has the correct behavior, so it's here as well.
cvt(unsafe { libc::link(original.as_ptr(), link.as_ptr()) })?;
} else if #[cfg(any(target_os = "macos", target_os = "solaris"))] {
// MacOS (<=10.9) and Solaris 10 lack support for linkat while newer
// versions have it. We want to use linkat if it is available, so we use weak!
// to check. `linkat` is preferable to `link` because it gives us a flag to
// specify how symlinks should be handled. We pass 0 as the flags argument,
// meaning it shouldn't follow symlinks.
weak!(fn linkat(c_int, *const c_char, c_int, *const c_char, c_int) -> c_int);

if let Some(f) = linkat.get() {
cvt(unsafe { f(libc::AT_FDCWD, original.as_ptr(), libc::AT_FDCWD, link.as_ptr(), 0) })?;
} else {
cvt(unsafe { libc::link(original.as_ptr(), link.as_ptr()) })?;
};
} else {
// Where we can, use `linkat` instead of `link`; see the comment above
// this one for details on why.
Expand Down
2 changes: 0 additions & 2 deletions src/bootstrap/defaults/config.compiler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ lto = "off"
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
# This can be helpful for profiling at a small performance cost.
frame-pointers = true
# Build the llvm-bitcode-linker as it is required for running nvptx tests
llvm-bitcode-linker = true

[llvm]
# Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true`
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/defaults/config.dist.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ download-ci-llvm = false
# Make sure they don't get set when installing from source.
channel = "nightly"
download-rustc = false
# Build the llvm-bitcode-linker as it is required for running nvptx tests
# Build the llvm-bitcode-linker
llvm-bitcode-linker = true

[dist]
Expand Down
2 changes: 0 additions & 2 deletions src/bootstrap/defaults/config.library.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ bench-stage = 0
incremental = true
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
lto = "off"
# Build the llvm-bitcode-linker as it is required for running nvptx tests
llvm-bitcode-linker = true

[llvm]
# Will download LLVM from CI if available on your platform.
Expand Down
2 changes: 0 additions & 2 deletions src/bootstrap/defaults/config.tools.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ incremental = true
# Using these defaults will download the stage2 compiler (see `download-rustc`
# setting) and the stage2 toolchain should therefore be used for these defaults.
download-rustc = "if-unchanged"
# Build the llvm-bitcode-linker as it is required for running nvptx tests
llvm-bitcode-linker = true

[build]
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.
Expand Down
10 changes: 8 additions & 2 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::Path;
use std::process::{Command as StdCommand, ExitStatus, Output, Stdio};

use crate::drop_bomb::DropBomb;
use crate::{assert_not_contains, handle_failed_output};
use crate::{assert_contains, assert_not_contains, handle_failed_output};

/// This is a custom command wrapper that simplifies working with commands and makes it easier to
/// ensure that we check the exit status of executed processes.
Expand Down Expand Up @@ -170,6 +170,12 @@ impl CompletedProcess {
self
}

#[track_caller]
pub fn assert_stdout_contains<S: AsRef<str>>(self, needle: S) -> Self {
assert_contains(&self.stdout_utf8(), needle.as_ref());
self
}

#[track_caller]
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
Expand All @@ -185,7 +191,7 @@ impl CompletedProcess {

#[track_caller]
pub fn assert_stderr_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
assert!(self.stderr_utf8().contains(needle.as_ref()));
assert_contains(&self.stderr_utf8(), needle.as_ref());
self
}

Expand Down
12 changes: 12 additions & 0 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,18 @@ pub fn read_dir<F: Fn(&Path)>(dir: impl AsRef<Path>, callback: F) {
}
}

/// Check that `haystack` contains `needle`. Panic otherwise.
#[track_caller]
pub fn assert_contains(haystack: &str, needle: &str) {
if !haystack.contains(needle) {
eprintln!("=== HAYSTACK ===");
eprintln!("{}", haystack);
eprintln!("=== NEEDLE ===");
eprintln!("{}", needle);
panic!("needle was not found in haystack");
}
}

/// Check that `haystack` does not contain `needle`. Panic otherwise.
#[track_caller]
pub fn assert_not_contains(haystack: &str, needle: &str) {
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
run-make/allocator-shim-circular-deps/Makefile
run-make/allow-non-lint-warnings-cmdline/Makefile
run-make/archive-duplicate-names/Makefile
run-make/atomic-lock-free/Makefile
run-make/branch-protection-check-IBT/Makefile
Expand Down
12 changes: 0 additions & 12 deletions tests/run-make/allow-non-lint-warnings-cmdline/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//@ compile-flags: -Awarnings
//@ check-pass

#[derive()]
#[derive(Copy, Clone)]
pub struct Foo;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//@ error-pattern: r#T: 'static
//@ error-pattern: r#K: 'static
//@ error-pattern: T: 'static=

// https://github.com/rust-lang/rust/issues/124785

struct Foo<T, K = i32>(&'static T, &'static K);
//~^ ERROR: the parameter type `T` may not live long enough
//~| ERROR: the parameter type `K` may not live long enough

struct Bar<r#T, r#K = i32>(&'static r#T, &'static r#K);
//~^ ERROR: the parameter type `T` may not live long enough
//~| ERROR: the parameter type `K` may not live long enough

struct Boo<T= i32>(&'static T);
//~^ ERROR: the parameter type `T` may not live long enough

struct Far<T
= i32>(&'static T);
//~^ ERROR: the parameter type `T` may not live long enough

struct S<'a, K: 'a = i32>(&'static K);
//~^ ERROR: lifetime parameter `'a` is never used
//~| ERROR: the parameter type `K` may not live long enough

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/static-lifetime-tip-with-default-type.rs:7:24
|
LL | struct Foo<T, K = i32>(&'static T, &'static K);
| ^^^^^^^^^^
| |
| the parameter type `T` must be valid for the static lifetime...
| ...so that the reference type `&'static T` does not outlive the data it points at
|
help: consider adding an explicit lifetime bound
|
LL | struct Foo<T: 'static, K = i32>(&'static T, &'static K);
| +++++++++

error[E0310]: the parameter type `K` may not live long enough
--> $DIR/static-lifetime-tip-with-default-type.rs:7:36
|
LL | struct Foo<T, K = i32>(&'static T, &'static K);
| ^^^^^^^^^^
| |
| the parameter type `K` must be valid for the static lifetime...
| ...so that the reference type `&'static K` does not outlive the data it points at
|
help: consider adding an explicit lifetime bound
|
LL | struct Foo<T, K: 'static = i32>(&'static T, &'static K);
| +++++++++

error[E0310]: the parameter type `T` may not live long enough
--> $DIR/static-lifetime-tip-with-default-type.rs:11:28
|
LL | struct Bar<r#T, r#K = i32>(&'static r#T, &'static r#K);
| ^^^^^^^^^^^^
| |
| the parameter type `T` must be valid for the static lifetime...
| ...so that the reference type `&'static T` does not outlive the data it points at
|
help: consider adding an explicit lifetime bound
|
LL | struct Bar<r#T: 'static, r#K = i32>(&'static r#T, &'static r#K);
| +++++++++

error[E0310]: the parameter type `K` may not live long enough
--> $DIR/static-lifetime-tip-with-default-type.rs:11:42
|
LL | struct Bar<r#T, r#K = i32>(&'static r#T, &'static r#K);
| ^^^^^^^^^^^^
| |
| the parameter type `K` must be valid for the static lifetime...
| ...so that the reference type `&'static K` does not outlive the data it points at
|
help: consider adding an explicit lifetime bound
|
LL | struct Bar<r#T, r#K: 'static = i32>(&'static r#T, &'static r#K);
| +++++++++

error[E0310]: the parameter type `T` may not live long enough
--> $DIR/static-lifetime-tip-with-default-type.rs:15:20
|
LL | struct Boo<T= i32>(&'static T);
| ^^^^^^^^^^
| |
| the parameter type `T` must be valid for the static lifetime...
| ...so that the reference type `&'static T` does not outlive the data it points at
|
help: consider adding an explicit lifetime bound
|
LL | struct Boo<T: 'static= i32>(&'static T);
| +++++++++

error[E0310]: the parameter type `T` may not live long enough
--> $DIR/static-lifetime-tip-with-default-type.rs:19:8
|
LL | = i32>(&'static T);
| ^^^^^^^^^^
| |
| the parameter type `T` must be valid for the static lifetime...
| ...so that the reference type `&'static T` does not outlive the data it points at
|
help: consider adding an explicit lifetime bound
|
LL | struct Far<T: 'static
| +++++++++

error[E0310]: the parameter type `K` may not live long enough
--> $DIR/static-lifetime-tip-with-default-type.rs:22:27
|
LL | struct S<'a, K: 'a = i32>(&'static K);
| ^^^^^^^^^^
| |
| the parameter type `K` must be valid for the static lifetime...
| ...so that the reference type `&'static K` does not outlive the data it points at
|
help: consider adding an explicit lifetime bound
|
LL | struct S<'a, K: 'a + 'static = i32>(&'static K);
| +++++++++

error[E0392]: lifetime parameter `'a` is never used
--> $DIR/static-lifetime-tip-with-default-type.rs:22:10
|
LL | struct S<'a, K: 'a = i32>(&'static K);
| ^^ unused lifetime parameter
|
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0310, E0392.
For more information about an error, try `rustc --explain E0310`.

0 comments on commit 64da5e9

Please sign in to comment.