Skip to content

compiler-builtins subtree update #144154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions library/compiler-builtins/.github/workflows/rustc-pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Perform a subtree sync (pull) using the josh-sync tool once every few days (or on demand).
name: rustc-pull

on:
workflow_dispatch:
schedule:
# Run at 04:00 UTC every Monday and Thursday
- cron: '0 4 * * 1,4'

jobs:
pull:
if: github.repository == 'rust-lang/compiler-builtins'
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main
with:
# https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/compiler-builtins.20subtree.20sync.20automation/with/528482375
zulip-stream-id: 219381
zulip-topic: 'compiler-builtins subtree sync automation'
zulip-bot-email: "[email protected]"
pr-base-branch: master
branch-name: rustc-pull
secrets:
zulip-api-token: ${{ secrets.ZULIP_API_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions library/compiler-builtins/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,12 @@ cargo bench --no-default-features \

[`iai-callgrind-runner`]: https://crates.io/crates/iai-callgrind-runner
[Valgrind]: https://valgrind.org/

## Subtree synchronization

`compiler-builtins` is included as a [Josh subtree] in the main compiler
repository (`rust-lang/rust`). You can find a guide on how to create synchronization
(pull and push) PRs at the [`rustc-dev-guide` page].

[Josh subtree]: https://rustc-dev-guide.rust-lang.org/external-repos.html#josh-subtrees
[`rustc-dev-guide` page]: https://rustc-dev-guide.rust-lang.org/external-repos.html#synchronizing-a-josh-subtree
1 change: 0 additions & 1 deletion library/compiler-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resolver = "2"
members = [
"builtins-shim",
"builtins-test",
"crates/josh-sync",
"crates/libm-macros",
"crates/musl-math-sys",
"crates/panic-handler",
Expand Down
4 changes: 2 additions & 2 deletions library/compiler-builtins/builtins-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
# `xoshiro128**` is used for its quality, size, and speed at generating `u32` shift amounts.
rand_xoshiro = "0.7"
# To compare float builtins against
rustc_apfloat = "0.2.2"
rustc_apfloat = "0.2.3"
# Really a dev dependency, but dev dependencies can't be optional
iai-callgrind = { version = "0.14.1", optional = true }
iai-callgrind = { version = "0.15.2", optional = true }

[dependencies.compiler_builtins]
path = "../builtins-shim"
Expand Down
2 changes: 1 addition & 1 deletion library/compiler-builtins/ci/bench-icount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function run_icount_benchmarks() {

iai_args=(
"--home" "$(pwd)/$iai_home"
"--regression=ir=5.0"
"--callgrind-limits=ir=5.0"
"--save-summary"
)

Expand Down
5 changes: 3 additions & 2 deletions library/compiler-builtins/compiler-builtins/src/mem/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// this use. Of course this is not a guarantee that such use will work, it just means that this
// crate doing wrapping pointer arithmetic with a method that must not wrap won't be the problem if
// something does go wrong at runtime.
use core::ffi::c_int;
use core::intrinsics::likely;

const WORD_SIZE: usize = core::mem::size_of::<usize>();
Expand Down Expand Up @@ -384,13 +385,13 @@ pub unsafe fn set_bytes(mut s: *mut u8, c: u8, mut n: usize) {
}

#[inline(always)]
pub unsafe fn compare_bytes(s1: *const u8, s2: *const u8, n: usize) -> i32 {
pub unsafe fn compare_bytes(s1: *const u8, s2: *const u8, n: usize) -> c_int {
let mut i = 0;
while i < n {
let a = *s1.wrapping_add(i);
let b = *s2.wrapping_add(i);
if a != b {
return a as i32 - b as i32;
return c_int::from(a) - c_int::from(b);
}
i += 1;
}
Expand Down
13 changes: 3 additions & 10 deletions library/compiler-builtins/compiler-builtins/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
// FIXME(e2024): this eventually needs to be removed.
#![allow(unsafe_op_in_unsafe_fn)]

#[allow(warnings)]
#[cfg(target_pointer_width = "16")]
type c_int = i16;
#[allow(warnings)]
#[cfg(not(target_pointer_width = "16"))]
type c_int = i32;

// memcpy/memmove/memset have optimized implementations on some architectures
#[cfg_attr(
all(not(feature = "no-asm"), target_arch = "x86_64"),
Expand Down Expand Up @@ -38,18 +31,18 @@ intrinsics! {
}

#[mem_builtin]
pub unsafe extern "C" fn memset(s: *mut u8, c: crate::mem::c_int, n: usize) -> *mut u8 {
pub unsafe extern "C" fn memset(s: *mut u8, c: core::ffi::c_int, n: usize) -> *mut u8 {
impls::set_bytes(s, c as u8, n);
s
}

#[mem_builtin]
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> core::ffi::c_int {
impls::compare_bytes(s1, s2, n)
}

#[mem_builtin]
pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, n: usize) -> core::ffi::c_int {
memcmp(s1, s2, n)
}

Expand Down
8 changes: 0 additions & 8 deletions library/compiler-builtins/crates/josh-sync/Cargo.toml

This file was deleted.

45 changes: 0 additions & 45 deletions library/compiler-builtins/crates/josh-sync/src/main.rs

This file was deleted.

Loading
Loading