Skip to content

Commit 8d0ff6b

Browse files
authored
Merge pull request #249 from rust-lang/fix/signed-integer-overflow
Fix/signed integer overflow
2 parents e6024f3 + 2dc7dbc commit 8d0ff6b

File tree

3 files changed

+123
-6
lines changed

3 files changed

+123
-6
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
matrix:
2121
libgccjit_version:
2222
- { gcc: "libgccjit.so", artifacts_branch: "master" }
23+
commands: [
24+
"--test-successful-rustc --nb-parts 2 --current-part 0",
25+
"--test-successful-rustc --nb-parts 2 --current-part 1",
26+
]
2327

2428
steps:
2529
- uses: actions/checkout@v3
@@ -104,9 +108,4 @@ jobs:
104108

105109
- name: Run tests
106110
run: |
107-
./test.sh --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests # --test-libcore # FIXME(antoyo): libcore tests fail.
108-
109-
- name: Run stdarch tests
110-
run: |
111-
cd build_sysroot/sysroot_src/library/stdarch/
112-
CHANNEL=release TARGET=x86_64-unknown-linux-gnu ../../../../cargo.sh test
111+
./test.sh --release --clean --release-sysroot --build-sysroot ${{ matrix.commands }}

.github/workflows/stdarch.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: stdarch tests with sysroot compiled in release mode
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
# Enable backtraces for easier debugging
12+
RUST_BACKTRACE: 1
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
libgccjit_version:
22+
- { gcc: "libgccjit.so", artifacts_branch: "master" }
23+
commands: [
24+
"--test-successful-rustc --nb-parts 2 --current-part 0",
25+
"--test-successful-rustc --nb-parts 2 --current-part 1",
26+
]
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
31+
- uses: actions/checkout@v3
32+
with:
33+
repository: llvm/llvm-project
34+
path: llvm
35+
36+
- name: Install packages
37+
run: sudo apt-get install ninja-build ripgrep
38+
39+
- name: Download artifact
40+
uses: dawidd6/action-download-artifact@v2
41+
with:
42+
workflow: main.yml
43+
name: ${{ matrix.libgccjit_version.gcc }}
44+
path: gcc-build
45+
repo: antoyo/gcc
46+
branch: ${{ matrix.libgccjit_version.artifacts_branch }}
47+
event: push
48+
search_artifacts: true # Because, instead, the action only check the last job ran and that won't work since we want multiple artifacts.
49+
50+
- name: Setup path to libgccjit
51+
run: |
52+
echo $(readlink -f gcc-build) > gcc_path
53+
# NOTE: the filename is still libgccjit.so even when the artifact name is different.
54+
ln gcc-build/libgccjit.so gcc-build/libgccjit.so.0
55+
56+
- name: Set env
57+
run: |
58+
echo "LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
59+
echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
60+
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
61+
62+
- name: Set RUST_COMPILER_RT_ROOT
63+
run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV
64+
65+
- name: Cache cargo installed crates
66+
uses: actions/cache@v3
67+
with:
68+
path: ~/.cargo/bin
69+
key: cargo-installed-crates2-ubuntu-latest
70+
71+
- name: Cache cargo registry
72+
uses: actions/cache@v3
73+
with:
74+
path: ~/.cargo/registry
75+
key: ${{ runner.os }}-cargo-registry2-${{ hashFiles('**/Cargo.lock') }}
76+
77+
- name: Cache cargo index
78+
uses: actions/cache@v3
79+
with:
80+
path: ~/.cargo/git
81+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
82+
83+
- name: Cache cargo target dir
84+
uses: actions/cache@v3
85+
with:
86+
path: target
87+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain') }}
88+
89+
- name: Build
90+
run: |
91+
./prepare_build.sh
92+
./build.sh --release --release-sysroot
93+
cargo test
94+
./clean_all.sh
95+
96+
- name: Prepare dependencies
97+
run: |
98+
git config --global user.email "[email protected]"
99+
git config --global user.name "User"
100+
./prepare.sh
101+
102+
# Compile is a separate step, as the actions-rs/cargo action supports error annotations
103+
- name: Compile
104+
uses: actions-rs/[email protected]
105+
with:
106+
command: build
107+
args: --release
108+
109+
- name: Run tests
110+
run: |
111+
./test.sh --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore
112+
113+
- name: Run stdarch tests
114+
run: |
115+
cd build_sysroot/sysroot_src/library/stdarch/
116+
CHANNEL=release TARGET=x86_64-unknown-linux-gnu ../../../../cargo.sh test

src/base.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
124124
context.add_command_line_option("-fno-semantic-interposition");
125125
// NOTE: Rust relies on LLVM not doing TBAA (https://github.com/rust-lang/unsafe-code-guidelines/issues/292).
126126
context.add_command_line_option("-fno-strict-aliasing");
127+
// NOTE: Rust relies on LLVM doing wrapping on overflow.
128+
context.add_command_line_option("-fwrapv");
127129

128130
if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) {
129131
context.add_command_line_option("-ffunction-sections");

0 commit comments

Comments
 (0)