From 41f5e701e69a164acae301574938c30e2fd605a5 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 22 Jan 2023 21:22:49 -0500 Subject: [PATCH] Fix signed integer overflow --- .github/workflows/release.yml | 3 ++- src/base.rs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e81442298c6..c60c96d2023e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -104,7 +104,8 @@ jobs: - name: Run tests run: | - ./test.sh --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests # --test-libcore # FIXME(antoyo): libcore tests fail. + ./test.sh --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore + # TODO(antoyo): also run the rustc's test suite. - name: Run stdarch tests run: | diff --git a/src/base.rs b/src/base.rs index ea933c25b2f3..6102016b4345 100644 --- a/src/base.rs +++ b/src/base.rs @@ -124,6 +124,8 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_ context.add_command_line_option("-fno-semantic-interposition"); // NOTE: Rust relies on LLVM not doing TBAA (https://github.com/rust-lang/unsafe-code-guidelines/issues/292). context.add_command_line_option("-fno-strict-aliasing"); + // NOTE: Rust relies on LLVM doing wrapping on overflow. + context.add_command_line_option("-fwrapv"); if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) { context.add_command_line_option("-ffunction-sections");