Skip to content

Commit 6fda6d2

Browse files
fix(libflux): fix libflux tests on aarch64-linux (#5542)
This test uses the `c_char` type and tried to negate it. This works on `x86_64` because `c_char` is signed, but this signedness is explicitly _implementation-defined_ in the standard. In fact, on `aarch64-linux`, `c_char` is unsigned, and in Rust unsigned values cannot be negated. To work around this, we must patch over this piece of ancient esoterica by telling the Rust compiler _exactly_ what we want to do. We specify that the literal is an `i8`, and then explicitly cast to `c_char`. Rust safely defines casts between signed and unsigned types to behave like two's complement, so `aarch64` systems will interpret it as `-61 + 256 = 195`. This does not appear to break the test :). Closes #5495
1 parent b492178 commit 6fda6d2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libflux/flux/src/cffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ from(bucket: v.bucket)
11491149
fn parse_with_invalid_utf8() {
11501150
let cfname = CString::new("foo.flux").unwrap();
11511151
let cfname_ptr: *const c_char = cfname.as_ptr();
1152-
let v: Vec<c_char> = vec![-61, 0];
1152+
let v: Vec<c_char> = vec![-61i8 as c_char, 0];
11531153
let csrc: *const c_char = &v[0];
11541154
// Safety: both pointers are valid
11551155
let pkg = unsafe { flux_parse(cfname_ptr, csrc) };

libflux/go/libflux/buildinfo.gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var sourceHashes = map[string]string{
6262
"libflux/flux/Cargo.toml": "913a8be19540592efc631bcb2f8b5fd25747a7297f6c1073fec40ad0f5ec255e",
6363
"libflux/flux/FLUXDOC.md": "92e6dd8043bd87b4924e09aa28fb5346630aee1214de28ea2c8fc0687cad0785",
6464
"libflux/flux/build.rs": "31dcb1e825555e56b4d959244c4ea630b1d32ccddc1f8615620e0c23552d914f",
65-
"libflux/flux/src/cffi.rs": "a5e3c5bb6eeb720f726cc7177afb5e7dd3a3e8b32ac269a2d48f199068995f78",
65+
"libflux/flux/src/cffi.rs": "573dd8ea708c3a41af03f8128c3e7ffa9e9a721eebb76f90a022165e50e0709e",
6666
"libflux/flux/src/lib.rs": "7e0bacaa5da218888cae12e4245d305909153bbe60cc8c17b85543563fa628cc",
6767
"libflux/flux/templates/base.html": "a818747b9621828bb96b94291c60922db54052bbe35d5e354f8e589d2a4ebd02",
6868
"libflux/flux/templates/home.html": "f9927514dd42ca7271b4817ad1ca33ec79c03a77a783581b4dcafabd246ebf3f",

0 commit comments

Comments
 (0)