Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 946913 - media-libs/mesa-24.3.2 - fails to compile src/gallium/frontends/rusticl/rusticl_libc_bindings.rs, unsafe extern "C" error: extern block cannot be declared unsafe
Summary: media-libs/mesa-24.3.2 - fails to compile src/gallium/frontends/rusticl/rusti...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords: PullRequest
: 950195 (view as bug list)
Depends on: 946887 950262
Blocks:
  Show dependency tree
 
Reported: 2024-12-25 13:48 UTC by jospezial
Modified: 2025-03-12 23:21 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log bzipped (build.log.bz2,159.48 KB, application/x-bzip2)
2024-12-25 13:48 UTC, jospezial
Details
emerge --info (emerge--info.txt,10.91 KB, text/plain)
2024-12-25 13:50 UTC, jospezial
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jospezial 2024-12-25 13:48:59 UTC
Created attachment 914862 [details]
build.log bzipped

[ebuild     U  ]              media-libs/mesa-24.3.2::gentoo [24.3.0::gentoo] USE="X d3d9 llvm lm-sensors opencl (opengl) proprietary-codecs vaapi vulkan wayland zstd -debug -osmesa (-selinux) -test -unwind -valgrind -vdpau -xa" ABI_X86="32 (64) (-x32)" CPU_FLAGS_X86="sse2" LLVM_SLOT="18 -15 -16 -17" VIDEO_CARDS="radeon radeonsi -d3d12 (-freedreno) -intel -lavapipe (-lima) -nouveau -nvk (-panfrost) -r300 -r600 (-v3d) (-vc4) -virgl (-vivante) -vmware -zink" 0 KiB



[1460/1846] /opt/rust-bin-1.81.0/bin/rustc -C linker=x86_64-pc-linux-gnu-gcc --color=always -C debug-assertions=no -C overflow-checks=no --crate-type rlib --edition=2021 --crate-name libc_rust_gen --emit dep-info=src/gallium/frontends/rusticl/libc_rust_gen.d --emit link=src/gallium/frontends/rusticl/liblibc_rust_gen.rlib --out-dir src/gallium/frontends/rusticl/liblibc_rust_gen.rlib.p -C metadata=b863b06@@libc_rust_gen@sta -Aclippy::all -Aimproper_ctypes -Aunused_unsafe -Anon_camel_case_types -Anon_snake_case -Anon_upper_case_globals src/gallium/frontends/rusticl/rusticl_libc_bindings.rs
FAILED: src/gallium/frontends/rusticl/liblibc_rust_gen.rlib 
/opt/rust-bin-1.81.0/bin/rustc -C linker=x86_64-pc-linux-gnu-gcc --color=always -C debug-assertions=no -C overflow-checks=no --crate-type rlib --edition=2021 --crate-name libc_rust_gen --emit dep-info=src/gallium/frontends/rusticl/libc_rust_gen.d --emit link=src/gallium/frontends/rusticl/liblibc_rust_gen.rlib --out-dir src/gallium/frontends/rusticl/liblibc_rust_gen.rlib.p -C metadata=b863b06@@libc_rust_gen@sta -Aclippy::all -Aimproper_ctypes -Aunused_unsafe -Anon_camel_case_types -Anon_snake_case -Anon_upper_case_globals src/gallium/frontends/rusticl/rusticl_libc_bindings.rs
error: extern block cannot be declared unsafe
 --> src/gallium/frontends/rusticl/rusticl_libc_bindings.rs:3:1
  |
3 | unsafe extern "C" {
  | ^^^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information

error: extern block cannot be declared unsafe
 --> src/gallium/frontends/rusticl/rusticl_libc_bindings.rs:9:1
  |
9 | unsafe extern "C" {
  | ^^^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information

error: extern block cannot be declared unsafe
  --> src/gallium/frontends/rusticl/rusticl_libc_bindings.rs:12:1
   |
12 | unsafe extern "C" {
   | ^^^^^^
   |
   = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information

error: extern block cannot be declared unsafe
  --> src/gallium/frontends/rusticl/rusticl_libc_bindings.rs:15:1
   |
15 | unsafe extern "C" {
   | ^^^^^^
   |
   = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information

error: aborting due to 4 previous errors
Comment 1 jospezial 2024-12-25 13:50:07 UTC
Created attachment 914863 [details]
emerge --info
Comment 2 jospezial 2024-12-25 13:53:03 UTC
same with mesa-9999
last successful build was 24.3.1 which had runtime crashes.
Comment 3 Holger Hoffstätte 2024-12-25 14:58:40 UTC
"unsafe extern" blocks require >=1.82 aka "2024 edition".
Comment 4 jospezial 2024-12-25 19:06:40 UTC
(In reply to Holger Hoffstätte from comment #3)
> "unsafe extern" blocks require >=1.82 aka "2024 edition".

That would require either
llvm slot 19 for mesa
or
rust >=1.82 with llvm slot 18, if that works.
Comment 5 jospezial 2025-01-01 00:44:04 UTC
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3c0b4a10435fe8fc45ff51d4818268779cd7f50b
media-libs/mesa: Add LLVM_SLOT=19

9999 works now
Comment 6 Matt Jolly gentoo-dev 2025-02-24 05:08:31 UTC
*** Bug 950195 has been marked as a duplicate of this bug. ***
Comment 7 Matt Jolly gentoo-dev 2025-02-24 05:39:35 UTC
This is not fixed, see the duplicate bug.

It appears that Rust < 1.82.0 can't successfully build 24.3.2. That doesn't appear to make sense based on the upstream Rust minimum requirements:

https://docs.mesa3d.org/rusticl.html

However 'unsafe extern' requires at least 1.82.0.

https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html

Haven't been able to reproduce this locally but I suspect that bindgen is targeting the wrong edition of Rust or something along those lines.
Comment 8 Eli Schwartz gentoo-dev 2025-02-25 01:45:12 UTC
This is a meson bug fixed in meson 1.7.0
Comment 9 Larry the Git Cow gentoo-dev 2025-02-28 15:11:56 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a89a5cd12f2e2f63684df1790b8cf9162ce4d90b

commit a89a5cd12f2e2f63684df1790b8cf9162ce4d90b
Author:     Matt Jolly <kangie@gentoo.org>
AuthorDate: 2025-02-25 03:27:41 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2025-02-28 15:10:58 +0000

    media-libs/mesa: bump meson and bindgen deps for Rust-related USE
    
    Due to a bug in Meson < 1.7.0, it is possible for bindgen to generate
    code that is not compatible with the compiler in use. This has the
    potential to cause build failures when e.g. edition 2024 bindings
    are generated for a compiler that only supports edition 2021 code.
    
    A patch has been submitted upstream to enforce this dependency in
    the Meson build scripts, however we can just enforce dependencies
    on appropriate bindgen and Meson versions if the USE flags that
    generate bindings are selected.
    
    Bug: https://bugs.gentoo.org/946913
    Bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12680
    Signed-off-by: Matt Jolly <kangie@gentoo.org>
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 media-libs/mesa/mesa-25.0.0.ebuild | 6 ++++--
 media-libs/mesa/mesa-9999.ebuild   | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-03-12 23:21:08 UTC
meson-1.7.0 is stable now.