Skip to content

Fix build failure on aarch64 - #2

Merged
StephanvanSchaik merged 1 commit into
StephanvanSchaik:mainfrom
yagehu:aarch64
May 13, 2026
Merged

StephanvanSchaik merged 1 commit into
StephanvanSchaik:mainfrom
yagehu:aarch64

Conversation

@yagehu

@yagehu yagehu commented May 12, 2026

Copy link
Copy Markdown
Contributor

A C char may be signed or unsigned depending on the architecture. Most notably, it is unsigned on aarch64. Due to this difference, dynamorio-rs and drstd cannot be compiled on aarch64 as-is. This commit fixes some assumptions about bool being represented as i8. This commit also contains other formatting changes as a result of running cargo fmt on the repository.

I will mark all the non-formatting changes in the PR.

Comment thread dynamorio-rs/src/lib.rs
/// whether AVX-512 is being used or not.
#[no_mangle]
pub static _DR_CLIENT_AVX512_CODE_IN_USE: i8 = dynamorio_sys::_DR_CLIENT_AVX512_CODE_IN_USE_;
pub static _DR_CLIENT_AVX512_CODE_IN_USE: dynamorio_sys::bool_ =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

dr_module_set_should_instrument((*self.raw).__bindgen_anon_1.handle, instrumented as i8);
dr_module_set_should_instrument(
(*self.raw).__bindgen_anon_1.handle,
instrumented as dynamorio_sys::bool_,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

Comment thread drstd/src/fs/mod.rs
dr_rename_file(from.as_ptr(), to.as_ptr(), true as i8) != 0
};
let result =
unsafe { dr_rename_file(from.as_ptr(), to.as_ptr(), true as dynamorio_sys::bool_) != 0 };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

@yagehu

yagehu commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

I took a look at the clippy CI failure. I think there's an easy fix. I'll submit a follow up PR.

@yagehu
yagehu marked this pull request as draft May 13, 2026 00:05
A C `char` may be signed or unsigned depending on the architecture.
Most notably, it is unsigned on aarch64. Due to this difference,
`dynamorio-rs` and `drstd` cannot be compiled on aarch64 as-is.
This commit fixes some assumptions about bool being represented
as `i8`. This commit also contains other formatting changes as a result
of running `cargo fmt` on the repository.
Comment on lines +93 to +94
dynamorio_sys::bool_,
dynamorio_sys::bool_,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

Comment on lines +123 to +124
dynamorio_sys::bool_,
dynamorio_sys::bool_,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

Comment on lines +144 to +145
dynamorio_sys::bool_,
dynamorio_sys::bool_,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

context: *mut core::ffi::c_void,
module: *const module_data_t,
loaded: i8,
loaded: dynamorio_sys::bool_,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

let func: extern "C" fn(*mut core::ffi::c_void, i32) -> i8 = unsafe {
core::mem::transmute(self.closure.code())
};
let func: extern "C" fn(*mut core::ffi::c_void, i32) -> dynamorio_sys::bool_ =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

Comment on lines +53 to +62
) -> dynamorio_sys::bool_ {
let mut context = BeforeSyscallContext::from_raw(context);
let handler = unsafe { &*(user_data as *mut Mutex<T>) };
let mut result = 0;
let mut result = false;

if let Ok(mut handler) = handler.lock() {
result = handler.before_syscall(&mut context, sysnum) as i8;
result = handler.before_syscall(&mut context, sysnum);
}

result
result as dynamorio_sys::bool_

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

let func: extern "C" fn(*mut core::ffi::c_void, i32) -> i8 = unsafe {
core::mem::transmute(closure.code())
};
let func: extern "C" fn(*mut core::ffi::c_void, i32) -> dynamorio_sys::bool_ =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use DR's bool_ type instead of assuming i8.

@yagehu

yagehu commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

I've marked all the non-formatting changes.

@yagehu
yagehu marked this pull request as ready for review May 13, 2026 03:34
@StephanvanSchaik
StephanvanSchaik merged commit 8e8fd93 into StephanvanSchaik:main May 13, 2026
1 of 3 checks passed
@StephanvanSchaik

Copy link
Copy Markdown
Owner

A C char may be signed or unsigned depending on the architecture. Most notably, it is unsigned on aarch64. Due to this difference, dynamorio-rs and drstd cannot be compiled on aarch64 as-is. This commit fixes some assumptions about bool being represented as i8. This commit also contains other formatting changes as a result of running cargo fmt on the repository.
Yes, I learned about this recently that char defaults to signed char on x86 and unsigned char on AArch64. I reviewed the changes and they look good to me. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants