Skip to content

Commit d85276b

Browse files
committed
Auto merge of rust-lang#148337 - matthiaskrgr:rollup-vojwz0m, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#139310 (add first HelenOS compilation targets) - rust-lang#147161 (implement VecDeque extend_from_within and prepend_from_within) - rust-lang#147622 (`unicode_data` refactors) - rust-lang#147780 (Implement VecDeque::extract_if) - rust-lang#147942 (Enable regression labeling aliases) - rust-lang#147986 (Use fstatat() in DirEntry::metadata on Apple platforms) - rust-lang#148103 (cg_llvm: Pass `debuginfo_compression` through FFI as an enum) - rust-lang#148319 (docs: Fix argument names for `carrying_mul_add`) - rust-lang#148322 (Enable file locking support in illumos) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 17e7324 + eaa283d commit d85276b

File tree

44 files changed

+6069
-1641
lines changed

Some content is hidden

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

44 files changed

+6069
-1641
lines changed

compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl OwnedTargetMachine {
3636
use_init_array: bool,
3737
split_dwarf_file: &CStr,
3838
output_obj_file: &CStr,
39-
debug_info_compression: &CStr,
39+
debug_info_compression: llvm::CompressionKind,
4040
use_emulated_tls: bool,
4141
use_wasm_eh: bool,
4242
) -> Result<Self, LlvmError<'static>> {
@@ -62,7 +62,7 @@ impl OwnedTargetMachine {
6262
use_init_array,
6363
split_dwarf_file.as_ptr(),
6464
output_obj_file.as_ptr(),
65-
debug_info_compression.as_ptr(),
65+
debug_info_compression,
6666
use_emulated_tls,
6767
use_wasm_eh,
6868
)

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ use std::sync::Arc;
66
use std::{fs, slice, str};
77

88
use libc::{c_char, c_int, c_void, size_t};
9-
use llvm::{
10-
LLVMRustLLVMHasZlibCompressionForDebugSymbols, LLVMRustLLVMHasZstdCompressionForDebugSymbols,
11-
};
129
use rustc_codegen_ssa::back::link::ensure_removed;
1310
use rustc_codegen_ssa::back::versioned_llvm_target;
1411
use rustc_codegen_ssa::back::write::{
@@ -252,21 +249,25 @@ pub(crate) fn target_machine_factory(
252249

253250
let use_emulated_tls = matches!(sess.tls_model(), TlsModel::Emulated);
254251

255-
let debuginfo_compression = sess.opts.debuginfo_compression.to_string();
256-
match sess.opts.debuginfo_compression {
257-
rustc_session::config::DebugInfoCompression::Zlib => {
258-
if !unsafe { LLVMRustLLVMHasZlibCompressionForDebugSymbols() } {
252+
let debuginfo_compression = match sess.opts.debuginfo_compression {
253+
config::DebugInfoCompression::None => llvm::CompressionKind::None,
254+
config::DebugInfoCompression::Zlib => {
255+
if llvm::LLVMRustLLVMHasZlibCompression() {
256+
llvm::CompressionKind::Zlib
257+
} else {
259258
sess.dcx().emit_warn(UnknownCompression { algorithm: "zlib" });
259+
llvm::CompressionKind::None
260260
}
261261
}
262-
rustc_session::config::DebugInfoCompression::Zstd => {
263-
if !unsafe { LLVMRustLLVMHasZstdCompressionForDebugSymbols() } {
262+
config::DebugInfoCompression::Zstd => {
263+
if llvm::LLVMRustLLVMHasZstdCompression() {
264+
llvm::CompressionKind::Zstd
265+
} else {
264266
sess.dcx().emit_warn(UnknownCompression { algorithm: "zstd" });
267+
llvm::CompressionKind::None
265268
}
266269
}
267-
rustc_session::config::DebugInfoCompression::None => {}
268270
};
269-
let debuginfo_compression = SmallCStr::new(&debuginfo_compression);
270271

271272
let file_name_display_preference =
272273
sess.filename_display_preference(RemapPathScopeComponents::DEBUGINFO);
@@ -310,7 +311,7 @@ pub(crate) fn target_machine_factory(
310311
use_init_array,
311312
&split_dwarf_file,
312313
&output_obj_file,
313-
&debuginfo_compression,
314+
debuginfo_compression,
314315
use_emulated_tls,
315316
use_wasm_eh,
316317
)

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,15 @@ pub(crate) enum Opcode {
678678
CatchSwitch = 65,
679679
}
680680

681+
/// Must match the layout of `LLVMRustCompressionKind`.
682+
#[derive(Copy, Clone)]
683+
#[repr(C)]
684+
pub(crate) enum CompressionKind {
685+
None = 0,
686+
Zlib = 1,
687+
Zstd = 2,
688+
}
689+
681690
unsafe extern "C" {
682691
type Opaque;
683692
}
@@ -2329,7 +2338,7 @@ unsafe extern "C" {
23292338
UseInitArray: bool,
23302339
SplitDwarfFile: *const c_char,
23312340
OutputObjFile: *const c_char,
2332-
DebugInfoCompression: *const c_char,
2341+
DebugInfoCompression: CompressionKind,
23332342
UseEmulatedTls: bool,
23342343
UseWasmEH: bool,
23352344
) -> *mut TargetMachine;
@@ -2517,9 +2526,8 @@ unsafe extern "C" {
25172526

25182527
pub(crate) fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
25192528

2520-
pub(crate) fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool;
2521-
2522-
pub(crate) fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool;
2529+
pub(crate) safe fn LLVMRustLLVMHasZlibCompression() -> bool;
2530+
pub(crate) safe fn LLVMRustLLVMHasZstdCompression() -> bool;
25232531

25242532
pub(crate) fn LLVMRustGetSymbols(
25252533
buf_ptr: *const u8,

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,31 @@ static FloatABI::ABIType fromRust(LLVMRustFloatABI RustFloatAbi) {
224224
report_fatal_error("Bad FloatABI.");
225225
}
226226

227+
// Must match the layout of `rustc_codegen_llvm::llvm::ffi::CompressionKind`.
228+
enum class LLVMRustCompressionKind {
229+
None = 0,
230+
Zlib = 1,
231+
Zstd = 2,
232+
};
233+
234+
static llvm::DebugCompressionType fromRust(LLVMRustCompressionKind Kind) {
235+
switch (Kind) {
236+
case LLVMRustCompressionKind::None:
237+
return llvm::DebugCompressionType::None;
238+
case LLVMRustCompressionKind::Zlib:
239+
if (!llvm::compression::zlib::isAvailable()) {
240+
report_fatal_error("LLVMRustCompressionKind::Zlib not available");
241+
}
242+
return llvm::DebugCompressionType::Zlib;
243+
case LLVMRustCompressionKind::Zstd:
244+
if (!llvm::compression::zstd::isAvailable()) {
245+
report_fatal_error("LLVMRustCompressionKind::Zstd not available");
246+
}
247+
return llvm::DebugCompressionType::Zstd;
248+
}
249+
report_fatal_error("bad LLVMRustCompressionKind");
250+
}
251+
227252
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
228253
RustStringRef OutStr) {
229254
ArrayRef<SubtargetSubTypeKV> CPUTable =
@@ -271,7 +296,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
271296
bool TrapUnreachable, bool Singlethread, bool VerboseAsm,
272297
bool EmitStackSizeSection, bool RelaxELFRelocations, bool UseInitArray,
273298
const char *SplitDwarfFile, const char *OutputObjFile,
274-
const char *DebugInfoCompression, bool UseEmulatedTls, bool UseWasmEH) {
299+
LLVMRustCompressionKind DebugInfoCompression, bool UseEmulatedTls,
300+
bool UseWasmEH) {
275301

276302
auto OptLevel = fromRust(RustOptLevel);
277303
auto RM = fromRust(RustReloc);
@@ -307,16 +333,10 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
307333
if (OutputObjFile) {
308334
Options.ObjectFilenameForDebug = OutputObjFile;
309335
}
310-
if (!strcmp("zlib", DebugInfoCompression) &&
311-
llvm::compression::zlib::isAvailable()) {
312-
Options.MCOptions.CompressDebugSections = DebugCompressionType::Zlib;
313-
} else if (!strcmp("zstd", DebugInfoCompression) &&
314-
llvm::compression::zstd::isAvailable()) {
315-
Options.MCOptions.CompressDebugSections = DebugCompressionType::Zstd;
316-
} else if (!strcmp("none", DebugInfoCompression)) {
317-
Options.MCOptions.CompressDebugSections = DebugCompressionType::None;
318-
}
319-
336+
// To avoid fatal errors, make sure the Rust-side code only passes a
337+
// compression kind that is known to be supported by this build of LLVM, via
338+
// `LLVMRustLLVMHasZlibCompression` and `LLVMRustLLVMHasZstdCompression`.
339+
Options.MCOptions.CompressDebugSections = fromRust(DebugInfoCompression);
320340
Options.MCOptions.X86RelaxRelocations = RelaxELFRelocations;
321341
Options.UseInitArray = UseInitArray;
322342
Options.EmulatedTLS = UseEmulatedTls;

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,11 +1645,11 @@ extern "C" bool LLVMRustIsNonGVFunctionPointerTy(LLVMValueRef V) {
16451645
return false;
16461646
}
16471647

1648-
extern "C" bool LLVMRustLLVMHasZlibCompressionForDebugSymbols() {
1648+
extern "C" bool LLVMRustLLVMHasZlibCompression() {
16491649
return llvm::compression::zlib::isAvailable();
16501650
}
16511651

1652-
extern "C" bool LLVMRustLLVMHasZstdCompressionForDebugSymbols() {
1652+
extern "C" bool LLVMRustLLVMHasZstdCompression() {
16531653
return llvm::compression::zstd::isAvailable();
16541654
}
16551655

compiler/rustc_session/src/config.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -583,17 +583,6 @@ pub enum DebugInfoCompression {
583583
Zstd,
584584
}
585585

586-
impl ToString for DebugInfoCompression {
587-
fn to_string(&self) -> String {
588-
match self {
589-
DebugInfoCompression::None => "none",
590-
DebugInfoCompression::Zlib => "zlib",
591-
DebugInfoCompression::Zstd => "zstd",
592-
}
593-
.to_owned()
594-
}
595-
}
596-
597586
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
598587
pub enum MirStripDebugInfo {
599588
None,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{PanicStrategy, RelroLevel, StackProbeType, TargetOptions};
2+
3+
pub(crate) fn opts() -> TargetOptions {
4+
TargetOptions {
5+
os: "helenos".into(),
6+
7+
dynamic_linking: true,
8+
// we need the linker to keep libgcc and friends
9+
no_default_libraries: false,
10+
has_rpath: true,
11+
relro_level: RelroLevel::Full,
12+
panic_strategy: PanicStrategy::Abort,
13+
stack_probes: StackProbeType::Inline,
14+
15+
..Default::default()
16+
}
17+
}

compiler/rustc_target/src/spec/base/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub(crate) mod dragonfly;
88
pub(crate) mod freebsd;
99
pub(crate) mod fuchsia;
1010
pub(crate) mod haiku;
11+
pub(crate) mod helenos;
1112
pub(crate) mod hermit;
1213
pub(crate) mod hurd;
1314
pub(crate) mod hurd_gnu;

compiler/rustc_target/src/spec/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,12 @@ supported_targets! {
15341534
("i686-unknown-haiku", i686_unknown_haiku),
15351535
("x86_64-unknown-haiku", x86_64_unknown_haiku),
15361536

1537+
("aarch64-unknown-helenos", aarch64_unknown_helenos),
1538+
("i686-unknown-helenos", i686_unknown_helenos),
1539+
("powerpc-unknown-helenos", powerpc_unknown_helenos),
1540+
("sparc64-unknown-helenos", sparc64_unknown_helenos),
1541+
("x86_64-unknown-helenos", x86_64_unknown_helenos),
1542+
15371543
("i686-unknown-hurd-gnu", i686_unknown_hurd_gnu),
15381544
("x86_64-unknown-hurd-gnu", x86_64_unknown_hurd_gnu),
15391545

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use crate::spec::{Target, base};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = base::helenos::opts();
5+
base.max_atomic_width = Some(128);
6+
base.features = "+v8a".into();
7+
base.linker = Some("aarch64-helenos-gcc".into());
8+
9+
Target {
10+
llvm_target: "aarch64-unknown-helenos".into(),
11+
metadata: crate::spec::TargetMetadata {
12+
description: Some("ARM64 HelenOS".into()),
13+
tier: Some(3),
14+
host_tools: Some(false),
15+
std: Some(true),
16+
},
17+
pointer_width: 64,
18+
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
19+
arch: "aarch64".into(),
20+
options: base,
21+
}
22+
}

0 commit comments

Comments
 (0)