Skip to content

Commit 322c659

Browse files
committed
Auto merge of rust-lang#129351 - tgross35:rollup-ae0u4tw, r=tgross35
Rollup of 7 pull requests Successful merges: - rust-lang#128432 (WASI: forbid `unsafe_op_in_unsafe_fn` for `std::{os, sys}`) - rust-lang#128627 (Special case DUMMY_SP to emit line 0/column 0 locations on DWARF platforms.) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation) - rust-lang#129257 (Allow rust staticlib to work with MSVC's /WHOLEARCHIVE) - rust-lang#129264 (Update `library/Cargo.toml` in weekly job) - rust-lang#129284 (rustdoc: animate the `:target` highlight) - rust-lang#129332 (Avoid extra `cast()`s after `CStr::as_ptr()`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 59a74db + 54b3197 commit 322c659

File tree

35 files changed

+215
-130
lines changed

35 files changed

+215
-130
lines changed

.github/workflows/dependencies.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
- name: cargo update
6565
# Remove first line that always just says "Updating crates.io index"
6666
run: cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
67+
- name: cargo update library
68+
run: |
69+
echo -e "\nlibrary dependencies:" >> cargo_update.log
70+
cargo update --manifest-path library/Cargo.toml 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
6771
- name: cargo update rustbook
6872
run: |
6973
echo -e "\nrustbook dependencies:" >> cargo_update.log
@@ -74,6 +78,7 @@ jobs:
7478
name: Cargo-lock
7579
path: |
7680
Cargo.lock
81+
library/Cargo.lock
7782
src/tools/rustbook/Cargo.lock
7883
retention-days: 1
7984
- name: upload cargo-update log artifact for use in PR
@@ -119,7 +124,7 @@ jobs:
119124
git config user.name github-actions
120125
git config user.email github-actions@github.com
121126
git switch --force-create cargo_update
122-
git add ./Cargo.lock ./src/tools/rustbook/Cargo.lock
127+
git add ./Cargo.lock ./library/Cargo.lock ./src/tools/rustbook/Cargo.lock
123128
git commit --no-verify --file=commit.txt
124129
125130
- name: push

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ dependencies = [
195195

196196
[[package]]
197197
name = "ar_archive_writer"
198-
version = "0.4.0"
198+
version = "0.4.2"
199199
source = "registry+https://github.com/rust-lang/crates.io-index"
200-
checksum = "de11a9d32db3327f981143bdf699ade4d637c6887b13b97e6e91a9154666963c"
200+
checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4"
201201
dependencies = [
202202
"object 0.36.3",
203203
]

compiler/rustc_codegen_llvm/src/allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn create_wrapper_function(
149149
}
150150
llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);
151151

152-
let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, c"entry".as_ptr().cast());
152+
let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, c"entry".as_ptr());
153153

154154
let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
155155
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ pub(crate) fn run_pass_manager(
616616
llvm::LLVMRustAddModuleFlagU32(
617617
module.module_llvm.llmod(),
618618
llvm::LLVMModFlagBehavior::Error,
619-
c"LTOPostLink".as_ptr().cast(),
619+
c"LTOPostLink".as_ptr(),
620620
1,
621621
);
622622
}

compiler/rustc_codegen_llvm/src/back/write.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ unsafe fn embed_bitcode(
10311031
let llglobal = llvm::LLVMAddGlobal(
10321032
llmod,
10331033
common::val_ty(llconst),
1034-
c"rustc.embedded.module".as_ptr().cast(),
1034+
c"rustc.embedded.module".as_ptr(),
10351035
);
10361036
llvm::LLVMSetInitializer(llglobal, llconst);
10371037

@@ -1044,7 +1044,7 @@ unsafe fn embed_bitcode(
10441044
let llglobal = llvm::LLVMAddGlobal(
10451045
llmod,
10461046
common::val_ty(llconst),
1047-
c"rustc.embedded.cmdline".as_ptr().cast(),
1047+
c"rustc.embedded.cmdline".as_ptr(),
10481048
);
10491049
llvm::LLVMSetInitializer(llglobal, llconst);
10501050
let section = if is_apple {
@@ -1054,7 +1054,7 @@ unsafe fn embed_bitcode(
10541054
} else {
10551055
c".llvmcmd"
10561056
};
1057-
llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
1057+
llvm::LLVMSetSection(llglobal, section.as_ptr());
10581058
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
10591059
} else {
10601060
// We need custom section flags, so emit module-level inline assembly.
@@ -1107,7 +1107,7 @@ fn create_msvc_imps(
11071107
.collect::<Vec<_>>();
11081108

11091109
for (imp_name, val) in globals {
1110-
let imp = llvm::LLVMAddGlobal(llmod, ptr_ty, imp_name.as_ptr().cast());
1110+
let imp = llvm::LLVMAddGlobal(llmod, ptr_ty, imp_name.as_ptr());
11111111
llvm::LLVMSetInitializer(imp, val);
11121112
llvm::LLVMRustSetLinkage(imp, llvm::Linkage::ExternalLinkage);
11131113
}

compiler/rustc_codegen_llvm/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl<'ll> CodegenCx<'ll, '_> {
525525
let val = llvm::LLVMMetadataAsValue(self.llcx, meta);
526526
llvm::LLVMAddNamedMetadataOperand(
527527
self.llmod,
528-
c"wasm.custom_sections".as_ptr().cast(),
528+
c"wasm.custom_sections".as_ptr(),
529529
val,
530530
);
531531
}

compiler/rustc_codegen_llvm/src/context.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ pub unsafe fn create_module<'ll>(
207207
// If skipping the PLT is enabled, we need to add some module metadata
208208
// to ensure intrinsic calls don't use it.
209209
if !sess.needs_plt() {
210-
let avoid_plt = c"RtLibUseGOT".as_ptr().cast();
210+
let avoid_plt = c"RtLibUseGOT".as_ptr();
211211
unsafe {
212212
llvm::LLVMRustAddModuleFlagU32(llmod, llvm::LLVMModFlagBehavior::Warning, avoid_plt, 1);
213213
}
214214
}
215215

216216
// Enable canonical jump tables if CFI is enabled. (See https://reviews.llvm.org/D65629.)
217217
if sess.is_sanitizer_cfi_canonical_jump_tables_enabled() && sess.is_sanitizer_cfi_enabled() {
218-
let canonical_jump_tables = c"CFI Canonical Jump Tables".as_ptr().cast();
218+
let canonical_jump_tables = c"CFI Canonical Jump Tables".as_ptr();
219219
unsafe {
220220
llvm::LLVMRustAddModuleFlagU32(
221221
llmod,
@@ -228,7 +228,7 @@ pub unsafe fn create_module<'ll>(
228228

229229
// Enable LTO unit splitting if specified or if CFI is enabled. (See https://reviews.llvm.org/D53891.)
230230
if sess.is_split_lto_unit_enabled() || sess.is_sanitizer_cfi_enabled() {
231-
let enable_split_lto_unit = c"EnableSplitLTOUnit".as_ptr().cast();
231+
let enable_split_lto_unit = c"EnableSplitLTOUnit".as_ptr();
232232
unsafe {
233233
llvm::LLVMRustAddModuleFlagU32(
234234
llmod,
@@ -241,7 +241,7 @@ pub unsafe fn create_module<'ll>(
241241

242242
// Add "kcfi" module flag if KCFI is enabled. (See https://reviews.llvm.org/D119296.)
243243
if sess.is_sanitizer_kcfi_enabled() {
244-
let kcfi = c"kcfi".as_ptr().cast();
244+
let kcfi = c"kcfi".as_ptr();
245245
unsafe {
246246
llvm::LLVMRustAddModuleFlagU32(llmod, llvm::LLVMModFlagBehavior::Override, kcfi, 1);
247247
}
@@ -280,26 +280,26 @@ pub unsafe fn create_module<'ll>(
280280
llvm::LLVMRustAddModuleFlagU32(
281281
llmod,
282282
llvm::LLVMModFlagBehavior::Min,
283-
c"branch-target-enforcement".as_ptr().cast(),
283+
c"branch-target-enforcement".as_ptr(),
284284
bti.into(),
285285
);
286286
llvm::LLVMRustAddModuleFlagU32(
287287
llmod,
288288
llvm::LLVMModFlagBehavior::Min,
289-
c"sign-return-address".as_ptr().cast(),
289+
c"sign-return-address".as_ptr(),
290290
pac_ret.is_some().into(),
291291
);
292292
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
293293
llvm::LLVMRustAddModuleFlagU32(
294294
llmod,
295295
llvm::LLVMModFlagBehavior::Min,
296-
c"sign-return-address-all".as_ptr().cast(),
296+
c"sign-return-address-all".as_ptr(),
297297
pac_opts.leaf.into(),
298298
);
299299
llvm::LLVMRustAddModuleFlagU32(
300300
llmod,
301301
llvm::LLVMModFlagBehavior::Min,
302-
c"sign-return-address-with-bkey".as_ptr().cast(),
302+
c"sign-return-address-with-bkey".as_ptr(),
303303
u32::from(pac_opts.key == PAuthKey::B),
304304
);
305305
}
@@ -317,7 +317,7 @@ pub unsafe fn create_module<'ll>(
317317
llvm::LLVMRustAddModuleFlagU32(
318318
llmod,
319319
llvm::LLVMModFlagBehavior::Override,
320-
c"cf-protection-branch".as_ptr().cast(),
320+
c"cf-protection-branch".as_ptr(),
321321
1,
322322
);
323323
}
@@ -327,7 +327,7 @@ pub unsafe fn create_module<'ll>(
327327
llvm::LLVMRustAddModuleFlagU32(
328328
llmod,
329329
llvm::LLVMModFlagBehavior::Override,
330-
c"cf-protection-return".as_ptr().cast(),
330+
c"cf-protection-return".as_ptr(),
331331
1,
332332
);
333333
}
@@ -338,7 +338,7 @@ pub unsafe fn create_module<'ll>(
338338
llvm::LLVMRustAddModuleFlagU32(
339339
llmod,
340340
llvm::LLVMModFlagBehavior::Error,
341-
c"Virtual Function Elim".as_ptr().cast(),
341+
c"Virtual Function Elim".as_ptr(),
342342
1,
343343
);
344344
}

compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
3434
let c_section_var_name = c"__rustc_debug_gdb_scripts_section__";
3535
let section_var_name = c_section_var_name.to_str().unwrap();
3636

37-
let section_var =
38-
unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr().cast()) };
37+
let section_var = unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr()) };
3938

4039
section_var.unwrap_or_else(|| {
4140
let mut section_contents = Vec::new();
@@ -70,7 +69,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
7069
let section_var = cx
7170
.define_global(section_var_name, llvm_type)
7271
.unwrap_or_else(|| bug!("symbol `{}` is already defined", section_var_name));
73-
llvm::LLVMSetSection(section_var, c".debug_gdb_scripts".as_ptr().cast());
72+
llvm::LLVMSetSection(section_var, c".debug_gdb_scripts".as_ptr());
7473
llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
7574
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
7675
llvm::LLVMSetUnnamedAddress(section_var, llvm::UnnamedAddr::Global);

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
952952
producer.as_ptr().cast(),
953953
producer.len(),
954954
tcx.sess.opts.optimize != config::OptLevel::No,
955-
c"".as_ptr().cast(),
955+
c"".as_ptr(),
956956
0,
957957
// NB: this doesn't actually have any perceptible effect, it seems. LLVM will instead
958958
// put the path supplied to `MCSplitDwarfFile` into the debug info of the final

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
109109
llvm::LLVMRustAddModuleFlagU32(
110110
self.llmod,
111111
llvm::LLVMModFlagBehavior::Warning,
112-
c"Dwarf Version".as_ptr().cast(),
112+
c"Dwarf Version".as_ptr(),
113113
dwarf_version,
114114
);
115115
} else {
116116
// Indicate that we want CodeView debug information on MSVC
117117
llvm::LLVMRustAddModuleFlagU32(
118118
self.llmod,
119119
llvm::LLVMModFlagBehavior::Warning,
120-
c"CodeView".as_ptr().cast(),
120+
c"CodeView".as_ptr(),
121121
1,
122122
)
123123
}
@@ -126,7 +126,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
126126
llvm::LLVMRustAddModuleFlagU32(
127127
self.llmod,
128128
llvm::LLVMModFlagBehavior::Warning,
129-
c"Debug Info Version".as_ptr().cast(),
129+
c"Debug Info Version".as_ptr(),
130130
llvm::LLVMRustDebugMetadataVersion(),
131131
);
132132
}
@@ -570,7 +570,17 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
570570
inlined_at: Option<&'ll DILocation>,
571571
span: Span,
572572
) -> &'ll DILocation {
573-
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
573+
// When emitting debugging information, DWARF (i.e. everything but MSVC)
574+
// treats line 0 as a magic value meaning that the code could not be
575+
// attributed to any line in the source. That's also exactly what dummy
576+
// spans are. Make that equivalence here, rather than passing dummy spans
577+
// to lookup_debug_loc, which will return line 1 for them.
578+
let (line, col) = if span.is_dummy() && !self.sess().target.is_like_msvc {
579+
(0, 0)
580+
} else {
581+
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
582+
(line, col)
583+
};
574584

575585
unsafe { llvm::LLVMRustDIBuilderCreateDebugLocation(line, col, scope, inlined_at) }
576586
}

compiler/rustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
ar_archive_writer = "0.4.0"
8+
ar_archive_writer = "0.4.2"
99
arrayvec = { version = "0.7", default-features = false }
1010
bitflags = "2.4.1"
1111
cc = "1.0.90"

compiler/rustc_codegen_ssa/src/back/archive.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ pub trait ArchiveBuilderBuilder {
108108
&exports,
109109
machine,
110110
!sess.target.is_like_msvc,
111-
/*comdat=*/ false,
111+
// Enable compatibility with MSVC's `/WHOLEARCHIVE` flag.
112+
// Without this flag a duplicate symbol error would be emitted
113+
// when linking a rust staticlib using `/WHOLEARCHIVE`.
114+
// See #129020
115+
true,
112116
) {
113117
sess.dcx()
114118
.emit_fatal(ErrorCreatingImportLibrary { lib_name, error: error.to_string() });

library/std/src/os/wasi/fs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! [`std::fs`]: crate::fs
44
5-
#![deny(unsafe_op_in_unsafe_fn)]
65
#![unstable(feature = "wasi_ext", issue = "71213")]
76

87
// Used for `File::read` on intra-doc links

library/std/src/os/wasi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
3131
#![cfg_attr(not(target_env = "p2"), stable(feature = "rust1", since = "1.0.0"))]
3232
#![cfg_attr(target_env = "p2", unstable(feature = "wasip2", issue = "none"))]
33-
#![deny(unsafe_op_in_unsafe_fn)]
33+
#![forbid(unsafe_op_in_unsafe_fn)]
3434
#![doc(cfg(target_os = "wasi"))]
3535

3636
pub mod ffi;

library/std/src/os/wasip2/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
//!
33
//! This module is currently empty, but will be filled over time as wasi-libc support for WASI Preview 2 is stabilized.
44
5+
#![forbid(unsafe_op_in_unsafe_fn)]
56
#![stable(feature = "raw_ext", since = "1.1.0")]

library/std/src/sys/pal/unix/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
116116
if pfd.revents & libc::POLLNVAL == 0 {
117117
continue;
118118
}
119-
if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
119+
if open64(c"/dev/null".as_ptr(), libc::O_RDWR, 0) == -1 {
120120
// If the stream is closed but we failed to reopen it, abort the
121121
// process. Otherwise we wouldn't preserve the safety of
122122
// operations on the corresponding Rust object Stdin, Stdout, or
@@ -147,7 +147,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
147147
use crate::sys::os::errno;
148148
for fd in 0..3 {
149149
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
150-
if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
150+
if open64(c"/dev/null".as_ptr(), libc::O_RDWR, 0) == -1 {
151151
// If the stream is closed but we failed to reopen it, abort the
152152
// process. Otherwise we wouldn't preserve the safety of
153153
// operations on the corresponding Rust object Stdin, Stdout, or

library/std/src/sys/pal/wasi/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use crate::ffi::{CStr, OsStr, OsString};
44
use crate::os::wasi::ffi::OsStrExt;

library/std/src/sys/pal/wasi/env.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_op_in_unsafe_fn)]
2+
13
pub mod os {
24
pub const FAMILY: &str = "";
35
pub const OS: &str = "";

library/std/src/sys/pal/wasi/fd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22
#![allow(dead_code)]
33

44
use super::err2io;

library/std/src/sys/pal/wasi/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use super::fd::WasiFd;
44
use crate::ffi::{CStr, OsStr, OsString};

library/std/src/sys/pal/wasi/helpers.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_op_in_unsafe_fn)]
2+
13
use crate::{io as std_io, mem};
24

35
#[inline]

library/std/src/sys/pal/wasi/io.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use crate::marker::PhantomData;
44
use crate::os::fd::{AsFd, AsRawFd};

library/std/src/sys/pal/wasi/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use super::err2io;
44
use super::fd::WasiFd;

library/std/src/sys/pal/wasi/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use core::slice::memchr;
44

library/std/src/sys/pal/wasi/stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use super::fd::WasiFd;
44
use crate::io::{self, IoSlice, IoSliceMut};

0 commit comments

Comments
 (0)