Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
840ff78
library: optimize truncate method
xtqqczze Mar 28, 2026
dfa6584
ping me for layout invariant changes
RalfJung Oct 18, 2026
0fc7ab9
Update subtree sync docs
Kobzol Oct 19, 2026
4f3cf97
Document updating the `gcc` submodule
Kobzol Oct 19, 2026
5893562
Merge pull request #1007 from Kobzol/sync-docs
antoyo Oct 19, 2026
750d8d3
Remove /tmp workaround now that rustdoc fixed the disk usage issue
antoyo Oct 20, 2026
712fb6a
Merge pull request #1008 from rust-lang/fix/remove-tmp-workaround
antoyo Oct 20, 2026
6e8e699
Use correct alignment for global variables
antoyo Oct 20, 2026
a4f5320
Remove integer packing workaround and replace by the new_array_from_b…
antoyo Oct 20, 2026
33b571c
Merge pull request #1009 from rust-lang/fix/ram-usage
antoyo Oct 21, 2026
0c80051
Merge pull request #1010 from rust-lang/fix/alignment
antoyo Oct 21, 2026
aea90b8
Update dependency jinja2 to v3.1.6 [SECURITY]
renovate-bot Oct 22, 2026
f65e06b
Fix sysroot path for ui tests
GuillaumeGomez Oct 23, 2026
adc83fa
Merge pull request #1013 from GuillaumeGomez/const-str-fixes
GuillaumeGomez Oct 23, 2026
41be5c0
Make const strings readonly and remove the pointer indirection
GuillaumeGomez Oct 21, 2026
2452094
Fix to use target features from a target spec
antoyo Oct 20, 2026
83a5618
Merge pull request #1012 from rust-lang/fix/target-spec-features
antoyo Oct 24, 2026
e034607
specialize str.escape_default().{to_string, collect::<String>}()
the8472 Jul 25, 2026
195573d
partially revert "Optimize escape_string_symbol()"
the8472 Jul 25, 2026
ab2464a
Add regression test for closure input inference through fn pointer args
yashaggarwal85d Oct 24, 2026
cbf6e4a
Do not checkout Cargo for bootstrap tests
Kobzol Oct 24, 2026
59a2d73
Fix path setup for panic messages
GuillaumeGomez Oct 23, 2026
bd872a0
Remove non-failing ui test from the failing ui tests list
GuillaumeGomez Oct 24, 2026
e02f4fd
Prepare for merging from rust-lang/rust
antoyo Oct 24, 2026
5f15550
Merge ref '48f4b05538b8' (nightly-2026-10-24) from rust-lang/rust
antoyo Oct 24, 2026
c91c9a1
Merge pull request #1016 from rust-lang/sync_from_rust_2026_10_24
antoyo Oct 24, 2026
660b88a
Merge pull request #1015 from GuillaumeGomez/const-str-fixes
GuillaumeGomez Oct 24, 2026
ed29f42
Fix skipping library build with `--keep-stage[-std]`
Kobzol Oct 24, 2026
cdcaab7
Update gcc submodule
GuillaumeGomez Oct 24, 2026
bb4f948
cg_llvm: clarify Send / Sync story for modules
hanna-kruppe Oct 24, 2026
127a5d9
rustdoc: Correctly handle reexports when `--document-private-items` i…
GuillaumeGomez Aug 19, 2026
f87a2da
Add rustdoc-html regression test for reexports when `--document-priva…
GuillaumeGomez Aug 19, 2026
072ded8
Add FIXME comments to `from_ascii_bytes_radix_impl`
sorairolake Oct 25, 2026
dfa3e66
Test(lib/sync): Fix `test_rwlock_max_readers` for 32bit architectures
sthibaul Oct 25, 2026
e006e81
Rollup merge of #161362 - GuillaumeGomez:reexports-document-private, …
JonathanBrouwer Oct 25, 2026
5bc414d
Rollup merge of #164764 - sthibaul:rwlock, r=JohnTitor
JonathanBrouwer Oct 25, 2026
882999d
Rollup merge of #164869 - GuillaumeGomez:cg_gcc-subtree-sync, r=Guill…
JonathanBrouwer Oct 25, 2026
9fea3ee
Rollup merge of #157123 - xtqqczze:truncate, r=Mark-Simulacrum
JonathanBrouwer Oct 25, 2026
f627991
Rollup merge of #159916 - the8472:escape-default-to-string, r=Mark-Si…
JonathanBrouwer Oct 25, 2026
3b37988
Rollup merge of #164508 - RalfJung:layout-invariant-ping, r=jieyouxu
JonathanBrouwer Oct 25, 2026
868dd46
Rollup merge of #164758 - renovate-bot:renovate/pypi-jinja2-vulnerabi…
JonathanBrouwer Oct 25, 2026
26ea826
Rollup merge of #164836 - yashaggarwal85d:fix-162109-regression-test,…
JonathanBrouwer Oct 25, 2026
ef64511
Rollup merge of #164857 - Kobzol:bootstrap-no-cargo-checkout, r=jieyouxu
JonathanBrouwer Oct 25, 2026
0cec23e
Rollup merge of #164868 - Kobzol:fix-bootstrap-rebuild, r=jieyouxu
JonathanBrouwer Oct 25, 2026
96341a6
Rollup merge of #164872 - hanna-kruppe:llvm-send-sync, r=bjorn3
JonathanBrouwer Oct 25, 2026
e31c811
Rollup merge of #164881 - sorairolake:nonzero-from-ascii-const-hack, …
JonathanBrouwer Oct 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Code related to parsing literals.

use std::fmt::Write as _;
use std::{ascii, fmt, str};

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

// Don't use escape_default() here, because using it is slower than escaping manually.
for c in suffix.chars() {
match c {
'\t' => escaped.push_str("\\t"),
'\r' => escaped.push_str("\\r"),
'\n' => escaped.push_str("\\n"),
'\\' => escaped.push_str("\\\\"),
'\'' => escaped.push_str("\\'"),
'\"' => escaped.push_str("\\\""),
'\x20'..='\x7e' => escaped.push(c),
c => write!(escaped, "\\u{{{:x}}}", c as u32).unwrap(),
}
}
escaped.extend(suffix.escape_default());

Symbol::intern(&escaped)
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_gcc/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ jobs:
- name: Set env
run: |
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
# /tmp is a small tmpfs, and rustdoc keeps every compiled doctest there until the run ends.
echo "TMPDIR=$RUNNER_TEMP" >> $GITHUB_ENV

#- name: Cache rust repository
## We only clone the rust repository for rustc tests
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_gcc/.github/workflows/rustup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ jobs:
- name: Set env
run: |
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
# /tmp is a small tmpfs, and rustdoc keeps every compiled doctest there until the run ends.
echo "TMPDIR=$RUNNER_TEMP" >> $GITHUB_ENV

- name: Prepare
if: ${{ matrix.run_cargo_tests }}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_gcc/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ dependencies = [

[[package]]
name = "gccjit"
version = "7.2.0"
version = "7.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27cd340f3c265988de3379689cbbd103c25b1f8a3d0cc73f91a49083e899d3e1"
checksum = "ea1820165dfb376a3bbfe8b69628d9e5a851c423e0480a666f71f560e2d0a924"
dependencies = [
"gccjit_sys",
]

[[package]]
name = "gccjit_sys"
version = "4.2.0"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da2d9d74572f004908f17ec1bd0af071e5db63a12c3335c9651a6125593951c6"
checksum = "a6091291fc118448b91df5b662d20564020198fee46d8445a6aa0c25b6b435be"
dependencies = [
"libc",
]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default = ["master"]
[dependencies]
object = { version = "0.39.0", default-features = false, features = ["std", "read"] }
tempfile = "3.20"
gccjit = { version = "7.2.0", features = ["dlopen"] }
gccjit = { version = "7.3.0", features = ["dlopen"] }
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs", branch = "error-dlopen", features = ["dlopen"] }

# Local copy.
Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_codegen_gcc/build_system/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::path::{Path, PathBuf};

use crate::config::{Channel, ConfigInfo};
use crate::utils::{
create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir,
create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, rustc_version_info,
walk_dir,
};

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

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

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

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

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

```bash
git clone git@github.com:tqc/git.git
cd git
git checkout tqc/subtree
make
make install
cd contrib/subtree
make
cp git-subtree ~/bin
```
[rdg-josh]: https://rustc-dev-guide.rust-lang.org/external-repos.html#synchronizing-a-josh-subtree

### Syncing with rust compiler
## Pushing changes to `rust-lang/rust`

Do a sync with this command:

```bash
PATH="$HOME/bin:$PATH" ~/bin/git-subtree push -P compiler/rustc_codegen_gcc/ ../rustc_codegen_gcc/ sync_branch_name
cd ../rustc_codegen_gcc
git checkout master
git pull
git checkout sync_branch_name
git merge master
```

To send the changes to the rust repo:

```bash
cd ../rust
git pull origin master
git checkout -b subtree-update_cg_gcc_YYYY-MM-DD
PATH="$HOME/bin:$PATH" ~/bin/git-subtree pull --prefix=compiler/rustc_codegen_gcc/ https://github.com/rust-lang/rustc_codegen_gcc.git master
# Don't forget to update the `gcc` submodule to the same version as the
# one in `rustc_codegen_gcc/libgccjit.version`.
git push

# Immediately merge the merge commit into cg_gcc to prevent merge conflicts when syncing from rust-lang/rust later.
PATH="$HOME/bin:$PATH" ~/bin/git-subtree push -P compiler/rustc_codegen_gcc/ ../rustc_codegen_gcc/ sync_branch_name
```

FIXME: write a script that does the above.

https://rust-lang.zulipchat.com/#narrow/stream/301329-t-devtools/topic/subtree.20madness/near/258877725
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.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/libgccjit.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
37ea7cd851f04ee6a313c5067c9fde9328f876aa
e1c6e07b095d091177376a163da44039475e05e3
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2026-10-19"
channel = "nightly-2026-10-24"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
17 changes: 2 additions & 15 deletions compiler/rustc_codegen_gcc/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::base;
use crate::context::CodegenCx;
#[cfg(feature = "master")]
use crate::gcc_util::to_gcc_aarch64_extension;
use crate::gcc_util::to_gcc_features;
use crate::gcc_util::{to_gcc_features, to_gcc_target_attribute_feature};

/// Checks if the function `instance` is recursively inline.
/// Returns `false` if a functions is guaranteed to be non-recursive, and `true` if it *might* be recursive.
Expand Down Expand Up @@ -192,20 +192,7 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
}
let target_features = function_features
.iter()
.filter_map(|feature| {
// FIXME(antoyo): support soft-float.
if feature.contains("soft-float") {
return None;
}

if feature.starts_with('-') {
Some(format!("no{}", feature))
} else if let Some(stripped) = feature.strip_prefix('+') {
Some(stripped.to_string())
} else {
Some(feature.to_string())
}
})
.filter_map(|feature| to_gcc_target_attribute_feature(feature))
.collect::<Vec<_>>()
.join(",");
if !target_features.is_empty() {
Expand Down
89 changes: 22 additions & 67 deletions compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
self.const_uint(self.type_u16(), i as u64)
}

fn global_string(&self, string: &str) -> LValue<'gcc> {
// FIXME(antoyo): handle non-null-terminated strings.
let string = self.context.new_string_literal(string);
fn global_const_string(&self, string: &str) -> LValue<'gcc> {
// The bytes of a Rust string are not NUL-terminated and can contain NULs.
let string = bytes_in_context(self, string.as_bytes());
let sym = self.generate_local_symbol_name("str");
let global = self.declare_private_global(&sym, self.val_ty(string));
global.global_set_initializer_rvalue(string);
#[cfg(feature = "master")]
global.global_set_readonly();
global
// FIXME(antoyo): set linkage.
}
Expand Down Expand Up @@ -126,18 +128,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
}
}

/// The element type and element count of the array used to represent a run of `len` constant bytes.
///
/// Larger integers are used where possible: this reduces the number of rvalues, which is a
/// significant memory saving on constant-heavy crates.
fn byte_run_shape<'gcc>(cx: &CodegenCx<'gcc, '_>, len: usize) -> (Type<'gcc>, u64) {
match len % 8 {
0 => (cx.context.new_type::<u64>(), len as u64 / 8),
4 => (cx.context.new_type::<u32>(), len as u64 / 4),
_ => (cx.context.new_type::<u8>(), len as u64),
}
}

/// The type [`bytes_in_context`] gives a run of `len` constant bytes.
///
/// Exposed separately so that the type of a constant allocation can be computed before any of its
Expand All @@ -147,65 +137,30 @@ fn byte_run_shape<'gcc>(cx: &CodegenCx<'gcc, '_>, len: usize) -> (Type<'gcc>, u6
/// Two equal-but-distinct array types would key [`CodegenCx::type_struct`] differently and so
/// produce two distinct anonymous structs, and libgccjit compares struct types by identity.
pub fn bytes_type_in_context<'gcc>(cx: &CodegenCx<'gcc, '_>, len: usize) -> Type<'gcc> {
let (element_type, count) = byte_run_shape(cx, len);
if let Some(&typ) = cx.byte_array_types.borrow().get(&(element_type, count)) {
if let Some(&typ) = cx.byte_array_types.borrow().get(&len) {
return typ;
}
let typ = new_array_type(cx.context, None, element_type, count);
cx.byte_array_types.borrow_mut().insert((element_type, count), typ);
let typ = new_array_type(cx.context, None, cx.type_u8(), len as u64);
cx.byte_array_types.borrow_mut().insert(len, typ);
typ
}

// FIXME(FractalFir): Consider using `global_set_initializer` instead. Before this is done, we need to confirm that
// `global_set_initializer` is more memory efficient than the current solution.
// `global_set_initializer` calls `global_set_initializer_rvalue` under the hood - does it generate an array of rvalues,
// or is it using a more efficient representation?
pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) -> RValue<'gcc> {
let typ = bytes_type_in_context(cx, bytes.len());
let (element_type, _) = byte_run_shape(cx, bytes.len());
let context = &cx.context;
// Since we are representing arbitrary byte runs as integers, we need to follow the target
// endianness.
let endian = cx.sess().target.options.endian;
let elements: Vec<_> = match bytes.len() % 8 {
0 => {
let (arrays, remainder) = bytes.as_chunks::<8>();
debug_assert!(remainder.is_empty());
arrays
.iter()
.map(|&arr| {
context.new_rvalue_from_long(
element_type,
match endian {
rustc_abi::Endian::Little => u64::from_le_bytes(arr) as i64,
rustc_abi::Endian::Big => u64::from_be_bytes(arr) as i64,
},
)
})
.collect()
}
4 => {
let (arrays, remainder) = bytes.as_chunks::<4>();
debug_assert!(remainder.is_empty());
arrays
.iter()
.map(|&arr| {
context.new_rvalue_from_int(
element_type,
match endian {
rustc_abi::Endian::Little => u32::from_le_bytes(arr) as i32,
rustc_abi::Endian::Big => u32::from_be_bytes(arr) as i32,
},
)
})
.collect()
}
_ => bytes
// Raw bytes take far less RAM in libgccjit than one rvalue per array element.
#[cfg(feature = "master")]
{
cx.context.new_array_from_bytes(None, typ, bytes)
}
#[cfg(not(feature = "master"))]
{
let byte_type = cx.type_u8();
let elements: Vec<_> = bytes
.iter()
.map(|&byte| context.new_rvalue_from_int(element_type, byte as i32))
.collect(),
};
context.new_array_constructor(None, typ, &elements)
.map(|&byte| cx.context.new_rvalue_from_int(byte_type, byte as i32))
.collect();
cx.context.new_array_constructor(None, typ, &elements)
}
}

pub fn type_is_pointer(typ: Type<'_>) -> bool {
Expand Down Expand Up @@ -292,7 +247,7 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) {
let mut const_str_cache = self.const_str_cache.borrow_mut();
let str_global = const_str_cache.get(s).copied().unwrap_or_else(|| {
let g = self.global_string(s);
let g = self.global_const_string(s);
const_str_cache.insert(s.to_owned(), g);
g
});
Expand Down
Loading
Loading