Bug 2365083 - regression: bindgen generates rust codes that cannot be compiled with rust-1.79.0 on EPEL9
Summary: regression: bindgen generates rust codes that cannot be compiled with rust-1....
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: rust-bindgen-cli
Version: epel9
Hardware: All
OS: Unspecified
unspecified
urgent
Target Milestone: ---
Assignee: Fabio Valentini
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-05-08 11:06 UTC by Than Ngo
Modified: 2025-05-08 12:44 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Than Ngo 2025-05-08 11:06:42 UTC
Description of problem:
bindgen generates rust codes that cannot be compiled with rust-1.79.0 on EPEL9

Version-Release number of selected component (if applicable):
bindgen-cli-0.71.1-1.el9.x86_64
rust-1.79.0-3.el9_5.x86_64

How reproducible:
Build chromium-136.0.7103.92 on epel9

Actual results:
The chromium build breaks with following errors:

FAILED: obj/third_party/crabbyavif/liblibyuv_sys.rlib 
"/usr/bin/python3" "../../build/rust/rustc_wrapper.py" --rustc=../../../../../../usr/bin/rustc --depfile=obj/third_party/crabbyavif/liblibyuv_sys.rlib.d --rsp=obj/third_party/crabbyavif/liblibyuv_sys.rlib.rsp -- -Clinker="clang++" --crate-name libyuv_sys ../../third_party/crabbyavif/src/sys/libyuv-sys/src/lib.rs --crate-type rlib --edition=2021 -Dunsafe_op_in_unsafe_fn -Cforce-unwind-tables=no -Crelocation-model=pic -Cdefault-linker-libraries -Zdep-info-omit-d-target -Zmacro-backtrace -Zremap-cwd-prefix=. -Zexternal-clangrt --color=always --target=x86_64-unknown-linux-gnu -Cembed-bitcode=no -Clto=no -Ccodegen-units=1 --cfg cr_rustc_revision=\"rustc\ 1.79.0\ \(129f3b996\ 2024-06-10\)\ \(Red\ Hat\ 1.79.0-3.el9_5\)\" -Copt-level=3 -Zallow-features= --emit=dep-info=obj/third_party/crabbyavif/liblibyuv_sys.rlib.d,link -o obj/third_party/crabbyavif/liblibyuv_sys.rlib LDFLAGS RUSTENV OUT_DIR=../../../../../../out/Release/gen/third_party/crabbyavif/crabbyavif_libyuv_sys
error: extern block cannot be declared unsafe
 --> ../../third_party/crabbyavif/src/sys/libyuv-sys/src/../../../../../../out/Release/gen/third_party/crabbyavif/crabbyavif_libyuv_sys/libyuv_bindgen.rs:3:268
  |
3 | ...ode = 3 ; pub type FilterMode = :: std :: os :: raw :: c_uint ; unsafe extern "C" { pub fn ScalePlane (src : * const u8 , src_stride :...
  |                                                                    ^^^^^^

error: extern block cannot be declared unsafe
 --> ../../third_party/crabbyavif/src/sys/libyuv-sys/src/../../../../../../out/Release/gen/third_party/crabbyavif/crabbyavif_libyuv_sys/libyuv_bindgen.rs:3:665
  |
3 | ...t , filtering : FilterMode) -> :: std :: os :: raw :: c_int ; } unsafe extern "C" { pub fn ScalePlane_12 (src : * const u16 , src_stri...
  |                                                                    ^^^^^^

For more infos please have a look at chromium build log:

   https://koji.fedoraproject.org/koji/taskinfo?taskID=132420726

Expected results:
chromium should be built fine.

Additional info:
chromium just built fine with bindgen-cli-0.69.5-1

Comment 1 Fabio Valentini 2025-05-08 11:56:06 UTC
Sorry about that - I *did* do test builds of all packages that depend on bindgen-cli and all of them built fine - but those test builds were on Rawhide, where this isn't an issue :(

As far as I can tell, this should (hopefully) be a temporary issue, since the next RHEL minor release (out in the next 1-2 weeks?) will ship with Rust 1.84, where this error should go away.

It looks like a bug that was introduced here and later reported:
https://github.com/rust-lang/rust-bindgen/pull/3015
https://github.com/rust-lang/rust-bindgen/issues/3052

As an immediate workaround, you could 1) tag the old bindgen-cli into a side-tag to build chromium, or 2) pass "--rust-target 1.79" to the bindgen CLI call (not sure if this would be possible with chromium's build system).

I'll take a look if it's possible to fix Rust target version selection in general ...

Comment 2 Than Ngo 2025-05-08 12:44:08 UTC
Hello Fabio,

it's no problem to patch Chromium to pass “--rust-target 1.79” to the bindgen CLI call. I will add this workaround before we have a final solution for this issue.

Thanks a lot for this!


Note You need to log in before you can comment on or make changes to this bug.