Skip to content

Allow static building of the monolithic dawn library: (lib)webgpu_dawn #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

manuel5975p
Copy link
Contributor

  • Update BundleLibraries to take another argument (STATIC or SHARED)
  • Change DAWN_BUILD_MONOLITHIC_LIBRARY from OFF/ON to OFF/STATIC/SHARED

Copy link

👋 Thanks for your contribution! Your PR has been imported to Gerrit.
Please visit https://dawn-review.googlesource.com/c/dawn/+/238874 to see it and CC yourself on the change.
After iterating on feedback, please comment on the Gerrit review to notify reviewers.
All reviews are handled within Gerrit, any comments on the GitHub PR may be missed.
You can continue to upload commits to this PR, and they will be automatically imported
into Gerrit.

kommander pushed a commit to kommander/dawn that referenced this pull request May 22, 2025
- Update BundleLibraries to take another argument (STATIC or SHARED)
- Change DAWN_BUILD_MONOLITHIC_LIBRARY from OFF/ON to OFF/STATIC/SHARED

This is an imported pull request from
google#33

GITHUB_PR_HEAD_SHA=74b9f13d2c44fbdc8bc8cbede44325ff1f75b164
ORIGINAL_AUTHOR=Manuel <[email protected]>
GitOrigin-RevId: 44f76ba
Change-Id: I69dc673656e43c6c1a3c710ece00ecf16a8b9cde
@wcandillon
Copy link

@manuel5975p Thank You for making this PR, this is an option that would be useful to us as well ☺️

@fs-eire
Copy link
Contributor

fs-eire commented Jul 20, 2025

I saw the change is merged (https://dawn-review.googlesource.com/c/dawn/+/238874). However, the implementation is changed and the following change is no longer there:

Change DAWN_BUILD_MONOLITHIC_LIBRARY from OFF/ON to OFF/STATIC/SHARED

With the latest change, how do I consume Dawn as a monolithic (static/dynamic) library? Is there an example?

@Kangz
Copy link
Collaborator

Kangz commented Jul 21, 2025

You'd use the standard CMake variable BUILD_SHARED_LIBS on/off.

@fs-eire
Copy link
Contributor

fs-eire commented Jul 22, 2025

I am not directly building Dawn but consume it as a dependency in my project. I got the following error:

Error Messages
CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "dawn_internal_config" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target "dawn_common"
  that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "dawn_platform" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "dawncpp_headers" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "partition_alloc" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "flat_hash_map" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "flat_hash_set" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "inlined_vector" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target
  "str_format_internal" that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target "strings"
  that is not in any export set.


CMake Error in _deps/dawn-src/CMakeLists.txt:
  export called with target "webgpu_dawn" which requires target "tint_api"
  that is not in any export set.

This used to work before this change is merged. Do you know how I can fix it?

@wcandillon
Copy link

I also tried to use DAWN_BUILD_MONOLITHIC_LIBRARY=static as part of the review comments for #39 and encountered the same build error as @fs-eire: https://github.com/google/dawn/actions/runs/16437585953/job/46450622134?pr=39

@Kangz
Copy link
Collaborator

Kangz commented Jul 22, 2025

Can you check if https://dawn-review.googlesource.com/c/dawn/+/254234 fixes it?

@fs-eire
Copy link
Contributor

fs-eire commented Jul 22, 2025

Can you check if https://dawn-review.googlesource.com/c/dawn/+/254234 fixes it?

Now that it works with static build! but the dynamic build (BUILD_SHARED_LIBS=ON) failed of the following error message:

CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
  "clangParse" of type SHARED_LIBRARY
    depends on "clangAST" (weak)
    depends on "clangSema" (weak)
  "clangAST" of type SHARED_LIBRARY
    depends on "clangCodeGen" (weak)
    depends on "clangSema" (weak)
  "clangSema" of type SHARED_LIBRARY
    depends on "clangAST" (weak)
    depends on "clangAnalysis" (weak)
    depends on "clangEdit" (weak)
  "clangCodeGen" of type SHARED_LIBRARY
    depends on "clangAST" (weak)
    depends on "clangFrontend" (weak)
  "clangAnalysis" of type SHARED_LIBRARY
    depends on "clangAST" (weak)
  "clangEdit" of type SHARED_LIBRARY
    depends on "clangAST" (weak)
  "clangFrontend" of type SHARED_LIBRARY
    depends on "clangAST" (weak)
    depends on "clangEdit" (weak)
    depends on "clangParse" (weak)
    depends on "clangSema" (weak)
At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.
CMake Generate step failed.  Build files cannot be regenerated correctly.

@Kangz
Copy link
Collaborator

Kangz commented Jul 23, 2025

Try again with https://dawn-review.googlesource.com/c/dawn/+/254234/ and the previous commit? But Dawn doesn't use clang so the error log seems unrelated.

@dj2
Copy link
Collaborator

dj2 commented Jul 23, 2025

Are you building with DXC? You may want to try disabling that as it's possibly what's triggering the clang in your build. (It's the only thing in Dawn that would build clang). Setting DAWN_USE_BUILT_DXC to false in your cmake configure should disable it.

@fs-eire
Copy link
Contributor

fs-eire commented Jul 23, 2025

Are you building with DXC? You may want to try disabling that as it's possibly what's triggering the clang in your build. (It's the only thing in Dawn that would build clang). Setting DAWN_USE_BUILT_DXC to false in your cmake configure should disable it.

Yes I am building DXC. I cannot set DAWN_USE_BUILT_DXC to false because a few features are guarded by the build definition (eg. ShaderF16).

#if defined(DAWN_USE_BUILT_DXC)
// ShaderF16 features require DXC version being 1.4 or higher, shader model supporting 6.2 or
// higher, and native supporting F16 shader ops.
if (mDeviceInfo.highestSupportedShaderModel >= 62 && mDeviceInfo.supportsNative16BitShaderOps) {
EnableFeature(Feature::ShaderF16);
}

@fs-eire
Copy link
Contributor

fs-eire commented Jul 24, 2025

Try again with https://dawn-review.googlesource.com/c/dawn/+/254234/ and the previous commit? But Dawn doesn't use clang so the error log seems unrelated.

I tried the latest change (Patchset 4) and do not set BUILD_SHARED_LIBS this time. Instead, I uses DAWN_BUILD_MONOLITHIC_LIBRARY=SHARED|STATIC. Now it works as expected!

the previous build error related to clang is from DXC. seems it is not compatible with BUILD_SHARED_LIBS=ON.

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.

5 participants