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.
After running ninja to build, when you see Generate FDBOptions for GO, terminates the building by CTRL-C.
Edit the build.ninja file in where you run ninja command (referred as $BUILDDIR below)
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
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
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.
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.
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