Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit 2286e5d

Browse files
committed
Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez
Sync rustc_codegen_gcc subtree cc `@antoyo` r? ghost
2 parents af5c5b7 + 866de5f commit 2286e5d

32 files changed

Lines changed: 483 additions & 292 deletions

‎compiler/rustc_codegen_gcc/.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:

‎compiler/rustc_codegen_gcc/.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

‎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 = "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
]

‎compiler/rustc_codegen_gcc/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.

‎compiler/rustc_codegen_gcc/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:

‎compiler/rustc_codegen_gcc/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
letmut copier = |dir_to_copy:&Path| {
154157
// FIXME: should not use shell command!

‎compiler/rustc_codegen_gcc/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
fnclean_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

‎compiler/rustc_codegen_gcc/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
usecrate::rustc_info::get_rustc_path;
57
usecrate::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+
constGIT_CMD:[&dynAsRef<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+
fnrun_git_command(
28+
command:&dynAsRef<OsStr>,
29+
input:&[&dynAsRef<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+
fnrun_git_command_with_output(
38+
command:&dynAsRef<OsStr>,
39+
input:&[&dynAsRef<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
fnprepare_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
letmut 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
ifletSome(extra) = extra {
160192
extra(&repo_path)?;
161193
}

0 commit comments

Comments
 (0)