Algunenano opened a new pull request, #12421:
URL: https://github.com/apache/arrow-rs/pull/12421

   # Which issue does this PR close?
   
   None.
   
   # Rationale for this change
   
   Found while building [ClickHouse](https://github.com/ClickHouse/ClickHouse) 
with Clang CFI: Rust encodes `repr(C)` structs in CFI type ids by their Rust 
name (`FFI_ArrowSchema`), C and C++ by the C name (`ArrowSchema`), so every 
`release` or stream callback across the boundary traps.
   
   # What changes are included in this PR?
   
   Under a `cfi`/`kcfi` sanitizer, the three FFI structs get `#[cfi_encoding]` 
with their C names. `cfg(sanitize)` is unstable, so a build script reads 
`CARGO_CFG_SANITIZE` and sets `arrow_cfi`, as 
[getrandom](https://github.com/rust-random/getrandom/blob/56a296181458f8ce8b0c874a51c8c8dddc54e173/build.rs#L7)
 and 
[crossbeam](https://github.com/crossbeam-rs/crossbeam/blob/bc002195e08b91c6e5cee1b4040ecd23eb2d0e2c/crossbeam-utils/build.rs#L16)
 do for their sanitizers. `cfi_encoding` is used the same way in 
[std](https://github.com/rust-lang/rust/blob/8979186e4a4d5dbc04bf182a2fe40e8d05abedfc/library/std/src/sys/thread_local/destructors/linux_like.rs#L22)
 and the [Linux 
kernel](https://github.com/torvalds/linux/blob/107a25d62c40ef47b2284ee37fdefc1d3f5d013b/rust/bindings/lib.rs#L22).
   
   # Are these changes tested?
   
   Not in CI, which has no CFI build. The tests pass locally, the type ids of 
all six callbacks now match the ones Clang emits for the C declarations, and a 
ClickHouse build with CFI works with the patch applied to 58.4.1.
   
   # Are there any significant user-facing changes?
   
   No. Builds without a CFI sanitizer, including all stable builds, are 
unaffected.
   
   # AI usage disclosure
   
   Written with Claude Code; I reviewed the change and the verification.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to