Skip to content

Commit 5f39295

Browse files
committed
Auto merge of #164894 - JonathanBrouwer:rollup-fyOlw75, r=JonathanBrouwer
Rollup of 20 pull requests Successful merges: - #160404 (fd-views: AsRef<File>&Co. for BorrowedFd) - #161362 ( rustdoc: Correctly handle reexports when --document-private-items is used) - #163769 (reborrow: Fix various ICEs related to auto reborrowing of user-space types) - #164764 (Test(lib/sync): Fix `test_rwlock_max_readers` for 32bit architectures) - #164860 (std::fs: read interrupted by a signal, read_buf_exact_at reports EOF.) - #164869 (rustc_codegen_gcc subtree update) - #157123 (library: optimize truncate method) - #159916 (Optimize `str.escape_default().to_string()`) - #163510 (process: Improve the output of `Debug` for `ExitStatus` on Unix) - #164508 (ping me for layout invariant changes) - #164758 (Update dependency jinja2 to v3.1.6 [SECURITY]) - #164816 (Take the colon span into account for struct field initializers) - #164836 (Add regression test for #162109) - #164846 (Remove contradictory inequalities from overflow safety docs) - #164857 (Do not checkout Cargo for bootstrap tests) - #164868 (Fix skipping library build with `--keep-stage[-std]`) - #164872 (cg_llvm: clarify Send / Sync story for modules) - #164880 (Add context span showing item that can't be annotated) - #164881 (Add FIXME comments to `from_ascii_bytes_radix_impl`) - #164884 (Windows: bounds-check the reparse point name in `read_link`)
2 parents dc44e7f + d4ca4bf commit 5f39295

211 files changed

Lines changed: 2407 additions & 440 deletions

File tree

Some content is hidden

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

‎compiler/rustc_ast/src/util/literal.rs‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Code related to parsing literals.
22
3-
use std::fmt::Write as _;
43
use std::{ascii, fmt, str};
54

65
use rustc_literal_escaper::{
@@ -38,19 +37,8 @@ pub fn escape_string_symbol(symbol: Symbol) -> Symbol {
3837
let mut escaped = String::with_capacity(s.len() + 1);
3938
escaped.push_str(prefix);
4039

41-
// Don't use escape_default() here, because using it is slower than escaping manually.
42-
for c in suffix.chars() {
43-
match c {
44-
'\t' => escaped.push_str("\\t"),
45-
'\r' => escaped.push_str("\\r"),
46-
'\n' => escaped.push_str("\\n"),
47-
'\\' => escaped.push_str("\\\\"),
48-
'\'' => escaped.push_str("\\'"),
49-
'\"' => escaped.push_str("\\\""),
50-
'\x20'..='\x7e' => escaped.push(c),
51-
c => write!(escaped, "\\u{{{:x}}}", c as u32).unwrap(),
52-
}
53-
}
40+
escaped.extend(suffix.escape_default());
41+
5442
Symbol::intern(&escaped)
5543
}
5644

‎compiler/rustc_attr_parsing/src/diagnostics.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,8 @@ pub(crate) struct InvalidTarget {
13891389
pub attr_span: Span,
13901390
pub name: AttrPath,
13911391
pub target: &'static str,
1392+
#[context]
1393+
pub target_span: Span,
13921394
pub applied: DiagArgValue,
13931395
pub only: &'static str,
13941396
pub attribute_args: String,

‎compiler/rustc_attr_parsing/src/target_checking.rs‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,31 @@ impl<'sess> AttributeParser<'sess> {
131131
let (applied, only) = allowed_targets_applied(allowed_targets, cx.target, cx.features);
132132
let is_diagnostic_attr = cx.attr_path.segments[0] == sym::diagnostic;
133133

134+
let span = if attribute_args.is_empty() {
135+
// Example: for the attribute `#[inline]`, name+attribute_args gives "inline",
136+
// and the path span covers `inline` which is just what we want.
137+
cx.attr_path.span
138+
} else {
139+
// Example 1: for the attribute `#[repr(C)]`, name+attribute_args gives
140+
// "repr(C)", and the inner span covers `repr(C)` which is just what we want.
141+
//
142+
// Example 2: for the attribute `#[repr(C, packed)]`, name+attribute_args gives
143+
// "repr(C)", and the inner span covers `repr(C, packed)` which doesn't match
144+
// exactly but is as close as we can get.
145+
cx.inner_span
146+
};
147+
let target_span = if span.eq_ctxt(cx.target_span) && cx.target != Target::Crate {
148+
cx.target_span.shrink_to_lo()
149+
} else {
150+
span
151+
};
152+
134153
let diag = InvalidTarget {
135-
span: if attribute_args.is_empty() {
136-
// Example: for the attribute `#[inline]`, name+attribute_args gives "inline",
137-
// and the path span covers `inline` which is just what we want.
138-
cx.attr_path.span
139-
} else {
140-
// Example 1: for the attribute `#[repr(C)]`, name+attribute_args gives
141-
// "repr(C)", and the inner span covers `repr(C)` which is just what we want.
142-
//
143-
// Example 2: for the attribute `#[repr(C, packed)]`, name+attribute_args gives
144-
// "repr(C)", and the inner span covers `repr(C, packed)` which doesn't match
145-
// exactly but is as close as we can get.
146-
cx.inner_span
147-
},
154+
span,
148155
attr_span: cx.attr_span,
149156
name: cx.attr_path.clone(),
150157
target: cx.target.plural_name(),
158+
target_span,
151159
only: if only { "only " } else { "" },
152160
applied: DiagArgValue::StrListSepByAnd(applied.into_iter().map(Cow::Owned).collect()),
153161
attribute_args: attribute_args.to_string(),

‎compiler/rustc_codegen_gcc/.github/workflows/ci.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ jobs:
116116
- name: Set env
117117
run: |
118118
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
119-
# /tmp is a small tmpfs, and rustdoc keeps every compiled doctest there until the run ends.
120-
echo "TMPDIR=$RUNNER_TEMP" >> $GITHUB_ENV
121119
122120
#- name: Cache rust repository
123121
## We only clone the rust repository for rustc tests

‎compiler/rustc_codegen_gcc/.github/workflows/rustup.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ jobs:
7777
- name: Set env
7878
run: |
7979
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
80-
# /tmp is a small tmpfs, and rustdoc keeps every compiled doctest there until the run ends.
81-
echo "TMPDIR=$RUNNER_TEMP" >> $GITHUB_ENV
8280
8381
- name: Prepare
8482
if: ${{ matrix.run_cargo_tests }}

‎compiler/rustc_codegen_gcc/Cargo.lock‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ dependencies = [
5656

5757
[[package]]
5858
name = "gccjit"
59-
version = "7.2.0"
59+
version = "7.3.0"
6060
source = "registry+https://github.com/rust-lang/crates.io-index"
61-
checksum = "27cd340f3c265988de3379689cbbd103c25b1f8a3d0cc73f91a49083e899d3e1"
61+
checksum = "ea1820165dfb376a3bbfe8b69628d9e5a851c423e0480a666f71f560e2d0a924"
6262
dependencies = [
6363
"gccjit_sys",
6464
]
6565

6666
[[package]]
6767
name = "gccjit_sys"
68-
version = "4.2.0"
68+
version = "4.3.0"
6969
source = "registry+https://github.com/rust-lang/crates.io-index"
70-
checksum = "da2d9d74572f004908f17ec1bd0af071e5db63a12c3335c9651a6125593951c6"
70+
checksum = "a6091291fc118448b91df5b662d20564020198fee46d8445a6aa0c25b6b435be"
7171
dependencies = [
7272
"libc",
7373
]

‎compiler/rustc_codegen_gcc/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ default = ["master"]
2020
[dependencies]
2121
object = { version = "0.39.0", default-features = false, features = ["std", "read"] }
2222
tempfile = "3.20"
23-
gccjit = { version = "7.2.0", features = ["dlopen"] }
23+
gccjit = { version = "7.3.0", features = ["dlopen"] }
2424
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs", branch = "error-dlopen", features = ["dlopen"] }
2525

2626
# Local copy.

‎compiler/rustc_codegen_gcc/build_system/src/build.rs‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use std::path::{Path, PathBuf};
66

77
use crate::config::{Channel, ConfigInfo};
88
use crate::utils::{
9-
create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir,
9+
create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, rustc_version_info,
10+
walk_dir,
1011
};
1112

1213
#[derive(Default)]
@@ -137,17 +138,16 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
137138
// Builds libs
138139
let mut rustflags = env.get("RUSTFLAGS").cloned().unwrap_or_default();
139140

140-
// Record the sysroot sources under the path the `rust-src` component uses, which is where
141-
// rustc looks for them to turn a sysroot span into `/rustc/$hash`. Without this, ui tests
142-
// print the build path where they expect `$SRC_DIR`.
143-
let sysroot_source_dir = lib_path.join("rustlib/src/rust/library");
141+
// Remap both source spans and embedded panic locations to the standard virtual path.
142+
let sysroot_source_dir = start_dir.join("sysroot_src");
143+
let rustc_commit = rustc_version_info(env.get("RUSTC").map(String::as_str))?
144+
.commit_hash
145+
.ok_or_else(|| "Couldn't retrieve rustc commit hash".to_string())?;
146+
// Cargo passes workspace-relative filenames, including those used by panic locations.
147+
// Also: the `==` is intentional! The first `=` is "FROM" and the second `=` is for "TO".
148+
rustflags.push_str(&format!(" --remap-path-prefix==/rustc/{rustc_commit}/library"));
144149
rustflags.push_str(&format!(
145-
" --remap-path-prefix={library_dir}={sysroot_source_dir}",
146-
library_dir = std::path::absolute(&library_dir)
147-
.map_err(|error| format!(
148-
"Failed to get the absolute path of the sysroot sources: {error:?}"
149-
))?
150-
.display(),
150+
" --remap-path-prefix={sysroot_source_dir}=/rustc/{rustc_commit}",
151151
sysroot_source_dir = std::path::absolute(&sysroot_source_dir)
152152
.map_err(|error| format!(
153153
"Failed to get the absolute path of the sysroot sources: {error:?}"
Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,13 @@
1-
# git subtree sync
1+
# Subtree sync procedure
22

3-
`rustc_codegen_gcc` is a subtree of the rust compiler. As such, it needs to be
4-
synced from time to time to ensure changes that happened on their side are also
5-
included on our side.
3+
`rustc_codegen_gcc` is using [Josh] to perform subtree synces with the `rust-lang/rust` repository.
64

7-
### How to install a forked git-subtree
5+
[Josh]: https://josh-project.dev/docs/intro.html
86

9-
Using git-subtree with `rustc` requires a patched git to make it work.
10-
The PR that is needed is [here](https://github.com/gitgitgadget/git/pull/493).
11-
Use the following instructions to install it:
7+
The procedure for performing subtree synchronizations is documented [here][rdg-josh].
128

13-
```bash
14-
git clone git@github.com:tqc/git.git
15-
cd git
16-
git checkout tqc/subtree
17-
make
18-
make install
19-
cd contrib/subtree
20-
make
21-
cp git-subtree ~/bin
22-
```
9+
[rdg-josh]: https://rustc-dev-guide.rust-lang.org/external-repos.html#synchronizing-a-josh-subtree
2310

24-
### Syncing with rust compiler
11+
## Pushing changes to `rust-lang/rust`
2512

26-
Do a sync with this command:
27-
28-
```bash
29-
PATH="$HOME/bin:$PATH" ~/bin/git-subtree push -P compiler/rustc_codegen_gcc/ ../rustc_codegen_gcc/ sync_branch_name
30-
cd ../rustc_codegen_gcc
31-
git checkout master
32-
git pull
33-
git checkout sync_branch_name
34-
git merge master
35-
```
36-
37-
To send the changes to the rust repo:
38-
39-
```bash
40-
cd ../rust
41-
git pull origin master
42-
git checkout -b subtree-update_cg_gcc_YYYY-MM-DD
43-
PATH="$HOME/bin:$PATH" ~/bin/git-subtree pull --prefix=compiler/rustc_codegen_gcc/ https://github.com/rust-lang/rustc_codegen_gcc.git master
44-
# Don't forget to update the `gcc` submodule to the same version as the
45-
# one in `rustc_codegen_gcc/libgccjit.version`.
46-
git push
47-
48-
# Immediately merge the merge commit into cg_gcc to prevent merge conflicts when syncing from rust-lang/rust later.
49-
PATH="$HOME/bin:$PATH" ~/bin/git-subtree push -P compiler/rustc_codegen_gcc/ ../rustc_codegen_gcc/ sync_branch_name
50-
```
51-
52-
FIXME: write a script that does the above.
53-
54-
https://rust-lang.zulipchat.com/#narrow/stream/301329-t-devtools/topic/subtree.20madness/near/258877725
13+
If the used GCC commit (recorded in `libgccjit.version`) changed in `rustc_codegen_gcc`, then you will have to update the `gcc` submodule in the `rust-lang/rust` repository in the push sync PR. The CI in `rust-lang/rust` should ensure that these two commit references match. You can simply update the `gcc` submodule commit and push it to your push sync PR once it has been created.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
37ea7cd851f04ee6a313c5067c9fde9328f876aa
1+
e1c6e07b095d091177376a163da44039475e05e3

0 commit comments

Comments
 (0)