cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.03k stars 3.79k forks source link

Build fails on ARM64 Mac #59569

Closed ccampbell closed 3 years ago

ccampbell commented 3 years ago

Describe the problem

Trying to build from source on an ARM64 Mac with M1 chip fails with this error:

duplicate symbol 'vtable for geos::noding::BasicSegmentString' in:
    CMakeFiles/geos.dir/src/inlines.cpp.o
    CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o
duplicate symbol 'typeinfo name for geos::noding::BasicSegmentString' in:
    CMakeFiles/geos.dir/src/inlines.cpp.o
    CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o
duplicate symbol 'typeinfo for geos::noding::BasicSegmentString' in:
    CMakeFiles/geos.dir/src/inlines.cpp.o
    CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o
ld: 3 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

To Reproduce

curl https://binaries.cockroachdb.com/cockroach-v20.2.4.src.tgz | tar -xJ
cd cockroach-v20.2.4
make build

Expected behavior The build succeeds

Additional data / screenshots The issue itself seems to be with the geos submodule/fork

It looks like it may be fixed here: https://github.com/libgeos/geos/pull/365

Environment:

blathers-crl[bot] commented 3 years ago

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

ccampbell commented 3 years ago

Seems like rocksdb is also failing to build:

-- Build files have been written to: cockroach/cockroach-v20.2.4/native/arm64-apple-darwin20.1.0/rocksdb
Scanning dependencies of target build_version
[  0%] Building CXX object CMakeFiles/build_version.dir/build_version.cc.o
clang: error: the clang compiler does not support '-march=native'
make[5]: *** [CMakeFiles/build_version.dir/build_version.cc.o] Error 1
make[4]: *** [CMakeFiles/build_version.dir/all] Error 2
make[3]: *** [CMakeFiles/rocksdb.dir/rule] Error 2
make[2]: *** [rocksdb] Error 2
make[1]: *** [cockroach/cockroach-v20.2.4/native/arm64-apple-darwin20.1.0/rocksdb/librocksdb.a] Error 2
make: *** [build] Error 2

Perhaps related to https://github.com/facebook/rocksdb/pull/7714

ccampbell commented 3 years ago

Okay I finally got it to build, but it requires a bunch of changes:

  1. The geos library needs this patch
  2. -march=native needs to be removed from rocks-db for mac arm64: https://github.com/cockroachdb/rocksdb/blob/2512e96f3bf87b3c1b5b0183ed2ec421dc35d0d7/CMakeLists.txt#L227
  3. The arm check for rocks-db needs to be modified to not trigger a ROCKSDB_LITE build for Mac: https://github.com/cockroachdb/rocksdb/blob/2512e96f3bf87b3c1b5b0183ed2ec421dc35d0d7/CMakeLists.txt#L394-L398
  4. The https://github.com/shirou/gopsutil library needs to be upgraded to at least version v2.20.9 (same major release as the current version) which includes the process_darwin_arm64.go and host_darwin_arm64.go files

I think that is everything, but it also got hung up during the build process at some point, and I haven’t had a chance to actually try out the final binary yet.

otan commented 3 years ago

i can do the GEOS patch, but https://github.com/shirou/gopsutil needs an upgrade.

confused how rocksdb is still on your build - that thing is gone as of master about 3 months ago!

ccampbell commented 3 years ago

confused how rocksdb is still on your build - that thing is gone as of master about 3 months ago!

I built from the latest stable at the time v20.2.4 which still includes it: https://github.com/cockroachdb/cockroach/tree/eda2309728392593162e962a61182eab6ab003ff/c-deps

otan commented 3 years ago

Ah, right, we still needs rocks in v20.2, but it's gone in the upcoming master release (v21.1).

Did you need to build v20.2 for any reason?

ccampbell commented 3 years ago

Nope. I just tend to use the latest stable release when I’m trying out new software. I can try building off of one of the v21 alpha builds.

otan commented 3 years ago

should be fine on master, but i can't test it. let me know if you have any issues.