wcandillon / react-native-webgpu

React Native implementation of WebGPU using Dawn
MIT License
412 stars 19 forks source link

Unable to build dawn #83

Closed okwasniewski closed 1 week ago

okwasniewski commented 2 months ago

Hey,

I'm trying to build dawn on iOS but unfortunately Im encoutering a build issue.

Steps:

  1. Clone the repo
  2. git submodule update --init
  3. cd package && yarn
  4. yarn build-dawn <- fails

Is there anything I missed?

The error:

🍏 arm64 iphoneos [264/903] Building CXX object third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/escaping.cc.o
🍏 arm64 iphoneos [265/903] Building CXX object third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/internal/damerau_levenshtein_distance.cc.o
FAILED: third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/internal/damerau_levenshtein_distance.cc.o
/usr/bin/g++  -I/Users/okwasniewski/workspace/react-native-webgpu/externals/dawn/third_party/abseil-cpp -O3 -DNDEBUG -std=c++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -fPIC -Wno-array-parameter -Wno-deprecated-builtins -Wno-unknown-warning-option -Wall -Wextra -Wc++98-compat-extra-semi -Wcast-qual -Wconversion -Wdead-code-aggressive -Wdeprecated-pragma -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wfor-loop-analysis -Wformat-security -Wgnu-redeclared-enum -Winfinite-recursion -Winvalid-constexpr -Wliteral-conversion -Wmissing-declarations -Woverlength-strings -Wpointer-arith -Wself-assign -Wshadow-all -Wshorten-64-to-32 -Wsign-conversion -Wstring-conversion -Wtautological-overlap-compare -Wtautological-unsigned-zero-compare -Wundef -Wuninitialized -Wunreachable-code -Wunused-comparison -Wunused-local-typedefs -Wunused-result -Wvla -Wwrite-strings -Wno-float-conversion -Wno-implicit-float-conversion -Wno-implicit-int-float-conversion -DNOMINMAX -MD -MT third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/internal/damerau_levenshtein_distance.cc.o -MF third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/internal/damerau_levenshtein_distance.cc.o.d -o third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/internal/damerau_levenshtein_distance.cc.o -c /Users/okwasniewski/workspace/react-native-webgpu/externals/dawn/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc
fatal error: error in backend: live register clobbered by inserted prologue instructions
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple clang version 16.0.0 (clang-1600.0.20.10)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /var/folders/nc/lg2x6s_x2tz9q0zxs01j1qfc0000gn/T/damerau_levenshtein_distance-92bc71.cpp
clang++: note: diagnostic msg: /var/folders/nc/lg2x6s_x2tz9q0zxs01j1qfc0000gn/T/damerau_levenshtein_distance-92bc71.sh
clang++: note: diagnostic msg: Crash backtrace is located in
clang++: note: diagnostic msg: /Users/okwasniewski/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang++: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang++: note: diagnostic msg:

********************
🍏 arm64 iphoneos [266/903] Building CXX object third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/numbers.cc.o
🍏 arm64 iphoneos [267/903] Building CXX object third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/str_cat.cc.o
🍏 arm64 iphoneos [268/903] Building CXX object third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/str_replace.cc.o
🍏 arm64 iphoneos [269/903] Building CXX object third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/str_split.cc.o
🍏 arm64 iphoneos [270/903] Building CXX object third_party/abseil/absl/strings/CMakeFiles/absl_strings.dir/substitute.cc.o
🍏 arm64 iphoneos [271/903] Building CXX object third_party/abseil/absl/time/CMakeFiles/absl_civil_time.dir/internal/cctz/src/civil_time_detail.cc.o
🍏 arm64 iphoneos [272/903] Building CXX object third_party/abseil/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_fixed.cc.o
🍏 arm64 iphoneos [273/903] Building CXX object third_party/abseil/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_if.cc.o
🍏 arm64 iphoneos [274/903] Building CXX object third_party/abseil/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_impl.cc.o
🍏 arm64 iphoneos [275/903] Building CXX object third_party/abseil/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_format.cc.o
🍏 arm64 iphoneos [276/903] Building CXX object third_party/abseil/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_info.cc.o
🍏 arm64 iphoneos ninja: build stopped: subcommand failed.
/Users/okwasniewski/workspace/react-native-webgpu/package/scripts/build/util.ts:39
        reject(new Error(`${label} exited with code ${code}`));
               ^
Error: 🍏 arm64 iphoneos exited with code 1
    at ChildProcess.<anonymous> (/Users/okwasniewski/workspace/react-native-webgpu/package/scripts/build/util.ts:39:16)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess.emit (node:domain:488:12)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:domain:488:12)
    at Pipe.<anonymous> (node:net:338:12)
wcandillon commented 2 months ago

Are you using the latest XCode version tooling?

wcandillon commented 2 months ago

These steps are also executed automatically on our github actions: https://github.com/wcandillon/react-native-webgpu/blob/main/.github/workflows/build-dawn.yml so this might help as well. And you can download the prebuilt binaries directly if you want to skip this step altogether: https://github.com/wcandillon/react-native-webgpu/actions/runs/10156718895

Maybe it would be fun to have a script in the example so if the prebuild binaries are not available, download them from Github. Maybe it's something you could setup/contribute.

matthargett commented 2 months ago

If you replace the -O3 with -O2 on the command line, does that fix it? This is ultimately an Internal Compiler Error in Xcode’s clang, so the issue is there. That said, there is hopefully a workaround that doesn’t dramatically impact end-to-end performance.

okwasniewski commented 2 months ago

@wcandillon Yeah, this would be really useful. I'll try to implement this once I get the build working locally :) For now I've created a draft PR adding visionOS support to see if maybe the CI will build it properly: https://github.com/wcandillon/react-native-webgpu/pull/88

okwasniewski commented 2 months ago

Are you using the latest XCode version tooling?

Im running Xcode 16 beta, but I've also tested out Xcode 15, no luck on both.

If you replace the -O3 with -O2 on the command line, does that fix it? This is ultimately an Internal Compiler Error in Xcode’s clang, so the issue is there. That said, there is hopefully a workaround that doesn’t dramatically impact end-to-end performance.

Looks like it's passed to some dependency of dawn but one of their build scripts, I'll try to check if but if its working for William then it must be something on my machine

okwasniewski commented 2 months ago

Oh finally I've been able to run this on iOS. Dawn is now successfully building for iOS and visionOS but something is still wrong in the copy headers step.. I've took the cpp folder from the Github CI/CD and only then it worked! Im going to investigate this

CleanShot 2024-08-26 at 13 42 23@2x

wcandillon commented 1 week ago

I guess we can close this right?