Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 10 additions & 6 deletions compiler/rustc_target/src/spec/base/windows_gnullvm.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::borrow::Cow;

use crate::spec::crt_objects::pre_mingw_self_contained;
use crate::spec::{
Abi, BinaryFormat, Cc, DebuginfoKind, Env, LinkerFlavor, Lld, Os, SplitDebuginfo,
TargetOptions, cvs,
Abi, BinaryFormat, Cc, DebuginfoKind, Env, LinkSelfContainedDefault, LinkerFlavor, Lld, Os,
SplitDebuginfo, TargetOptions, add_link_args, cvs,
};

pub(crate) fn opts() -> TargetOptions {
Expand All @@ -15,10 +16,11 @@ pub(crate) fn opts() -> TargetOptions {
&["-nolibc", "--unwindlib=none"],
);
// Order of `late_link_args*` does not matter with LLD.
let late_link_args = TargetOptions::link_args(
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"],
);
let mingw_libs = &["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"];

let mut late_link_args =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);

TargetOptions {
os: Os::Windows,
Expand All @@ -36,6 +38,8 @@ pub(crate) fn opts() -> TargetOptions {
binary_format: BinaryFormat::Coff,
allows_weak_linkage: false,
pre_link_args,
pre_link_objects_self_contained: pre_mingw_self_contained(),
link_self_contained: LinkSelfContainedDefault::InferredForMingw,
late_link_args,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::spec::{Arch, FramePointer, Target, TargetMetadata, base};
use crate::spec::{Arch, Cc, FramePointer, LinkerFlavor, Lld, Target, TargetMetadata, base};

pub(crate) fn target() -> Target {
let mut base = base::windows_gnullvm::opts();
base.max_atomic_width = Some(128);
base.features = "+v8a,+neon,+fp-armv8".into();
base.linker = Some("aarch64-w64-mingw32-clang".into());
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "arm64pe"]);

// Microsoft recommends enabling frame pointers on Arm64 Windows.
// From https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub(crate) fn target() -> Target {
base.features = "+cx16,+sse3,+sahf".into();
base.plt_by_default = false;
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "i386pep"]);
base.max_atomic_width = Some(128);
base.linker = Some("x86_64-w64-mingw32-clang".into());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// ignore-tidy-filelength
use core::ops::ControlFlow;
use std::borrow::Cow;
use std::collections::hash_set;
use std::path::PathBuf;

use rustc_abi::ExternAbi;
use rustc_ast::ast::LitKind;
use rustc_ast::{LitIntType, TraitObjectSyntax};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::unord::UnordSet;
use rustc_errors::codes::*;
use rustc_errors::{
Expand Down Expand Up @@ -1952,11 +1953,17 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
if self.tcx.visibility(did).is_accessible_from(body_def_id, self.tcx) {
// don't suggest foreign `#[doc(hidden)]` types
if !did.is_local() {
while let Some(parent) = parent_map.get(&did) {
let mut previously_seen_dids: FxHashSet<DefId> = Default::default();
previously_seen_dids.insert(did);
while let Some(&parent) = parent_map.get(&did)
&& let hash_set::Entry::Vacant(v) =
previously_seen_dids.entry(parent)
{
if self.tcx.is_doc_hidden(did) {
return false;
}
did = *parent;
v.insert();
did = parent;
}
}
true
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![feature(associated_type_defaults)]
#![feature(box_patterns)]
#![feature(default_field_values)]
#![feature(hash_set_entry)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(iterator_try_reduce)]
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_ty_utils/src/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {

#[instrument(level = "trace", skip(self))]
fn collect_taits_declared_in_body(&mut self) {
let body = self.tcx.hir_body_owned_by(self.item).value;
let Some(body) = self.tcx.hir_maybe_body_owned_by(self.item) else {
return;
};
let body = body.value;
struct TaitInBodyFinder<'a, 'tcx> {
collector: &'a mut OpaqueTypeCollector<'tcx>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ fn copy_self_contained_objects(
DependencyType::TargetSelfContained,
);
}
} else if target.is_windows_gnu() {
} else if target.is_windows_gnu() || target.is_windows_gnullvm() {
for obj in ["crt2.o", "dllcrt2.o"].iter() {
let src = compiler_file(builder, &builder.cc(target), target, CLang::C, obj);
let dst = libdir_self_contained.join(obj);
Expand Down
48 changes: 46 additions & 2 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,44 @@ fn make_win_dist(plat_root: &Path, target: TargetSelection, builder: &Builder<'_
}
}

fn make_win_llvm_dist(plat_root: &Path, target: TargetSelection, builder: &Builder<'_>) {
if builder.config.dry_run() {
return;
}

let (_, lib_path) = get_cc_search_dirs(target, builder);

// Libraries necessary to link the windows-gnullvm toolchains.
// System libraries will be preferred if they are available (see #67429).
let target_libs = [
// MinGW libs
"libunwind.a",
"libunwind.dll.a",
"libmingw32.a",
"libmingwex.a",
"libmsvcrt.a",
// Windows import libs, remove them once std transitions to raw-dylib
"libkernel32.a",
"libuser32.a",
"libntdll.a",
"libuserenv.a",
"libws2_32.a",
"libdbghelp.a",
];

//Find mingw artifacts we want to bundle
let target_libs = find_files(&target_libs, &lib_path);

//Copy platform libs to platform-specific lib directory
let plat_target_lib_self_contained_dir =
plat_root.join("lib/rustlib").join(target).join("lib/self-contained");
fs::create_dir_all(&plat_target_lib_self_contained_dir)
.expect("creating plat_target_lib_self_contained_dir failed");
for src in target_libs {
builder.copy_link_to_folder(&src, &plat_target_lib_self_contained_dir);
}
}

fn runtime_dll_dist(rust_root: &Path, target: TargetSelection, builder: &Builder<'_>) {
if builder.config.dry_run() {
return;
Expand Down Expand Up @@ -394,14 +432,20 @@ impl Step for Mingw {

fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
let target = self.target;
if !target.ends_with("pc-windows-gnu") || !builder.config.dist_include_mingw_linker {
if !target.contains("pc-windows-gnu") || !builder.config.dist_include_mingw_linker {
return None;
}

let mut tarball = Tarball::new(builder, "rust-mingw", &target.triple);
tarball.set_product_name("Rust MinGW");

make_win_dist(tarball.image_dir(), target, builder);
if target.ends_with("pc-windows-gnu") {
make_win_dist(tarball.image_dir(), target, builder);
} else if target.ends_with("pc-windows-gnullvm") {
make_win_llvm_dist(tarball.image_dir(), target, builder);
} else {
unreachable!();
}

Some(tarball.generate())
}
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/config/target_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ impl TargetSelection {
self.ends_with("windows-gnu")
}

pub fn is_windows_gnullvm(&self) -> bool {
self.ends_with("windows-gnullvm")
}

pub fn is_cygwin(&self) -> bool {
self.is_windows() &&
// ref. https://cygwin.com/pipermail/cygwin/2022-February/250802.html
Expand Down
2 changes: 1 addition & 1 deletion src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl Builder {
}
// so is rust-mingw if it's available for the target
PkgType::RustMingw => {
if host.ends_with("pc-windows-gnu") {
if host.contains("pc-windows-gnu") {
components.push(host_component(pkg));
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/impl-trait/ice-148622-opaque-as-const-generics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(type_alias_impl_trait)]

pub type Opaque = impl std::future::Future;
//~^ ERROR: unconstrained opaque type

trait Foo<const N: Opaque> {
//~^ ERROR: `Opaque` is forbidden as the type of a const generic parameter
fn bar(&self) -> [u8; N];
//~^ ERROR: the constant `N` is not of type `usize`
}

fn main() {}
31 changes: 31 additions & 0 deletions tests/ui/impl-trait/ice-148622-opaque-as-const-generics.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error: `Opaque` is forbidden as the type of a const generic parameter
--> $DIR/ice-148622-opaque-as-const-generics.rs:6:20
|
LL | trait Foo<const N: Opaque> {
| ^^^^^^
|
= note: the only supported types are integers, `bool`, and `char`

error: the constant `N` is not of type `usize`
--> $DIR/ice-148622-opaque-as-const-generics.rs:8:22
|
LL | fn bar(&self) -> [u8; N];
| ^^^^^^^ expected `usize`, found future
|
note: this item must have a `#[define_opaque(Opaque)]` attribute to be able to define hidden types
--> $DIR/ice-148622-opaque-as-const-generics.rs:8:8
|
LL | fn bar(&self) -> [u8; N];
| ^^^
= note: the length of array `[u8; N]` must be type `usize`

error: unconstrained opaque type
--> $DIR/ice-148622-opaque-as-const-generics.rs:3:19
|
LL | pub type Opaque = impl std::future::Future;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `Opaque` must be used in combination with a concrete type within the same crate

error: aborting due to 3 previous errors

3 changes: 3 additions & 0 deletions tests/ui/suggestions/auxiliary/hidden-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ impl Marker for hidden::Foo {}
impl Marker for hidden1::Bar {}
impl Marker for Baz {}
impl Marker for Quux {}


pub use crate as library;
5 changes: 5 additions & 0 deletions tests/ui/suggestions/dont-suggest-foreign-doc-hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ pub fn test4(_: Quux) {}

fn test5<T: hidden_struct::Marker>() {}

fn test6<T: hidden_struct::library::Marker>() {}

fn main() {
test5::<i32>();
//~^ ERROR [E0277]

test6::<i32>();
//~^ ERROR [E0277]
}
26 changes: 24 additions & 2 deletions tests/ui/suggestions/dont-suggest-foreign-doc-hidden.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ LL + use hidden_struct::Quux;
|

error[E0277]: the trait bound `i32: Marker` is not satisfied
--> $DIR/dont-suggest-foreign-doc-hidden.rs:25:13
--> $DIR/dont-suggest-foreign-doc-hidden.rs:27:13
|
LL | test5::<i32>();
| ^^^ the trait `Marker` is not implemented for `i32`
Expand All @@ -59,7 +59,29 @@ note: required by a bound in `test5`
LL | fn test5<T: hidden_struct::Marker>() {}
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test5`

error: aborting due to 5 previous errors
error[E0277]: the trait bound `i32: Marker` is not satisfied
--> $DIR/dont-suggest-foreign-doc-hidden.rs:30:13
|
LL | test6::<i32>();
| ^^^ the trait `Marker` is not implemented for `i32`
|
help: the following other types implement trait `Marker`
--> $DIR/auxiliary/hidden-struct.rs:31:1
|
LL | impl Marker for Option<u32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Option<u32>`
...
LL | impl Marker for Baz {}
| ^^^^^^^^^^^^^^^^^^^ `Baz`
LL | impl Marker for Quux {}
| ^^^^^^^^^^^^^^^^^^^^ `Quux`
note: required by a bound in `test6`
--> $DIR/dont-suggest-foreign-doc-hidden.rs:24:13
|
LL | fn test6<T: hidden_struct::library::Marker>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test6`

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0277, E0412.
For more information about an error, try `rustc --explain E0277`.
Loading