mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.47k stars 1.58k forks source link

Rust bindgen with output_inline_wrapper create c file with incorrect include path if build directory is not inside source directory #13227

Open Billli11 opened 3 months ago

Billli11 commented 3 months ago

Describe the bug mesa rusticl recently updated to use output_inline_wrapper feature to build,
causing build failure when building AUR package mesa-git with rusticl enable with following error.

src/gallium/frontends/rusticl/rusticl_mesa_bindings.c:1:10: fatal error: '../mesa/src/gallium/frontends/rusticl/rusticl_mesa_bindings.h' file not found

The problem is because the path to header is a relative path point to source directory.
Creating invalid include path in the generated c file.

first line of src/gallium/frontends/rusticl/rusticl_mesa_bindings.c meson setup mesa _build

#include "../mesa/src/gallium/frontends/rusticl/rusticl_mesa_bindings.h

`meson setup mesa mesa/_build'

#include "../src/gallium/frontends/rusticl/rusticl_mesa_bindings.h"

meson setup mesa mesa/_test/_build

#include "../../src/gallium/frontends/rusticl/rusticl_mesa_bindings.h"

To Reproduce

git clone https://gitlab.freedesktop.org/mesa/mesa.git mesa
meson setup mesa _build  -Dgallium-rusticl=true -Dllvm=enabled -Drust_std=2021 -Dgallium-drivers=swrast -Dvulkan-drivers=swrast
ninja -C _build

Expected behavior A clear and concise description of what you expected to happen.

system parameters

ThatOneCalculator commented 3 months ago

This is a mesa issue, not a meson issue. https://gitlab.freedesktop.org/mesa/mesa/-/issues/11178

For now, use this diff on the PKGBUILD

diff --git a/PKGBUILD b/PKGBUILD
index 68b0dac..701a628 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -216,10 +216,10 @@ pkgver() {
 }

 prepare() {
-    # although removing _build folder in build() function feels more natural,
+    # although removing mesa/_build folder in build() function feels more natural,
     # that interferes with the spirit of makepkg --noextract
-    if [  -d _build ]; then
-        rm -rf _build
+    if [  -d mesa/_build ]; then
+        rm -rf mesa/_build
     fi

     local _patchfile
@@ -278,13 +278,13 @@ build () {
     CFLAGS+=' -g1'
     CXXFLAGS+=' -g1'

-    meson setup mesa _build "${meson_options[@]}"
-    meson configure --no-pager _build
-    ninja $NINJAFLAGS -C _build
+    meson setup mesa mesa/_build "${meson_options[@]}"
+    meson configure --no-pager mesa/_build
+    ninja $NINJAFLAGS -C mesa/_build
 }

 package() {
-    DESTDIR="${pkgdir}" ninja $NINJAFLAGS -C _build install
+    DESTDIR="${pkgdir}" ninja $NINJAFLAGS -C mesa/_build install

     # remove script file from /usr/bin
     # https://gitlab.freedesktop.org/mesa/mesa/issues/2230
karolherbst commented 2 months ago

fyi I have an MR against mesa for this: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29275

though I do wonder what the preferred solution to this issue should look like.