Skip to content

Conversation

@theoparis
Copy link

  • Allow building shared libraries with -DBUILD_SHARED_LIBS=ON
  • Add cmake install target

@theoparis theoparis changed the title Allow building shared libraries Fix cmake build files Jul 26, 2025
@theoparis theoparis marked this pull request as draft July 26, 2025 06:45
@theoparis theoparis closed this Jul 26, 2025
@manuel5975p
Copy link
Owner

@theoparis Hey, that actually seems like a good PR, you wanna reopen this?

@theoparis theoparis reopened this Jul 27, 2025
- Allow building shared libraries with -DBUILD_SHARED_LIBS=ON
- Add cmake install target
@theoparis theoparis force-pushed the push-xzwmkonypprl branch from f5b4d7c to 1bf771f Compare July 27, 2025 21:59
@theoparis
Copy link
Author

At first I had issues with the bundling of objects. It seems to work fine with just linking against tint_c_api with -DBUILD_SHARED_LIBS=off and CMAKE_POSITION_INDEPEDENT_CODE added so I'm not sure why that was needed.
I also ran into segfaults with wgpu create shader module functions when the examples were built but WGSL support wasn't enabled. I haven't solved that yet.

@manuel5975p
Copy link
Owner

Segfaulting when compiling wgsl without support for it is on me, that needs to be gracefully handled in wgpuCreateShaderModule.
However is it possible to keep the call to wgvk_bundle_libraries? Otherwise the static libwgvk.a will not be usable standalone.

# they will now correctly inherit all necessary compile definitions.
target_link_libraries(glfw_surface PUBLIC wgvk glfw)
target_link_libraries(basic_wgsl_shader PUBLIC wgvk glfw)
target_link_libraries(basic_wgsl_shader PUBLIC wgvk glfw m)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break windows, it has no libm.

Copy link
Author

@theoparis theoparis Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point. Is this PR needed now that 4258744 exists though? I get

/home/theo/src/WGVK/src/glslang_c_api.cpp:80:(.text+0x1f8): dangerous relocation: unsupported relocation
/usr/bin/ld: CMakeFiles/glslang_c_api.dir/src/glslang_c_api.cpp.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN7glslang7TShader14ForbidIncluderE' which may bind externally can not be used when making a shared object; recompile with -fPIC

Using BUILD_SHARED_LIBS with the latest commit 👀 Additionally disabling the examples breaks BUILD_SHARED_LIBS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, this PR isn't needed, sorry.
But the commit you mentioned still has that problem. I guess we don't test building the examples in CI yet and that's why it's not caught.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants