Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 93257e2

Browse files
committed
Auto merge of #138450 - matthiaskrgr:rollup-4im25vf, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #137816 (attempt to support `BinaryFormat::Xcoff` in `naked_asm!`) - #138109 (make precise capturing args in rustdoc Json typed) - #138343 (Enable `f16` tests for `powf`) - #138356 (bump libc to 0.2.171 to fix xous) - #138371 (Update compiletest's `has_asm_support` to match rustc) - #138404 (Cleanup sysroot locating a bit) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a2aba05 + ad23e9d commit 93257e2

File tree

33 files changed

+269
-128
lines changed

33 files changed

+269
-128
lines changed

‎compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3838
}
3939
if let Some(asm_arch) = asm_arch {
4040
// Inline assembly is currently only stable for these architectures.
41+
// (See also compiletest's `has_asm_support`.)
4142
let is_stable = matches!(
4243
asm_arch,
4344
asm::InlineAsmArch::X86

‎compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,8 +1288,7 @@ fn link_sanitizer_runtime(
12881288
if path.exists() {
12891289
sess.target_tlib_path.dir.clone()
12901290
} else {
1291-
let default_sysroot =
1292-
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
1291+
let default_sysroot = filesearch::get_or_default_sysroot();
12931292
let default_tlib =
12941293
filesearch::make_target_lib_path(&default_sysroot, sess.opts.target_triple.tuple());
12951294
default_tlib

‎compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ fn prefix_and_suffix<'tcx>(
125125
// the alignment from a `#[repr(align(<n>))]` is used if it specifies a higher alignment.
126126
// if no alignment is specified, an alignment of 4 bytes is used.
127127
let min_function_alignment = tcx.sess.opts.unstable_opts.min_function_alignment;
128-
let align = Ord::max(min_function_alignment, attrs.alignment).map(|a| a.bytes()).unwrap_or(4);
128+
let align_bytes =
129+
Ord::max(min_function_alignment, attrs.alignment).map(|a| a.bytes()).unwrap_or(4);
129130

130131
// In particular, `.arm` can also be written `.code 32` and `.thumb` as `.code 16`.
131132
let (arch_prefix, arch_suffix) = if is_arm {
@@ -157,12 +158,16 @@ fn prefix_and_suffix<'tcx>(
157158
}
158159
Linkage::LinkOnceAny | Linkage::LinkOnceODR | Linkage::WeakAny | Linkage::WeakODR => {
159160
match asm_binary_format {
160-
BinaryFormat::Elf
161-
| BinaryFormat::Coff
162-
| BinaryFormat::Wasm
163-
| BinaryFormat::Xcoff => {
161+
BinaryFormat::Elf | BinaryFormat::Coff | BinaryFormat::Wasm => {
164162
writeln!(w, ".weak {asm_name}")?;
165163
}
164+
BinaryFormat::Xcoff => {
165+
// FIXME: there is currently no way of defining a weak symbol in inline assembly
166+
// for AIX. See https://github.com/llvm/llvm-project/issues/130269
167+
emit_fatal(
168+
"cannot create weak symbols from inline assembly for this target",
169+
)
170+
}
166171
BinaryFormat::MachO => {
167172
writeln!(w, ".globl {asm_name}")?;
168173
writeln!(w, ".weak_definition {asm_name}")?;
@@ -189,7 +194,7 @@ fn prefix_and_suffix<'tcx>(
189194
let mut begin = String::new();
190195
let mut end = String::new();
191196
match asm_binary_format {
192-
BinaryFormat::Elf | BinaryFormat::Xcoff=> {
197+
BinaryFormat::Elf => {
193198
let section = link_section.unwrap_or(format!(".text.{asm_name}"));
194199

195200
let progbits = match is_arm {
@@ -203,7 +208,7 @@ fn prefix_and_suffix<'tcx>(
203208
};
204209

205210
writeln!(begin, ".pushsection {section},\"ax\", {progbits}").unwrap();
206-
writeln!(begin, ".balign {align}").unwrap();
211+
writeln!(begin, ".balign {align_bytes}").unwrap();
207212
write_linkage(&mut begin).unwrap();
208213
if let Visibility::Hidden = item_data.visibility {
209214
writeln!(begin, ".hidden {asm_name}").unwrap();
@@ -224,7 +229,7 @@ fn prefix_and_suffix<'tcx>(
224229
BinaryFormat::MachO => {
225230
let section = link_section.unwrap_or("__TEXT,__text".to_string());
226231
writeln!(begin, ".pushsection {},regular,pure_instructions", section).unwrap();
227-
writeln!(begin, ".balign {align}").unwrap();
232+
writeln!(begin, ".balign {align_bytes}").unwrap();
228233
write_linkage(&mut begin).unwrap();
229234
if let Visibility::Hidden = item_data.visibility {
230235
writeln!(begin, ".private_extern {asm_name}").unwrap();
@@ -240,7 +245,7 @@ fn prefix_and_suffix<'tcx>(
240245
BinaryFormat::Coff => {
241246
let section = link_section.unwrap_or(format!(".text.{asm_name}"));
242247
writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
243-
writeln!(begin, ".balign {align}").unwrap();
248+
writeln!(begin, ".balign {align_bytes}").unwrap();
244249
write_linkage(&mut begin).unwrap();
245250
writeln!(begin, ".def {asm_name}").unwrap();
246251
writeln!(begin, ".scl 2").unwrap();
@@ -279,6 +284,33 @@ fn prefix_and_suffix<'tcx>(
279284
// .size is ignored for function symbols, so we can skip it
280285
writeln!(end, "end_function").unwrap();
281286
}
287+
BinaryFormat::Xcoff => {
288+
// the LLVM XCOFFAsmParser is extremely incomplete and does not implement many of the
289+
// documented directives.
290+
//
291+
// - https://github.com/llvm/llvm-project/blob/1b25c0c4da968fe78921ce77736e5baef4db75e3/llvm/lib/MC/MCParser/XCOFFAsmParser.cpp
292+
// - https://www.ibm.com/docs/en/ssw_aix_71/assembler/assembler_pdf.pdf
293+
//
294+
// Consequently, we try our best here but cannot do as good a job as for other binary
295+
// formats.
296+
297+
// FIXME: start a section. `.csect` is not currently implemented in LLVM
298+
299+
// fun fact: according to the assembler documentation, .align takes an exponent,
300+
// but LLVM only accepts powers of 2 (but does emit the exponent)
301+
// so when we hand `.align 32` to LLVM, the assembly output will contain `.align 5`
302+
writeln!(begin, ".align {}", align_bytes).unwrap();
303+
304+
write_linkage(&mut begin).unwrap();
305+
if let Visibility::Hidden = item_data.visibility {
306+
// FIXME apparently `.globl {asm_name}, hidden` is valid
307+
// but due to limitations with `.weak` (see above) we can't really use that in general yet
308+
}
309+
writeln!(begin, "{asm_name}:").unwrap();
310+
311+
writeln!(end).unwrap();
312+
// FIXME: end the section?
313+
}
282314
}
283315

284316
(begin, end)

‎compiler/rustc_error_messages/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ impl From<Vec<FluentError>> for TranslationBundleError {
106106
/// (overriding any conflicting messages).
107107
#[instrument(level = "trace")]
108108
pub fn fluent_bundle(
109-
mutuser_provided_sysroot:Option<PathBuf>,
110-
mutsysroot_candidates: Vec<PathBuf>,
109+
sysroot:PathBuf,
110+
sysroot_candidates: Vec<PathBuf>,
111111
requested_locale: Option<LanguageIdentifier>,
112112
additional_ftl_path: Option<&Path>,
113113
with_directionality_markers: bool,
@@ -141,7 +141,7 @@ pub fn fluent_bundle(
141141
// If the user requests the default locale then don't try to load anything.
142142
if let Some(requested_locale) = requested_locale {
143143
let mut found_resources = false;
144-
for sysroot in user_provided_sysroot.iter_mut().chain(sysroot_candidates.iter_mut()) {
144+
for mutsysroot in Some(sysroot).into_iter().chain(sysroot_candidates.into_iter()) {
145145
sysroot.push("share");
146146
sysroot.push("locale");
147147
sysroot.push(requested_locale.to_string());

‎compiler/rustc_hir/src/hir.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,13 +3373,16 @@ pub struct OpaqueTy<'hir> {
33733373
pub span: Span,
33743374
}
33753375

3376-
#[derive(Debug, Clone, Copy, HashStable_Generic)]
3377-
pub enum PreciseCapturingArg<'hir> {
3378-
Lifetime(&'hirLifetime),
3376+
#[derive(Debug, Clone, Copy, HashStable_Generic,Encodable,Decodable)]
3377+
pub enum PreciseCapturingArgKind<T,U> {
3378+
Lifetime(T),
33793379
/// Non-lifetime argument (type or const)
3380-
Param(PreciseCapturingNonLifetimeArg),
3380+
Param(U),
33813381
}
33823382

3383+
pub type PreciseCapturingArg<'hir> =
3384+
PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3385+
33833386
impl PreciseCapturingArg<'_> {
33843387
pub fn hir_id(self) -> HirId {
33853388
match self {

‎compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc_errors::{
2828
use rustc_hir::def::DefKind;
2929
use rustc_hir::def_id::{DefId, LocalDefId};
3030
use rustc_hir::intravisit::{self, InferKind, Visitor, VisitorExt, walk_generics};
31-
use rustc_hir::{self as hir, GenericParamKind, HirId, Node};
31+
use rustc_hir::{self as hir, GenericParamKind, HirId, Node,PreciseCapturingArgKind};
3232
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
3333
use rustc_infer::traits::ObligationCause;
3434
use rustc_middle::hir::nested_filter;
@@ -1791,7 +1791,7 @@ fn opaque_ty_origin<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> hir::OpaqueT
17911791
fn rendered_precise_capturing_args<'tcx>(
17921792
tcx: TyCtxt<'tcx>,
17931793
def_id: LocalDefId,
1794-
) -> Option<&'tcx [Symbol]> {
1794+
) -> Option<&'tcx [PreciseCapturingArgKind<Symbol,Symbol>]> {
17951795
if let Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) =
17961796
tcx.opt_rpitit_info(def_id.to_def_id())
17971797
{
@@ -1800,7 +1800,12 @@ fn rendered_precise_capturing_args<'tcx>(
18001800

18011801
tcx.hir_node_by_def_id(def_id).expect_opaque_ty().bounds.iter().find_map(|bound| match bound {
18021802
hir::GenericBound::Use(args, ..) => {
1803-
Some(&*tcx.arena.alloc_from_iter(args.iter().map(|arg| arg.name())))
1803+
Some(&*tcx.arena.alloc_from_iter(args.iter().map(|arg| match arg {
1804+
PreciseCapturingArgKind::Lifetime(_) => {
1805+
PreciseCapturingArgKind::Lifetime(arg.name())
1806+
}
1807+
PreciseCapturingArgKind::Param(_) => PreciseCapturingArgKind::Param(arg.name()),
1808+
})))
18041809
}
18051810
_ => None,
18061811
})

‎compiler/rustc_interface/src/interface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_parse::parser::attr::AllowLeadingUnsafe;
1818
use rustc_query_impl::QueryCtxt;
1919
use rustc_query_system::query::print_query_stack;
2020
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
21-
use rustc_session::filesearch::{self,sysroot_candidates};
21+
use rustc_session::filesearch::sysroot_candidates;
2222
use rustc_session::parse::ParseSess;
2323
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint};
2424
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs};
@@ -390,7 +390,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
390390

391391
crate::callbacks::setup_callbacks();
392392

393-
let sysroot = filesearch::materialize_sysroot(config.opts.maybe_sysroot.clone());
393+
let sysroot = config.opts.sysroot.clone();
394394
let target = config::build_target_config(&early_dcx, &config.opts.target_triple, &sysroot);
395395
let file_loader = config.file_loader.unwrap_or_else(|| Box::new(RealFileLoader));
396396
let path_mapping = config.opts.file_path_mapping();
@@ -424,7 +424,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
424424
let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
425425

426426
let bundle = match rustc_errors::fluent_bundle(
427-
config.opts.maybe_sysroot.clone(),
427+
config.opts.sysroot.clone(),
428428
sysroot_candidates().to_vec(),
429429
config.opts.unstable_opts.translate_lang.clone(),
430430
config.opts.unstable_opts.translate_additional_ftl.as_deref(),

‎compiler/rustc_interface/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_session::config::{
2121
use rustc_session::lint::Level;
2222
use rustc_session::search_paths::SearchPath;
2323
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
24-
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, build_session, filesearch,getopts};
24+
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, build_session, getopts};
2525
use rustc_span::edition::{DEFAULT_EDITION, Edition};
2626
use rustc_span::source_map::{RealFileLoader, SourceMapInputs};
2727
use rustc_span::{FileName, SourceFileHashAlgorithm, sym};
@@ -41,7 +41,7 @@ where
4141

4242
let matches = optgroups().parse(args).unwrap();
4343
let sessopts = build_session_options(&mut early_dcx, &matches);
44-
let sysroot = filesearch::materialize_sysroot(sessopts.maybe_sysroot.clone());
44+
let sysroot = sessopts.sysroot.clone();
4545
let target =
4646
rustc_session::config::build_target_config(&early_dcx, &sessopts.target_triple, &sysroot);
4747
let hash_kind = sessopts.unstable_opts.src_hash_algorithm(&target);

‎compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_abi::{FieldIdx, ReprOptions, VariantIdx};
1010
use rustc_ast::expand::StrippedCfgItem;
1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_data_structures::svh::Svh;
13+
use rustc_hir::PreciseCapturingArgKind;
1314
use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap};
1415
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIndex, DefPathHash, StableCrateId};
1516
use rustc_hir::definitions::DefKey;
@@ -440,7 +441,7 @@ define_tables! {
440441
coerce_unsized_info: Table<DefIndex, LazyValue<ty::adjustment::CoerceUnsizedInfo>>,
441442
mir_const_qualif: Table<DefIndex, LazyValue<mir::ConstQualifs>>,
442443
rendered_const: Table<DefIndex, LazyValue<String>>,
443-
rendered_precise_capturing_args: Table<DefIndex, LazyArray<Symbol>>,
444+
rendered_precise_capturing_args: Table<DefIndex, LazyArray<PreciseCapturingArgKind<Symbol,Symbol>>>,
444445
asyncness: Table<DefIndex, ty::Asyncness>,
445446
fn_arg_names: Table<DefIndex, LazyArray<Ident>>,
446447
coroutine_kind: Table<DefIndex, hir::CoroutineKind>,

‎compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_hir::def_id::{
2525
CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
2626
};
2727
use rustc_hir::lang_items::{LangItem, LanguageItems};
28-
use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate};
28+
use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, PreciseCapturingArgKind,TraitCandidate};
2929
use rustc_index::IndexVec;
3030
use rustc_lint_defs::LintId;
3131
use rustc_macros::rustc_queries;
@@ -1424,7 +1424,7 @@ rustc_queries! {
14241424
}
14251425

14261426
/// Gets the rendered precise capturing args for an opaque for use in rustdoc.
1427-
query rendered_precise_capturing_args(def_id: DefId) -> Option<&'tcx [Symbol]> {
1427+
query rendered_precise_capturing_args(def_id: DefId) -> Option<&'tcx [PreciseCapturingArgKind<Symbol,Symbol>]> {
14281428
desc { |tcx| "rendering precise capturing args for `{}`", tcx.def_path_str(def_id) }
14291429
separate_provide_extern
14301430
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /