Closed ghost closed 10 months ago
Okey this means there is a problem with the RPATH set in CMake, I have to investigate this.
Could you try again now on linux?
And could you test mac if that's easy for you? I did not fix it because I couldn't test; try maybe this in CMakeLists.txt:
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(WGPU_RUNTIME_LIB ${WGPU}/bin/macos-${ARCH}/libwgpu_native.dylib)
set_target_properties(
webgpu
PROPERTIES
IMPORTED_LOCATION "libwgpu_native.dylib" # change here
INTERFACE_INCLUDE_DIRECTORIES "${WGPU}/include"
)
else()
# [...]
# In target_copy_webgpu_binaries function:
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set_target_properties(${Target} PROPERTIES INSTALL_RPATH "$ORIGIN/")
set_target_properties(${Target} PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set_target_properties(${Target} PROPERTIES INSTALL_RPATH "@executable_path/") # change here
set_target_properties(${Target} PROPERTIES BUILD_WITH_INSTALL_RPATH ON) # change here
# remove what's left here
endif()
Not solving the issue... This seems like a CMake-side problem actually TBH: the generated executable tries to link _deps/.../libwgpu_native.so
and at the same time sets the RPATH to /full/path/to/_deps/.../
. It should do only one of the two, i.e. keep the rpath this way but with link to libwgpu_native.so
without a path prefix.
Dynamic section at offset 0x4e6c8 contains 35 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libdl.so.2]
0x0000000000000001 (NEEDED) Shared library: [libX11.so.6]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED) Shared library: [_deps/webgpu-backend-wgpu-src/bin/linux-x86_64/libwgpu_native.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000001d (RUNPATH) Library runpath: [/mnt/g/SourceCode/LearnWebGPU-Code-folded/build-wgpu-gcc/_deps/webgpu-backend-wgpu-src/bin/linux-x86_64]
All right, turning on the IMPORTED_NO_SONAME
target option does the trick, and feels much cleaner. Not sure it would work with macOS though.
Weird, I just tried to run step005 and it worked. I saw that the last time the branch was modified was 2 weeks ago. Not sure what exactly changed, but now it works without any modifications.
I cannot check that on Mac though, only Linux.
The issue was not in the branch itself but in the CMakeLists of the WebGPU distribution it was fetching! That's what I updated on July 14, hence the fix.
Many of the examples include "./build/App" for Linux (and MacOS) as a way to start the application, but it doesn't work with relative path, you have to
cd
into the build folder and then execute./App
, to work as expected.