Skip to content

Commit 987ea16

Browse files
committed
Auto merge of #146462 - Zalathar:rollup-qhce3w5, r=Zalathar
Rollup of 16 pull requests Successful merges: - #144549 (match clang's `va_arg` assembly on arm targets) - #145660 (initial implementation of the darwin_objc unstable feature) - #145895 (thread parking: fix docs and examples) - #146308 (support integer literals in `${concat()}`) - #146323 (check before test for hardware capabilites in bits 32~63 of usize) - #146332 (tidy: make behavior of extra-checks more uniform) - #146374 (Update `browser-ui-test` version to `0.22.2`) - #146413 (Improve suggestion in case a bare URL is surrounded by brackets) - #146426 (Bump miow to 0.60.1) - #146432 (Implement `Socket::take_error` for Hermit) - #146433 (rwlock tests: fix miri macos test regression) - #146435 (Change the default value of `gcc.download-ci-gcc` to `true`) - #146439 (fix cfg for poison test macro) - #146448 ([rustdoc] Correctly handle literal search on paths) - #146449 (Fix `libgccjit` symlink when we build GCC locally) - #146455 (test: remove an outdated normalization for rustc versions) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8e2ed71 + 111079b commit 987ea16

File tree

77 files changed

+1888
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1888
-215
lines changed

Cargo.lock

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,11 +2347,11 @@ dependencies = [
23472347

23482348
[[package]]
23492349
name = "miow"
2350-
version = "0.6.0"
2350+
version = "0.6.1"
23512351
source = "registry+https://github.com/rust-lang/crates.io-index"
2352-
checksum = "359f76430b20a79f9e20e115b3428614e654f04fab314482fc0fda0ebd3c6044"
2352+
checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08"
23532353
dependencies = [
2354-
"windows-sys 0.48.0",
2354+
"windows-sys 0.60.2",
23552355
]
23562356

23572357
[[package]]
@@ -6314,15 +6314,6 @@ dependencies = [
63146314
"windows-link",
63156315
]
63166316

6317-
[[package]]
6318-
name = "windows-sys"
6319-
version = "0.48.0"
6320-
source = "registry+https://github.com/rust-lang/crates.io-index"
6321-
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
6322-
dependencies = [
6323-
"windows-targets 0.48.5",
6324-
]
6325-
63266317
[[package]]
63276318
name = "windows-sys"
63286319
version = "0.52.0"
@@ -6350,21 +6341,6 @@ dependencies = [
63506341
"windows-targets 0.53.3",
63516342
]
63526343

6353-
[[package]]
6354-
name = "windows-targets"
6355-
version = "0.48.5"
6356-
source = "registry+https://github.com/rust-lang/crates.io-index"
6357-
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
6358-
dependencies = [
6359-
"windows_aarch64_gnullvm 0.48.5",
6360-
"windows_aarch64_msvc 0.48.5",
6361-
"windows_i686_gnu 0.48.5",
6362-
"windows_i686_msvc 0.48.5",
6363-
"windows_x86_64_gnu 0.48.5",
6364-
"windows_x86_64_gnullvm 0.48.5",
6365-
"windows_x86_64_msvc 0.48.5",
6366-
]
6367-
63686344
[[package]]
63696345
name = "windows-targets"
63706346
version = "0.52.6"
@@ -6407,12 +6383,6 @@ dependencies = [
64076383
"windows-link",
64086384
]
64096385

6410-
[[package]]
6411-
name = "windows_aarch64_gnullvm"
6412-
version = "0.48.5"
6413-
source = "registry+https://github.com/rust-lang/crates.io-index"
6414-
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
6415-
64166386
[[package]]
64176387
name = "windows_aarch64_gnullvm"
64186388
version = "0.52.6"
@@ -6425,12 +6395,6 @@ version = "0.53.0"
64256395
source = "registry+https://github.com/rust-lang/crates.io-index"
64266396
checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764"
64276397

6428-
[[package]]
6429-
name = "windows_aarch64_msvc"
6430-
version = "0.48.5"
6431-
source = "registry+https://github.com/rust-lang/crates.io-index"
6432-
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
6433-
64346398
[[package]]
64356399
name = "windows_aarch64_msvc"
64366400
version = "0.52.6"
@@ -6443,12 +6407,6 @@ version = "0.53.0"
64436407
source = "registry+https://github.com/rust-lang/crates.io-index"
64446408
checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c"
64456409

6446-
[[package]]
6447-
name = "windows_i686_gnu"
6448-
version = "0.48.5"
6449-
source = "registry+https://github.com/rust-lang/crates.io-index"
6450-
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
6451-
64526410
[[package]]
64536411
name = "windows_i686_gnu"
64546412
version = "0.52.6"
@@ -6473,12 +6431,6 @@ version = "0.53.0"
64736431
source = "registry+https://github.com/rust-lang/crates.io-index"
64746432
checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11"
64756433

6476-
[[package]]
6477-
name = "windows_i686_msvc"
6478-
version = "0.48.5"
6479-
source = "registry+https://github.com/rust-lang/crates.io-index"
6480-
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
6481-
64826434
[[package]]
64836435
name = "windows_i686_msvc"
64846436
version = "0.52.6"
@@ -6491,12 +6443,6 @@ version = "0.53.0"
64916443
source = "registry+https://github.com/rust-lang/crates.io-index"
64926444
checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d"
64936445

6494-
[[package]]
6495-
name = "windows_x86_64_gnu"
6496-
version = "0.48.5"
6497-
source = "registry+https://github.com/rust-lang/crates.io-index"
6498-
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
6499-
65006446
[[package]]
65016447
name = "windows_x86_64_gnu"
65026448
version = "0.52.6"
@@ -6509,12 +6455,6 @@ version = "0.53.0"
65096455
source = "registry+https://github.com/rust-lang/crates.io-index"
65106456
checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba"
65116457

6512-
[[package]]
6513-
name = "windows_x86_64_gnullvm"
6514-
version = "0.48.5"
6515-
source = "registry+https://github.com/rust-lang/crates.io-index"
6516-
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
6517-
65186458
[[package]]
65196459
name = "windows_x86_64_gnullvm"
65206460
version = "0.52.6"
@@ -6527,12 +6467,6 @@ version = "0.53.0"
65276467
source = "registry+https://github.com/rust-lang/crates.io-index"
65286468
checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57"
65296469

6530-
[[package]]
6531-
name = "windows_x86_64_msvc"
6532-
version = "0.48.5"
6533-
source = "registry+https://github.com/rust-lang/crates.io-index"
6534-
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
6535-
65366470
[[package]]
65376471
name = "windows_x86_64_msvc"
65386472
version = "0.52.6"

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ attr_parsing_null_on_export = `export_name` may not contain null characters
122122
123123
attr_parsing_null_on_link_section = `link_section` may not contain null characters
124124
125+
attr_parsing_null_on_objc_class = `objc::class!` may not contain null characters
126+
127+
attr_parsing_null_on_objc_selector = `objc::selector!` may not contain null characters
128+
129+
attr_parsing_objc_class_expected_string_literal = `objc::class!` expected a string literal
130+
131+
attr_parsing_objc_selector_expected_string_literal = `objc::selector!` expected a string literal
132+
125133
attr_parsing_repr_ident =
126134
meta item in `repr` must be an identifier
127135

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use rustc_hir::attrs::{CoverageAttrKind, OptimizeAttr, SanitizerSet, UsedBy};
22
use rustc_session::parse::feature_err;
33

44
use super::prelude::*;
5-
use crate::session_diagnostics::{NakedFunctionIncompatibleAttribute, NullOnExport};
5+
use crate::session_diagnostics::{
6+
NakedFunctionIncompatibleAttribute, NullOnExport, NullOnObjcClass, NullOnObjcSelector,
7+
ObjcClassExpectedStringLiteral, ObjcSelectorExpectedStringLiteral,
8+
};
69

710
pub(crate) struct OptimizeParser;
811

@@ -150,6 +153,70 @@ impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
150153
}
151154
}
152155

156+
pub(crate) struct ObjcClassParser;
157+
158+
impl<S: Stage> SingleAttributeParser<S> for ObjcClassParser {
159+
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_class];
160+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
161+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
162+
const ALLOWED_TARGETS: AllowedTargets =
163+
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
164+
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "ClassName");
165+
166+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
167+
let Some(nv) = args.name_value() else {
168+
cx.expected_name_value(cx.attr_span, None);
169+
return None;
170+
};
171+
let Some(classname) = nv.value_as_str() else {
172+
// `#[rustc_objc_class = ...]` is expected to be used as an implementatioin detail
173+
// inside a standard library macro, but `cx.expected_string_literal` exposes too much.
174+
// Use a custom error message instead.
175+
cx.emit_err(ObjcClassExpectedStringLiteral { span: nv.value_span });
176+
return None;
177+
};
178+
if classname.as_str().contains('\0') {
179+
// `#[rustc_objc_class = ...]` will be converted to a null-terminated string,
180+
// so it may not contain any null characters.
181+
cx.emit_err(NullOnObjcClass { span: nv.value_span });
182+
return None;
183+
}
184+
Some(AttributeKind::ObjcClass { classname, span: cx.attr_span })
185+
}
186+
}
187+
188+
pub(crate) struct ObjcSelectorParser;
189+
190+
impl<S: Stage> SingleAttributeParser<S> for ObjcSelectorParser {
191+
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_selector];
192+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
193+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
194+
const ALLOWED_TARGETS: AllowedTargets =
195+
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
196+
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "methodName");
197+
198+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
199+
let Some(nv) = args.name_value() else {
200+
cx.expected_name_value(cx.attr_span, None);
201+
return None;
202+
};
203+
let Some(methname) = nv.value_as_str() else {
204+
// `#[rustc_objc_selector = ...]` is expected to be used as an implementatioin detail
205+
// inside a standard library macro, but `cx.expected_string_literal` exposes too much.
206+
// Use a custom error message instead.
207+
cx.emit_err(ObjcSelectorExpectedStringLiteral { span: nv.value_span });
208+
return None;
209+
};
210+
if methname.as_str().contains('\0') {
211+
// `#[rustc_objc_selector = ...]` will be converted to a null-terminated string,
212+
// so it may not contain any null characters.
213+
cx.emit_err(NullOnObjcSelector { span: nv.value_span });
214+
return None;
215+
}
216+
Some(AttributeKind::ObjcSelector { methname, span: cx.attr_span })
217+
}
218+
}
219+
153220
#[derive(Default)]
154221
pub(crate) struct NakedParser {
155222
span: Option<Span>,

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use crate::attributes::allow_unstable::{
2020
use crate::attributes::body::CoroutineParser;
2121
use crate::attributes::codegen_attrs::{
2222
ColdParser, CoverageParser, ExportNameParser, ForceTargetFeatureParser, NakedParser,
23-
NoMangleParser, OptimizeParser, SanitizeParser, TargetFeatureParser, TrackCallerParser,
24-
UsedParser,
23+
NoMangleParser, ObjcClassParser, ObjcSelectorParser, OptimizeParser, SanitizeParser,
24+
TargetFeatureParser, TrackCallerParser, UsedParser,
2525
};
2626
use crate::attributes::confusables::ConfusablesParser;
2727
use crate::attributes::crate_level::{
@@ -187,6 +187,8 @@ attribute_parsers!(
187187
Single<LinkageParser>,
188188
Single<MoveSizeLimitParser>,
189189
Single<MustUseParser>,
190+
Single<ObjcClassParser>,
191+
Single<ObjcSelectorParser>,
190192
Single<OptimizeParser>,
191193
Single<PathAttributeParser>,
192194
Single<PatternComplexityLimitParser>,

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,34 @@ pub(crate) struct NullOnLinkSection {
459459
pub span: Span,
460460
}
461461

462+
#[derive(Diagnostic)]
463+
#[diag(attr_parsing_null_on_objc_class)]
464+
pub(crate) struct NullOnObjcClass {
465+
#[primary_span]
466+
pub span: Span,
467+
}
468+
469+
#[derive(Diagnostic)]
470+
#[diag(attr_parsing_null_on_objc_selector)]
471+
pub(crate) struct NullOnObjcSelector {
472+
#[primary_span]
473+
pub span: Span,
474+
}
475+
476+
#[derive(Diagnostic)]
477+
#[diag(attr_parsing_objc_class_expected_string_literal)]
478+
pub(crate) struct ObjcClassExpectedStringLiteral {
479+
#[primary_span]
480+
pub span: Span,
481+
}
482+
483+
#[derive(Diagnostic)]
484+
#[diag(attr_parsing_objc_selector_expected_string_literal)]
485+
pub(crate) struct ObjcSelectorExpectedStringLiteral {
486+
#[primary_span]
487+
pub span: Span,
488+
}
489+
462490
#[derive(Diagnostic)]
463491
#[diag(attr_parsing_stability_outside_std, code = E0734)]
464492
pub(crate) struct StabilityOutsideStd {

compiler/rustc_codegen_llvm/src/base.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,36 @@ pub(crate) fn compile_codegen_unit(
109109
attributes::apply_to_llfn(entry, llvm::AttributePlace::Function, &attrs);
110110
}
111111

112+
// Define Objective-C module info and module flags. Note, the module info will
113+
// also be added to the `llvm.compiler.used` variable, created later.
114+
//
115+
// These are only necessary when we need the linker to do its Objective-C-specific
116+
// magic. We could theoretically do it unconditionally, but at a slight cost to linker
117+
// performance in the common case where it's unnecessary.
118+
if !cx.objc_classrefs.borrow().is_empty() || !cx.objc_selrefs.borrow().is_empty() {
119+
if cx.objc_abi_version() == 1 {
120+
cx.define_objc_module_info();
121+
}
122+
cx.add_objc_module_flags();
123+
}
124+
112125
// Finalize code coverage by injecting the coverage map. Note, the coverage map will
113126
// also be added to the `llvm.compiler.used` variable, created next.
114127
if cx.sess().instrument_coverage() {
115128
cx.coverageinfo_finalize();
116129
}
117130

118-
// Create the llvm.used and llvm.compiler.used variables.
131+
// Create the llvm.used variable.
119132
if !cx.used_statics.is_empty() {
120133
cx.create_used_variable_impl(c"llvm.used", &cx.used_statics);
121134
}
122-
if !cx.compiler_used_statics.is_empty() {
123-
cx.create_used_variable_impl(c"llvm.compiler.used", &cx.compiler_used_statics);
135+
136+
// Create the llvm.compiler.used variable.
137+
{
138+
let compiler_used_statics = cx.compiler_used_statics.borrow();
139+
if !compiler_used_statics.is_empty() {
140+
cx.create_used_variable_impl(c"llvm.compiler.used", &compiler_used_statics);
141+
}
124142
}
125143

126144
// Run replace-all-uses-with for statics that need it. This must

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
108108
bytes_in_context(self.llcx(), bytes)
109109
}
110110

111+
pub(crate) fn null_terminate_const_bytes(&self, bytes: &[u8]) -> &'ll Value {
112+
null_terminate_bytes_in_context(self.llcx(), bytes)
113+
}
114+
111115
pub(crate) fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
112116
unsafe {
113117
let idx = c_uint::try_from(idx).expect("LLVMGetAggregateElement index overflow");
@@ -381,6 +385,16 @@ pub(crate) fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> &
381385
}
382386
}
383387

388+
pub(crate) fn null_terminate_bytes_in_context<'ll>(
389+
llcx: &'ll llvm::Context,
390+
bytes: &[u8],
391+
) -> &'ll Value {
392+
unsafe {
393+
let ptr = bytes.as_ptr() as *const c_char;
394+
llvm::LLVMConstStringInContext2(llcx, ptr, bytes.len(), FALSE)
395+
}
396+
}
397+
384398
pub(crate) fn named_struct<'ll>(ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
385399
let len = c_uint::try_from(elts.len()).expect("LLVMConstStructInContext elements len overflow");
386400
unsafe { llvm::LLVMConstNamedStruct(ty, elts.as_ptr(), len) }

0 commit comments

Comments
 (0)