Building foundationdb source code in Macos Big Sur M1 chip

I am trying to build foundation db source code in macos version Big Sur with m1 chip. The commands used are
git checkout release-6.2
mkdir build_artifacts
cd build_artifacts
cmake …/.
make -j

while doing make - there are several compilation errors . I have installed mono and it is available. The compilation errors are mostly variables undefined. Is this architecture supported or we can’t build on MacOs m1 chip?

m1 is not an architecture currently supported by FDB, though we may add support later. The official build is for x86 Linux. There are build for x86 Mac and Windows as well, but not tested like Linux build.

1 Like

I managed to compile fdb 6.3.22 on a M1 Macbookpro. Here is how.

  1. Run Terminal in Rosetta mode(try google for how to do that), verify by uname -a
$ uname -a
Darwin xxx x Darwin Kernel Version 20.3.0: xxxx1 x86_64
End of above line MUST be x86_64
  1. Follow the build step in documentation
  2. After running ninja to build, when you see Generate FDBOptions for GO, terminates the building by CTRL-C.
  3. Edit the build.ninja file in where you run ninja command (referred as $BUILDDIR below)
  4. Replace /usr/local/go/bin/go run with GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go run and `` with GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go install
  5. Replace copy ${BUILDDIR}/bindings/go/bin/_stacktester ${BUILDDIR}/bindingtester/tests/go/build/bin/_stacktester with copy ${BUILDDIR}/bindings/go/bin/darwin_amd64/_stacktester ${BUILDDIR}/bindingtester/tests/go/build/bin/_stacktester
  6. Re-run ninja

If you want to run go clients
8. Then copy ${BUILDDIR}/bindings/go/pkg/darwin_amd64/github.com/* to $GOPATH/src/github.com/*
9. Copy ${BUILDDIR}/bindings/go/src/* to $GOPATH/src/
10. Use GO111MODULE=off GOARCH=amd64 CGO_ENABLED=1 go run yourfile.go to run go

Maybe someone has better idea for those complexed replacing steps, please let me know.

1 Like

If you don’t do step 4 & 5, you get something like

 Building fdb_go
FAILED: bindings/go/pkg/darwin_amd64/github.com/apple/foundationdb/bindings/go/src/fdb.a $BUILD_DIR/bindings/go/pkg/darwin_amd64/github.com/apple/foundationdb/bindings/go/src/fdb.a
cd $BUILD_DIR/bindings/go && /opt/homebrew/Cellar/cmake/3.22.1/bin/cmake -E env GOPATH=$BUILD_DIR/bindings/go C_INCLUDE_PATH=$BUILD_DIR/bindings/c/foundationdb:/Users/leon.liao/code/oss/foundationdb/bindings/c CGO_LDFLAGS=-L$BUILD_DIR/lib GO111MODULE=off /usr/local/go/bin/go get -d github.com/apple/foundationdb/bindings/go/src/fdb && /opt/homebrew/Cellar/cmake/3.22.1/bin/cmake -E env GOPATH=$BUILD_DIR/bindings/go C_INCLUDE_PATH=$BUILD_DIR/bindings/c/foundationdb:/Users/leon.liao/code/oss/foundationdb/bindings/c CGO_LDFLAGS=-L$BUILD_DIR/lib GO111MODULE=off /usr/local/go/bin/go install github.com/apple/foundationdb/bindings/go/src/fdb
# github.com/apple/foundationdb/bindings/go/src/fdb
ld: warning: ignoring file $BUILD_DIR/lib/libfdb_c.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "_fdb_create_database", referenced from:

If you don’t do step 6, you get _stacktester copy error.

  1. Replace
    /usr/local/go/bin/go run with
    GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go run
    and
    /usr/local/go/bin/go install with
    GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go install