Skip to content

Commit 3fc756b

Browse files
authored
Merge branch 'master' into fix_128b_leading_zeros_ub
2 parents beb0d05 + db67f59 commit 3fc756b

Some content is hidden

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

60 files changed

+1200
-813
lines changed

.github/workflows/m68k.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,16 @@ jobs:
8282
- name: Build sample project with target defined as JSON spec
8383
run: |
8484
./y.sh prepare --only-libcore --cross
85-
./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
85+
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
8686
CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
8787
./y.sh clean all
8888
8989
- name: Build
9090
run: |
9191
./y.sh prepare --only-libcore --cross
92-
./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu
92+
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu
9393
./y.sh test --mini-tests --target-triple m68k-unknown-linux-gnu
94-
# FIXME: since https://github.com/rust-lang/rust/pull/140809, we cannot run programs for architectures not
95-
# supported by the object crate, since this adds a dependency on symbols.o for the panic runtime.
96-
# And as such, a wrong order of the object files in the linker command now fails with an undefined reference
97-
# to some symbols like __rustc::rust_panic.
98-
#CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu
94+
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu
9995
./y.sh clean all
10096
10197
- name: Prepare dependencies
@@ -104,23 +100,21 @@ jobs:
104100
git config --global user.name "User"
105101
./y.sh prepare --cross
106102
107-
# FIXME: We cannot run programs for architectures not supported by the object crate. See comment above.
108-
#- name: Run tests
109-
#run: |
110-
#./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler-builtins-no-f16-f128 ${{ matrix.commands }}
111-
112-
# FIXME: We cannot run programs for architectures not supported by the object crate. See comment above.
113-
#- name: Run Hello World!
114-
#run: |
115-
#./y.sh build --target-triple m68k-unknown-linux-gnu
116-
117-
#vm_dir=$(pwd)/vm
118-
#cd tests/hello-world
119-
#CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu
120-
#sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/
121-
#sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout
122-
#expected_output="40"
123-
#test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1)
103+
- name: Run tests
104+
run: |
105+
./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot ${{ matrix.commands }}
106+
107+
- name: Run Hello World!
108+
run: |
109+
./y.sh build --target-triple m68k-unknown-linux-gnu
110+
111+
vm_dir=$(pwd)/vm
112+
cd tests/hello-world
113+
CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu
114+
sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/
115+
sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout
116+
expected_output="40"
117+
test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1)
124118
125119
# Summary job for the merge queue.
126120
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!

.github/workflows/release.yml

Lines changed: 20 additions & 7 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,39 @@ 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)
75+
- name: Add more failing tests (some panic and debuginfo tests fail)
7676
run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt
7777

7878
- name: Run tests
7979
run: |
8080
# 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 }}
81+
CG_RUSTFLAGS="-Cembed-bitcode=yes" ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }}
8482
85-
- name: Run y.sh cargo build
83+
- name: LTO test
8684
run: |
87-
EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml
85+
CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml
8886
call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||:
8987
if [ $call_found -gt 0 ]; then
9088
echo "ERROR: call my_func found in asm"
9189
echo "Test is done with LTO enabled, hence inlining should occur across crates"
9290
exit 1
9391
fi
9492
93+
- name: Cross-language LTO test
94+
run: |
95+
pushd tests/cross_lang_lto
96+
gcc -c -flto add.c -masm=intel -fPIC -O3
97+
ar rcs libadd.a add.o
98+
popd
99+
100+
CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml
101+
call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||:
102+
if [ $call_found -gt 0 ]; then
103+
echo "ERROR: call my_add found in asm"
104+
echo "Test is done with cross-language LTO enabled, hence inlining should occur across object files"
105+
exit 1
106+
fi
107+
95108
# Summary job for the merge queue.
96109
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
97110
success_release:

.github/workflows/stdarch.yml

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

Cargo.lock

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

6666
[[package]]
6767
name = "gccjit_sys"
68-
version = "0.8.0"
68+
version = "0.9.0"
6969
source = "registry+https://github.com/rust-lang/crates.io-index"
70-
checksum = "24edb7bfe2b7b27c6d09ed23eebfcab0b359c8fe978433f902943e6f127a0f1b"
70+
checksum = "ddd542c8414e122217551c6af6b7d33acf51a227aee85276f218c087525e01bb"
7171
dependencies = [
7272
"libc",
7373
]
@@ -143,6 +143,15 @@ dependencies = [
143143
"libc",
144144
]
145145

146+
[[package]]
147+
name = "object"
148+
version = "0.37.1"
149+
source = "registry+https://github.com/rust-lang/crates.io-index"
150+
checksum = "03fd943161069e1768b4b3d050890ba48730e590f57e56d4aa04e7e090e61b4a"
151+
dependencies = [
152+
"memchr",
153+
]
154+
146155
[[package]]
147156
name = "once_cell"
148157
version = "1.20.2"
@@ -179,6 +188,7 @@ dependencies = [
179188
"boml",
180189
"gccjit",
181190
"lang_tester",
191+
"object",
182192
"tempfile",
183193
]
184194

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ master = ["gccjit/master"]
2222
default = ["master"]
2323

2424
[dependencies]
25-
gccjit = "2.7"
25+
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
26+
tempfile = "3.20"
27+
gccjit = "2.10"
2628
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs" }
2729

2830
# Local copy.
@@ -31,7 +33,6 @@ gccjit = "2.7"
3133
[dev-dependencies]
3234
boml = "0.3.1"
3335
lang_tester = "0.8.0"
34-
tempfile = "3.20"
3536

3637
[profile.dev]
3738
# By compiling dependencies with optimizations, performing tests gets much faster.

Readme.md

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

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

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

7985
Then to run libgccjit tests:
8086

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

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

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

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

build_system/src/abi_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn run() -> Result<(), String> {
3131
Some("clones/abi-cafe".as_ref()),
3232
true,
3333
)
34-
.map_err(|err| (format!("Git clone failed with message: {err:?}!")))?;
34+
.map_err(|err| format!("Git clone failed with message: {err:?}!"))?;
3535
// Configure abi-cafe to use the exact same rustc version we use - this is crucial.
3636
// Otherwise, the concept of ABI compatibility becomes meanignless.
3737
std::fs::copy("rust-toolchain", "clones/abi-cafe/rust-toolchain")

build_system/src/build.rs

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

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

build_system/src/clean.rs

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

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

build_system/src/fmt.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::ffi::OsStr;
22
use std::path::Path;
33

4-
use crate::utils::run_command_with_output;
4+
use crate::utils::{run_command_with_output, walk_dir};
55

66
fn show_usage() {
77
println!(
@@ -32,5 +32,31 @@ pub fn run() -> Result<(), String> {
3232
if check { &[&"cargo", &"fmt", &"--check"] } else { &[&"cargo", &"fmt"] };
3333

3434
run_command_with_output(cmd, Some(Path::new(".")))?;
35-
run_command_with_output(cmd, Some(Path::new("build_system")))
35+
run_command_with_output(cmd, Some(Path::new("build_system")))?;
36+
37+
run_rustfmt_recursively("tests/run", check)
38+
}
39+
40+
fn run_rustfmt_recursively<P>(dir: P, check: bool) -> Result<(), String>
41+
where
42+
P: AsRef<Path>,
43+
{
44+
walk_dir(
45+
dir,
46+
&mut |dir| run_rustfmt_recursively(dir, check),
47+
&mut |file_path| {
48+
if file_path.extension().filter(|ext| ext == &OsStr::new("rs")).is_some() {
49+
let rustfmt_cmd: &[&dyn AsRef<OsStr>] = if check {
50+
&[&"rustfmt", &"--check", &file_path]
51+
} else {
52+
&[&"rustfmt", &file_path]
53+
};
54+
55+
run_command_with_output(rustfmt_cmd, Some(Path::new(".")))
56+
} else {
57+
Ok(())
58+
}
59+
},
60+
true,
61+
)
3662
}

0 commit comments

Comments
 (0)