beaufortfrancois / webgpu-cross-platform-app

WebGPU cross-platform app with CMake/Emscripten
https://developer.chrome.com/docs/web-platform/webgpu/build-app
82 stars 6 forks source link

Dawn compilation error Ubuntu 22.04 #2

Closed pierricgimmig closed 8 months ago

pierricgimmig commented 8 months ago

Hi @beaufortfrancois , thanks for this repo, it's exactly what I was looking for. I compiled it easily on MacOS following the README.

On Ubuntu 22.04 however, I get this error:

CMake Error at dawn/third_party/CMakeLists.txt:74 (add_subdirectory):
  add_subdirectory given source
  "/home/pierric/git/webgpu-cross-platform-app/dawn/third_party/vulkan-deps/glslang/src"
  which is not an existing directory.

Do you know why? I noticed the same thing building the standalone Dawn repo on Ubuntu using CMake without depot_tools. I was only able to build Dawn using depot_tools and Ninja.

It would be great to have this minimalist project template working on Ubuntu. Thanks for your help!

beaufortfrancois commented 8 months ago

The version of Dawn used in this program may be the culprit here: https://github.com/beaufortfrancois/webgpu-cross-platform-app/blob/main/.gitmodules#L4

You can update it and see if it works better for you with:

cd webgpu-cross-platform-app/dawn
git pull origin main
cd -
cmake -B build && cmake --build build -j4
pierricgimmig commented 8 months ago

Thanks for the suggestion. I switched to Dawn's main branch, I get further, but now get a linking error:

[100%] Linking CXX executable app
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::AdapterProperties::~AdapterProperties()':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2491: undefined reference to `wgpuAdapterPropertiesFreeMembers'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::SharedTextureMemoryEndAccessState::~SharedTextureMemoryEndAccessState()':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2543: undefined reference to `wgpuSharedTextureMemoryEndAccessStateFreeMembers'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::CreateDevice(wgpu::DeviceDescriptor const*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2585: undefined reference to `wgpuAdapterCreateDevice'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::EnumerateFeatures(wgpu::FeatureName*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2589: undefined reference to `wgpuAdapterEnumerateFeatures'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::GetInstance() const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2593: undefined reference to `wgpuAdapterGetInstance'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::GetLimits(wgpu::SupportedLimits*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2597: undefined reference to `wgpuAdapterGetLimits'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::GetProperties(wgpu::AdapterProperties*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2602: undefined reference to `wgpuAdapterGetProperties'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::HasFeature(wgpu::FeatureName) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2605: undefined reference to `wgpuAdapterHasFeature'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::RequestDevice(wgpu::DeviceDescriptor const*, void (*)(WGPURequestDeviceStatus, WGPUDeviceImpl*, char const*, void*), void*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:2609: undefined reference to `wgpuAdapterRequestDevice

I'm on commit 89290bbf58997ed43993745fc8d993f2e34325e4

beaufortfrancois commented 8 months ago

Argh... you may be hitting a bug in the main branch only. Can you reproduce with chromium/6045 (Chrome 119) instead of main for instance?

pierricgimmig commented 8 months ago

with chromium/6045, I get:

[ 98%] Building CXX object dawn/src/dawn/native/CMakeFiles/dawn_native.dir/vulkan/StreamImplVk.cpp.o
[ 98%] Building CXX object dawn/src/dawn/native/CMakeFiles/dawn_native.dir/vulkan/SwapChainVk.cpp.o
In file included from /home/pierric/git/webgpu-cross-platform-app/dawn/src/dawn/native/vulkan/StreamImplVk.cpp:23:
/home/pierric/git/webgpu-cross-platform-app/dawn/third_party/vulkan-deps/vulkan-utility-libraries/src/include/vulkan/utility/vk_struct_helper.hpp:670:45: error: ‘VkCudaModuleCreateInfoNV’ was not declared in this scope; did you mean ‘VkCuModuleCreateInfoNVX’?
  670 | template <> inline VkStructureType GetSType<VkCudaModuleCreateInfoNV>() { return VK_STRUCTURE_TYPE_CUDA_MODULE_CREATE_INFO_NV; }
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                             VkCuModuleCreateInfoNVX
/home/pierric/git/webgpu-cross-platform-app/dawn/third_party/vulkan-deps/vulkan-utility-libraries/src/include/vulkan/utility/vk_struct_helper.hpp:670:36: error: template-id ‘GetSType<<expression error> >’ for ‘VkStructureType vku::GetSType()’ does not match any template declaration
  670 | template <> inline VkStructureType GetSType<VkCudaModuleCreateInfoNV>() { return VK_STRUCTURE_TYPE_CUDA_MODULE_CREATE_INFO_NV; }
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/pierric/git/webgpu-cross-platform-app/dawn/src/dawn/native/vulkan/StreamImplVk.cpp:23:
/home/pierric/git/webgpu-cross-platform-app/dawn/third_party/vulkan-deps/vulkan-utility-libraries/src/include/vulkan/utility/vk_struct_helper.hpp:15:17: note: candidate is: ‘template<class T> VkStructureType vku::GetSType()’
   15 | VkStructureType GetSType() {
      |                 ^~~~~~~~
In file included from /home/pierric/git/webgpu-cross-platform-app/dawn/src/dawn/native/vulkan/StreamImplVk.cpp:23:
/home/pierric/git/webgpu-cross-platform-app/dawn/third_party/vulkan-deps/vulkan-utility-libraries/src/include/vulkan/utility/vk_struct_helper.hpp:671:45: error: ‘VkCudaFunctionCreateInfoNV’ was not declared in this scope; did you mean ‘VkCuFunctionCreateInfoNVX’?
  671 | template <> inline VkStructureType GetSType<VkCudaFunctionCreateInfoNV>() { return VK_STRUCTURE_TYPE_CUDA_FUNCTION_CREATE_INFO_NV; }
beaufortfrancois commented 8 months ago

Is it possible you didn't you update dawn git submodules as well? I forgot to mention it.

pierricgimmig commented 8 months ago

I ran

git submodule update --recursive in the webgpu-cross-platform-app root directory,

then wiped the build directory with

rm -rf build

I get further, but now hitting a linking error:

[100%] Dawn: Generating files for Dawn native WebGPU procs.
[100%] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/__/__/Placeholder.cpp.o
[100%] Building CXX object dawn/src/dawn/native/CMakeFiles/webgpu_dawn.dir/__/__/__/gen/src/dawn/native/webgpu_dawn_native_proc.cpp.o
[100%] Linking CXX static library libwebgpu_dawn.a
[100%] Built target webgpu_dawn
[100%] Building CXX object CMakeFiles/app.dir/main.cpp.o
[100%] Linking CXX executable app
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::CreateDevice(wgpu::DeviceDescriptor const*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:1974: undefined reference to `wgpuAdapterCreateDevice'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::EnumerateFeatures(wgpu::FeatureName*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:1978: undefined reference to `wgpuAdapterEnumerateFeatures'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::GetInstance() const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:1982: undefined reference to `wgpuAdapterGetInstance'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::GetLimits(wgpu::SupportedLimits*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:1986: undefined reference to `wgpuAdapterGetLimits'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::GetProperties(wgpu::AdapterProperties*) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:1990: undefined reference to `wgpuAdapterGetProperties'
/usr/bin/ld: dawn/src/dawn/libdawncpp.a(webgpu_cpp.cpp.o): in function `wgpu::Adapter::HasFeature(wgpu::FeatureName) const':
/home/pierric/git/webgpu-cross-platform-app/build/dawn/gen/src/dawn/webgpu_cpp.cpp:1993: undefined reference to `wgpuAdapterHasFeature'
beaufortfrancois commented 8 months ago

@kainino0x Any idea why @pierricgimmig is hitting a linking error?

kainino0x commented 8 months ago

No, I don't know that much about the current state of build stuff in Dawn. That looks like it has webgpu_cpp but not the rest of Dawn for some reason. Maybe the targets that need to be linked together has changed?

beaufortfrancois commented 8 months ago

FYI This works fine on macOS. @pierricgimmig Did you make progress?

pierricgimmig commented 8 months ago

It looks like webgpu_dawn_native_proc.cpp is not compiled in the cmake build, but not sure why it would work on MacOs and not Linux... will look into it further tomorrow.

pierricgimmig commented 8 months ago

@beaufortfrancois , https://github.com/beaufortfrancois/webgpu-cross-platform-app/pull/4 fixes it for me on Ubuntu, but I havent't tested on other platforms