Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Add 32bit job for 4.14.2 #1698

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
skip-effects: true
skip-test: false
skip-doc: true
- os: ubuntu-latest
ocaml-compiler: "ocaml-variants.4.14.2+options,ocaml-option-32bit"
skip-effects: true
skip-test: false
skip-doc: true
- os: macos-latest
ocaml-compiler: "4.14"
skip-effects: true
Expand Down Expand Up @@ -73,6 +78,19 @@ jobs:
git config --global core.eol lf
git config --global core.ignorecase false

# EJGA: Note that I tried to fix this upstream as depext is
# getting much better, but no luck yet, c.f:
# https://github.com/ocaml/opam-repository/pull/26626
- name: Install apt 32-bit dependencies
if: matrix.ocaml-compiler == 'ocaml-variants.4.14.2+options,ocaml-option-32bit'
run: |
sudo apt-get install aptitude
sudo dpkg --add-architecture i386
sudo aptitude -o Acquire::Retries=30 update -q
# Note we also install the 64-bit versions here as opam will
# try to install them anyways, so we save an apt-roundtrip.
sudo aptitude -o Acquire::Retries=30 install gcc-multilib g++-multilib pkg-config libgmp-dev libgmp-dev:i386 libx11-dev:i386 -y

- name: Checkout tree
uses: actions/checkout@v4

Expand Down
19 changes: 14 additions & 5 deletions benchmarks/sources/ml/splay.ml
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,24 @@ let rec generatePayloadTree depth tag =

let random =
let seed = ref 49734321 in
let mask_32bit =
match Sys.int_size with
| 31 | 32 -> -1
| _ -> int_of_string "0xffffffff"
in
let l_0xc761c23c = int_of_string "0xc761c23c" in
let l_0xd3a2646c = int_of_string "0xd3a2646c" in
let l_0xfd7046c5 = int_of_string "0xfd7046c5" in
let l_0xb55a4f09 = int_of_string "0xb55a4f09" in
fun () ->
(* // Robert Jenkins' 32 bit integer hash function. *)
let s = !seed in
let s = (s + 0x7ed55d16 + (s lsl 12)) land 0xffffffff in
let s = s lxor 0xc761c23c lxor (s lsr 19) in
let s = (s + 0x7ed55d16 + (s lsl 12)) land mask_32bit in
let s = s lxor l_0xc761c23c lxor (s lsr 19) in
let s = s + 0x165667b1 + (s lsl 5) in
let s = (s + 0xd3a2646c) lxor (s lsl 9) in
let s = (s + 0xfd7046c5 + (s lsl 3)) land 0xffffffff in
let s = s lxor 0xb55a4f09 lxor (s lsr 16) in
let s = (s + l_0xd3a2646c) lxor (s lsl 9) in
let s = (s + l_0xfd7046c5 + (s lsl 3)) land mask_32bit in
let s = s lxor l_0xb55a4f09 lxor (s lsr 16) in
seed := s;
float (s land 0xfffffff) /. float 0x10000000

Expand Down
12 changes: 7 additions & 5 deletions compiler/lib/stdlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -307,23 +307,25 @@ module Int32 = struct

external equal : int32 -> int32 -> bool = "%equal"

let warn_overflow ~to_dec ~to_hex i i32 =
let warn_overflow name ~to_dec ~to_hex i i32 =
warn
"Warning: integer overflow: integer 0x%s (%s) truncated to 0x%lx (%ld); the \
generated code might be incorrect.@."
"Warning: integer overflow: %s 0x%s (%s) truncated to 0x%lx (%ld); the generated \
code might be incorrect.@."
name
(to_hex i)
(to_dec i)
i32
i32

let convert_warning_on_overflow ~to_int32 ~of_int32 ~equal ~to_dec ~to_hex x =
let convert_warning_on_overflow name ~to_int32 ~of_int32 ~equal ~to_dec ~to_hex x =
let i32 = to_int32 x in
let x' = of_int32 i32 in
if not (equal x' x) then warn_overflow ~to_dec ~to_hex x i32;
if not (equal x' x) then warn_overflow name ~to_dec ~to_hex x i32;
i32

let of_nativeint_warning_on_overflow n =
convert_warning_on_overflow
"native integer"
~to_int32:Nativeint.to_int32
~of_int32:Nativeint.of_int32
~equal:Nativeint.equal
Expand Down
3 changes: 3 additions & 0 deletions compiler/lib/targetint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ let of_float_opt x =

let of_int_warning_on_overflow i =
Stdlib.Int32.convert_warning_on_overflow
"integer"
~to_int32:(fun i -> wrap_modulo (Int32.of_int i))
~of_int32:Int32.to_int
~equal:Int.equal
Expand All @@ -131,6 +132,7 @@ let of_int_warning_on_overflow i =

let of_int32_warning_on_overflow n =
Stdlib.Int32.convert_warning_on_overflow
"int32"
~to_int32:(fun i -> wrap_modulo i)
~of_int32:Fun.id
~equal:Int32.equal
Expand All @@ -140,6 +142,7 @@ let of_int32_warning_on_overflow n =

let of_nativeint_warning_on_overflow n =
Stdlib.Int32.convert_warning_on_overflow
"native integer"
~to_int32:(fun i -> wrap_modulo (Nativeint.to_int32 i))
~of_int32:Nativeint.of_int32
~equal:Nativeint.equal
Expand Down
4 changes: 2 additions & 2 deletions compiler/tests-compiler/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@
(library
;; compiler/tests-compiler/gh1051.ml
(name gh1051_15)
(enabled_if true)
(enabled_if %{arch_sixtyfour})
(modules gh1051)
(libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper)
(inline_tests
(enabled_if true)
(enabled_if %{arch_sixtyfour})
(deps
(file %{project_root}/compiler/bin-js_of_ocaml/js_of_ocaml.exe)
(file %{project_root}/compiler/bin-jsoo_minify/jsoo_minify.exe)))
Expand Down
9 changes: 7 additions & 2 deletions compiler/tests-compiler/gen-rules/gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ let prefix : string =

type enabled_if =
| GE5
| B64
| Any

let lib_enabled_if = function
| "obj" | "effects" -> GE5
| "gh1051" -> B64
| _ -> Any

let test_enabled_if = function
| "obj" | "lazy" -> GE5
| "gh1051" -> B64
| _ -> Any

let () =
Expand Down Expand Up @@ -86,8 +89,10 @@ let () =
(Hashtbl.hash prefix mod 100)
(match lib_enabled_if basename with
| Any -> "true"
| GE5 -> "(>= %{ocaml_version} 5)")
| GE5 -> "(>= %{ocaml_version} 5)"
| B64 -> "%{arch_sixtyfour}")
basename
(match test_enabled_if basename with
| Any -> "true"
| GE5 -> "(>= %{ocaml_version} 5)"))
| GE5 -> "(>= %{ocaml_version} 5)"
| B64 -> "%{arch_sixtyfour}"))
10 changes: 6 additions & 4 deletions compiler/tests-compiler/gh1051.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ let%expect_test _ =
Util.compile_and_run ~skip_modern:true prog;
[%expect
{|
Warning: integer overflow: integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
ffffffff |}];
Warning: integer overflow: native integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
ffffffff
|}];
()

let%expect_test _ =
Util.print_fun_decl (Util.compile_and_parse prog) None;
[%expect
{|
Warning: integer overflow: integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
Warning: integer overflow: native integer 0xffffffff (4294967295) truncated to 0xffffffff (-1); the generated code might be incorrect.
function caml_call2(f, a0, a1){
return (f.l >= 0 ? f.l : f.l = f.length) == 2
? f(a0, a1)
: runtime.caml_call_gen(f, [a0, a1]);
}
//end |}];
//end
|}];
()
14 changes: 8 additions & 6 deletions compiler/tests-compiler/pbt/test_int31.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,23 @@ let%expect_test _ =
i);
[%expect ""]

let sixty_four = Sys.int_size > 32

let%expect_test _ =
let i = Gen.(generate1 (no_shrink out_of_range_i32)) in
let i_trunc = Int32.(shift_right (shift_left i 1) 1) in
ignore (Int31.of_int32_warning_on_overflow i);
let output = [%expect.output] in
let expected =
Format.sprintf
"Warning: integer overflow: integer 0x%lx (%ld) truncated to 0x%lx (%ld); the \
"Warning: integer overflow: int32 0x%lx (%ld) truncated to 0x%lx (%ld); the \
generated code might be incorrect.@."
i
i
i_trunc
i_trunc
in
if not (String.equal output expected)
if sixty_four && not (String.equal output expected)
then Format.printf "Unexpected output string@.%[email protected]:@.%s@." output expected;
[%expect ""]

Expand All @@ -91,7 +93,7 @@ let%expect_test _ =
i_trunc
i_trunc
in
if not (String.equal output expected)
if sixty_four && not (String.equal output expected)
then Format.printf "Unexpected output string@.%[email protected]:@.%s@." output expected;
[%expect ""]

Expand All @@ -102,14 +104,14 @@ let%expect_test _ =
let output = [%expect.output] in
let expected =
Format.sprintf
"Warning: integer overflow: integer 0x%nx (%nd) truncated to 0x%lx (%ld); the \
generated code might be incorrect.@."
"Warning: integer overflow: native integer 0x%nx (%nd) truncated to 0x%lx (%ld); \
the generated code might be incorrect.@."
i
i
i_trunc
i_trunc
in
if not (String.equal output expected)
if sixty_four && not (String.equal output expected)
then Format.printf "Unexpected output string@.%[email protected]:@.%s@." output expected;
[%expect ""]

Expand Down
Loading