AnswerDotAI / gpu.cpp

A lightweight library for portable low-level GPU computation using WebGPU.
https://gpucpp.answer.ai
Apache License 2.0
3.75k stars 177 forks source link

Error building libprotobuf-mutator on macos #1

Closed junjihashimoto closed 5 months ago

junjihashimoto commented 5 months ago

Compilation error occurs when building libprotobuf-mutator on macos.

$ make 
...
[ 21%] Building CXX object third_party/dawn-build/src/tint/CMakeFiles/tint_utils_rtti.dir/utils/rtti/castable.cc.o
In file included from /Users/junji.hashimoto/git/gpu.cpp/third_party/dawn-src/third_party/libprotobuf-mutator/src/src/mutator.cc:27:
/Users/junji.hashimoto/git/gpu.cpp/third_party/dawn-src/third_party/libprotobuf-mutator/src/src/field_instance.h:195:34: error: no member named 'syntax' in 'google::protobuf::FileDescriptor'
           descriptor()->file()->syntax() ==
           ~~~~~~~~~~~~~~~~~~~~  ^
/Users/junji.hashimoto/git/gpu.cpp/third_party/dawn-src/third_party/libprotobuf-mutator/src/src/field_instance.h:196:42: error: no member named 'SYNTAX_PROTO3' in 'google::protobuf::FileDescriptor'
               protobuf::FileDescriptor::SYNTAX_PROTO3;
               ~~~~~~~~~~~~~~~~~~~~~~~~~~^
/Users/junji.hashimoto/git/gpu.cpp/third_party/dawn-src/third_party/libprotobuf-mutator/src/src/mutator.cc:92:24: error: no member named 'syntax' in 'google::protobuf::FileDescriptor'
  return field.file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
         ~~~~~~~~~~~~  ^
/Users/junji.hashimoto/git/gpu.cpp/third_party/dawn-src/third_party/libprotobuf-mutator/src/src/mutator.cc:92:52: error: no member named 'SYNTAX_PROTO3' in 'google::protobuf::FileDescriptor'
  return field.file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
                                   ~~~~~~~~~~~~~~~~^
...
$ uname -a
Darwin G-PC-01239990 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64 arm Darwin
$ brew info protobuf
==> protobuf: stable 27.0 (bottled)
...
austinvhuang commented 5 months ago

Thanks for filing the inaugural issue @junjihashimoto ! Can you try again with HEAD and make clean before make?

The dawn build is more brittle and opaque than I would like. Going through the WebGPU-distribution intermediary isn't ideal but I haven't found a better solution + may pin to specific commits in the near future.

junjihashimoto commented 5 months ago

I tried the HEAD (2223ea40d635d9d6872840ab6fb0e8076191b82b). But the error remains. I can build the latest branch of https://dawn.googlesource.com/dawn on macos. For now, I'll try gpu.cpp with the latest dawn.

junjihashimoto commented 5 months ago

It works with the latest dawn, but it needs to link many libraries as follows:

$ clang++ -o main ./CMakeFiles/run_demo.dir/run.cpp.o ../dawn/out/Debug/src/tint/libtint_*.a ../dawn/out/Debug//src/dawn/platform/libdawn_platform.a ../dawn/out/Debug//src/dawn/common/libdawn_common.a ../dawn/out/Debug/src/dawn/native/libdawn_native.a ../dawn/out/Debug/src/dawn/native/libwebgpu_dawn.a ../dawn/out/Debug//third_party/abseil/absl/*/libabsl_*.a -framework QuartzCore -framework Metal -framework IOSurface -framework CoreFoundation -framework Security -framework IOKit  -framework AppKit -lobjc
austinvhuang commented 5 months ago

Strange for me I don't need to specify link targets manually like that, make clean then make and Fetchcontent + cmake seem to be sufficient to just work. I don't even have protobuf installed via homebrew.

(base) austinhuang@Austins-MacBook-Pro gpu.cpp % brew info protobuf

==> protobuf: stable 26.1 (bottled)
Protocol buffers (Google's data interchange format)
https://protobuf.dev/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/protobuf.rb
License: BSD-3-Clause
==> Dependencies
Build: cmake ✘
Required: abseil ✘, jsoncpp ✘
==> Analytics
install: 56,407 (30 days), 164,486 (90 days), 694,039 (365 days)
install-on-request: 25,188 (30 days), 78,064 (90 days), 324,149 (365 days)
build-error: 216 (30 days)
(base) austinhuang@Austins-MacBook-Pro gpu.cpp % uname -a
Darwin Austins-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:35:58 PST 2022; root:
xnu-8020.101.4~2/RELEASE_ARM64_T6000 arm64

Maybe some aspects of developer tooling broke between Monterey and Ventura? Wouldn't be the first time :/

I'll try upgrading and see if I can replicate it.

junjihashimoto commented 5 months ago

The build was not working because I was running cmake myself. make demo works.