Skip to content

Commit 93b5b1b

Browse files
committed
Merge branch 'master' into sync_from_rust_2025_11_01
2 parents 0f5c80a + e7b5847 commit 93b5b1b

31 files changed

+480
-320
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
- name: Build
6363
run: |
6464
./y.sh prepare --only-libcore
65-
EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot
65+
./y.sh build --sysroot --release --release-sysroot
6666
./y.sh test --cargo-tests
6767
./y.sh clean all
6868
@@ -72,26 +72,36 @@ jobs:
7272
git config --global user.name "User"
7373
./y.sh prepare
7474
75-
- name: Add more failing tests because of undefined symbol errors (FIXME)
76-
run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt
77-
7875
- name: Run tests
7976
run: |
8077
# FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros.
81-
# FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode.
82-
printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml
83-
EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }}
78+
CG_RUSTFLAGS="-Cembed-bitcode=yes" ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }}
8479
85-
- name: Run y.sh cargo build
80+
- name: LTO test
8681
run: |
87-
EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml
82+
CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml
8883
call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||:
8984
if [ $call_found -gt 0 ]; then
9085
echo "ERROR: call my_func found in asm"
9186
echo "Test is done with LTO enabled, hence inlining should occur across crates"
9287
exit 1
9388
fi
9489
90+
- name: Cross-language LTO test
91+
run: |
92+
pushd tests/cross_lang_lto
93+
gcc -c -flto add.c -masm=intel -fPIC -O3
94+
ar rcs libadd.a add.o
95+
popd
96+
97+
CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml
98+
call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||:
99+
if [ $call_found -gt 0 ]; then
100+
echo "ERROR: call my_add found in asm"
101+
echo "Test is done with cross-language LTO enabled, hence inlining should occur across object files"
102+
exit 1
103+
fi
104+
95105
# Summary job for the merge queue.
96106
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
97107
success_release:

.github/workflows/stdarch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
# TODO: remove when we have binutils version 2.43 in the repo.
4242
- name: Install more recent binutils
4343
run: |
44-
echo "deb http://archive.ubuntu.com/ubuntu oracular main universe" | sudo tee /etc/apt/sources.list.d/oracular-copies.list
44+
echo "deb http://archive.ubuntu.com/ubuntu plucky main universe" | sudo tee /etc/apt/sources.list.d/plucky-copies.list
4545
sudo apt-get update
4646
sudo apt-get install binutils
4747

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 = "2.9.0"
59+
version = "2.10.0"
6060
source = "registry+https://github.com/rust-lang/crates.io-index"
61-
checksum = "4a0e310ef75f396cd11b2443b353d55376656ca92c13cba36f92b7aff346ac1a"
61+
checksum = "60362e038e71e4bdc1a5b23fb45e1aba587b5947fe0db58f4871d95608f89eca"
6262
dependencies = [
6363
"gccjit_sys",
6464
]
6565

6666
[[package]]
6767
name = "gccjit_sys"
68-
version = "0.8.2"
68+
version = "0.9.0"
6969
source = "registry+https://github.com/rust-lang/crates.io-index"
70-
checksum = "95ed7572b30cd32430294dde6fb70822d58e67c6846a548647e8739776a0125b"
70+
checksum = "ddd542c8414e122217551c6af6b7d33acf51a227aee85276f218c087525e01bb"
7171
dependencies = [
7272
"libc",
7373
]

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ default = ["master"]
2424
[dependencies]
2525
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
2626
tempfile = "3.20"
27-
gccjit = "2.8"
27+
gccjit = "2.10"
2828
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs" }
2929

3030
# Local copy.

Readme.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ $ ../gcc/configure \
7070
$ make -j4 # You can replace `4` with another number depending on how many cores you have.
7171
```
7272

73-
If you want to run libgccjit tests, you will need to also enable the C++ language in the `configure`:
73+
If you want to run libgccjit tests, you will need to
74+
* Enable the C++ language in the `configure` step:
7475

7576
```bash
7677
--enable-languages=jit,c++
7778
```
79+
* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests:
80+
81+
```bash
82+
$ sudo apt install dejagnu
83+
```
7884

7985
Then to run libgccjit tests:
8086

@@ -135,16 +141,6 @@ $ CHANNEL="release" $CG_GCCJIT_DIR/y.sh cargo run
135141

136142
If you compiled cg_gccjit in debug mode (aka you didn't pass `--release` to `./y.sh test`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely.
137143

138-
### LTO
139-
140-
To use LTO, you need to set the variable `EMBED_LTO_BITCODE=1` in addition to setting `lto = "fat"` in the `Cargo.toml`.
141-
142-
Failing to set `EMBED_LTO_BITCODE` will give you the following error:
143-
144-
```
145-
error: failed to copy bitcode to object file: No such file or directory (os error 2)
146-
```
147-
148144
### Rustc
149145

150146
If you want to run `rustc` directly, you can do so with:

build_system/src/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
149149

150150
// Copy files to sysroot
151151
let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple));
152+
// To avoid errors like "multiple candidates for `rmeta` dependency `core` found", we clean the
153+
// sysroot directory before copying the sysroot build artifacts.
154+
let _ = fs::remove_dir_all(&sysroot_path);
152155
create_dir(&sysroot_path)?;
153156
let mut copier = |dir_to_copy: &Path| {
154157
// FIXME: should not use shell command!

build_system/src/clean.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ fn clean_all() -> Result<(), String> {
6969
}
7070

7171
fn clean_ui_tests() -> Result<(), String> {
72-
let path = Path::new(crate::BUILD_DIR).join("rust/build/x86_64-unknown-linux-gnu/test/ui/");
73-
run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?;
72+
let directories = ["run-make", "run-make-cargo", "ui"];
73+
for directory in directories {
74+
let path = Path::new(crate::BUILD_DIR)
75+
.join("rust/build/x86_64-unknown-linux-gnu/test/")
76+
.join(directory);
77+
run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?;
78+
}
7479
Ok(())
7580
}
7681

build_system/src/prepare.rs

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
1+
use std::ffi::OsStr;
12
use std::fs;
23
use std::path::{Path, PathBuf};
4+
use std::process::Output;
35

46
use crate::rustc_info::get_rustc_path;
57
use crate::utils::{
68
cargo_install, create_dir, get_sysroot_dir, git_clone_root_dir, remove_file, run_command,
79
run_command_with_output, walk_dir,
810
};
911

12+
// This is needed on systems where nothing is configured.
13+
// git really needs something here, or it will fail.
14+
// Even using --author is not enough.
15+
const GIT_CMD: [&dyn AsRef<OsStr>; 9] = [
16+
&"git",
17+
&"-c",
18+
&"user.name=None",
19+
&"-c",
20+
&"user.email=none@example.com",
21+
&"-c",
22+
&"core.autocrlf=false",
23+
&"-c",
24+
&"commit.gpgSign=false",
25+
];
26+
27+
fn run_git_command(
28+
command: &dyn AsRef<OsStr>,
29+
input: &[&dyn AsRef<OsStr>],
30+
cwd: Option<&Path>,
31+
) -> Result<Output, String> {
32+
let git_cmd =
33+
&GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::<Vec<_>>()[..];
34+
run_command(git_cmd, cwd)
35+
}
36+
37+
fn run_git_command_with_output(
38+
command: &dyn AsRef<OsStr>,
39+
input: &[&dyn AsRef<OsStr>],
40+
cwd: Option<&Path>,
41+
) -> Result<(), String> {
42+
let git_cmd =
43+
&GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::<Vec<_>>()[..];
44+
run_command_with_output(git_cmd, cwd)
45+
}
46+
1047
fn prepare_libcore(
1148
sysroot_path: &Path,
1249
libgccjit12_patches: bool,
@@ -55,19 +92,12 @@ fn prepare_libcore(
5592
run_command(&[&"cp", &"-r", &rustlib_dir.join("library"), &sysroot_dir], None)?;
5693

5794
println!("[GIT] init (cwd): `{}`", sysroot_dir.display());
58-
run_command(&[&"git", &"init"], Some(&sysroot_dir))?;
95+
run_git_command(&"init", &[], Some(&sysroot_dir))?;
5996
println!("[GIT] add (cwd): `{}`", sysroot_dir.display());
60-
run_command(&[&"git", &"add", &"."], Some(&sysroot_dir))?;
97+
run_git_command(&"add", &[&"."], Some(&sysroot_dir))?;
6198
println!("[GIT] commit (cwd): `{}`", sysroot_dir.display());
6299

63-
// This is needed on systems where nothing is configured.
64-
// git really needs something here, or it will fail.
65-
// Even using --author is not enough.
66-
run_command(&[&"git", &"config", &"user.email", &"none@example.com"], Some(&sysroot_dir))?;
67-
run_command(&[&"git", &"config", &"user.name", &"None"], Some(&sysroot_dir))?;
68-
run_command(&[&"git", &"config", &"core.autocrlf", &"false"], Some(&sysroot_dir))?;
69-
run_command(&[&"git", &"config", &"commit.gpgSign", &"false"], Some(&sysroot_dir))?;
70-
run_command(&[&"git", &"commit", &"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?;
100+
run_git_command(&"commit", &[&"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?;
71101

72102
let mut patches = Vec::new();
73103
walk_dir(
@@ -105,10 +135,11 @@ fn prepare_libcore(
105135
for file_path in patches {
106136
println!("[GIT] apply `{}`", file_path.display());
107137
let path = Path::new("../../..").join(file_path);
108-
run_command_with_output(&[&"git", &"apply", &path], Some(&sysroot_dir))?;
109-
run_command_with_output(&[&"git", &"add", &"-A"], Some(&sysroot_dir))?;
110-
run_command_with_output(
111-
&[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())],
138+
run_git_command_with_output(&"apply", &[&path], Some(&sysroot_dir))?;
139+
run_git_command_with_output(&"add", &[&"-A"], Some(&sysroot_dir))?;
140+
run_git_command_with_output(
141+
&"commit",
142+
&[&"-m", &format!("Patch {}", path.display())],
112143
Some(&sysroot_dir),
113144
)?;
114145
}
@@ -124,10 +155,11 @@ fn prepare_rand() -> Result<(), String> {
124155
let rand_dir = Path::new("build/rand");
125156
println!("[GIT] apply `{file_path}`");
126157
let path = Path::new("../..").join(file_path);
127-
run_command_with_output(&[&"git", &"apply", &path], Some(rand_dir))?;
128-
run_command_with_output(&[&"git", &"add", &"-A"], Some(rand_dir))?;
129-
run_command_with_output(
130-
&[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())],
158+
run_git_command_with_output(&"apply", &[&path], Some(rand_dir))?;
159+
run_git_command_with_output(&"add", &[&"-A"], Some(rand_dir))?;
160+
run_git_command_with_output(
161+
&"commit",
162+
&[&"-m", &format!("Patch {}", path.display())],
131163
Some(rand_dir),
132164
)?;
133165

@@ -154,8 +186,8 @@ where
154186
println!("`{}` has already been cloned", clone_result.repo_name);
155187
}
156188
let repo_path = Path::new(crate::BUILD_DIR).join(&clone_result.repo_name);
157-
run_command(&[&"git", &"checkout", &"--", &"."], Some(&repo_path))?;
158-
run_command(&[&"git", &"checkout", &checkout_commit], Some(&repo_path))?;
189+
run_git_command(&"checkout", &[&"--", &"."], Some(&repo_path))?;
190+
run_git_command(&"checkout", &[&checkout_commit], Some(&repo_path))?;
159191
if let Some(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)