Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix building project when go-svm is imported #3052

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cmd/tmp
*/**/.DS_Store
/build
libgpu-setup-*
libsvm-*

.project
.settings
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM ubuntu:18.04 AS linux
# libsvm.a is linked with fcntl64, which was added to glibc since 2.28.
# The earliest Ubuntu release that has glibc >=2.28 by default is 18.10, so the LTS one is 20.04.
# If any issues occur on 20.04, it may be downgraded back to 18.04 with manual glibc upgrade.
FROM ubuntu:20.04 AS linux
ENV DEBIAN_FRONTEND noninteractive
ENV SHELL /bin/bash
ARG TZ=US/Eastern
Expand Down Expand Up @@ -93,6 +96,7 @@ COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/go-
COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/go-p2p /bin/
COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/go-harness /bin/
COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/libgpu-setup.so /bin/
COPY --from=server_builder /go/src/github.com/spacemeshos/go-spacemesh/build/libsvm.so /bin/

ENTRYPOINT ["/bin/go-harness"]
EXPOSE 7513
Expand Down
3 changes: 2 additions & 1 deletion DockerfilePrebuiltBinary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04 AS linux
FROM ubuntu:20.04 AS linux
ENV DEBIAN_FRONTEND noninteractive
ENV SHELL /bin/bash
ARG TZ=US/Eastern
Expand Down Expand Up @@ -30,6 +30,7 @@ COPY go-hare /bin/go-hare
COPY go-p2p /bin/go-p2p
COPY go-harness /bin/go-harness
COPY libgpu-setup.so /bin/
COPY libsvm.so /bin/

ENTRYPOINT ["/bin/go-harness"]
EXPOSE 7513
Expand Down
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ all: install build
.PHONY: all

LDFLAGS = -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.branch=${BRANCH}"
include Makefile.Inc
include Makefile-gpu.Inc
include Makefile-svm.Inc

DOCKER_HUB ?= spacemeshos
TEST_LOG_LEVEL ?=
Expand Down Expand Up @@ -95,11 +96,14 @@ install:
build: go-spacemesh
.PHONY: build

hare p2p: get-gpu-setup
get-libs: get-gpu-setup get-svm
.PHONY: get-libs

hare p2p: get-libs
cd cmd/$@ ; go build -o $(BIN_DIR)go-$@$(EXE) $(GOTAGS) .
go-spacemesh: get-gpu-setup
go-spacemesh: get-libs
go build -o $(BIN_DIR)$@$(EXE) $(LDFLAGS) $(GOTAGS) .
harness: get-gpu-setup
harness: get-libs
cd cmd/integration ; go build -o $(BIN_DIR)go-$@$(EXE) $(GOTAGS) .
.PHONY: hare p2p harness go-spacemesh

Expand Down Expand Up @@ -131,15 +135,15 @@ docker-local-build: go-spacemesh hare p2p harness
.PHONY: docker-local-build
endif

test test-all: get-gpu-setup
test test-all: get-libs
$(ULIMIT) CGO_LDFLAGS="$(CGO_TEST_LDFLAGS)" TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) go test -timeout 0 -p 1 ./...
.PHONY: test

test-no-app-test: get-gpu-setup
test-no-app-test: get-libs
$(ULIMIT) CGO_LDFLAGS="$(CGO_TEST_LDFLAGS)" TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) go test -timeout 0 -p 1 -tags exclude_app_test ./...
.PHONY: test-no-app-test

test-only-app-test: get-gpu-setup
test-only-app-test: get-libs
$(ULIMIT) CGO_LDFLAGS="$(CGO_TEST_LDFLAGS)" TEST_LOG_LEVEL=$(TEST_LOG_LEVEL) go test -timeout 0 -p 1 -tags !exclude_app_test ./cmd/node
.PHONY: test-only-app-test

Expand Down
File renamed without changes.
51 changes: 51 additions & 0 deletions Makefile-svm.Inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
PROJ_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
BIN_DIR ?= $(PROJ_DIR)build/
export GOOS
export GOARCH
export GOARM
export BIN_DIR

SVM_VERSION := 0.0.31

export CGO_CFLAGS := $(CGO_CFLAGS) -I${BIN_DIR}

ifeq ($(OS),Windows_NT)
HOST_OS := windows
else
HOST_OS := $(shell uname | tr [A-Z] [a-z])
endif

ifeq ($(GOOS),)
GOOS := $(HOST_OS)
endif

ifeq ($(GOOS),windows)
PLATFORM := windows
SVM_CLI := svm-cli.exe
export CGO_LDFLAGS := $(CGO_LDFLAGS) -L$(BIN_DIR) -lsvm
export PATH := $(PATH):$(BIN_DIR)
else
SVM_CLI := svm-cli
ifeq ($(GOOS),darwin)
PLATFORM := macos
export CGO_LDFLAGS := $(CGO_LDFLAGS) $(BIN_DIR)/libsvm.a -lm -ldl -framework Security -framework Foundation
else
PLATFORM := linux
export CGO_LDFLAGS := $(CGO_LDFLAGS) $(BIN_DIR)/libsvm.a -lm -ldl -Wl,-rpath,$(BIN_DIR)
endif
endif

CGO_TEST_LDFLAGS := $(CGO_LDFLAGS) -Wl,-rpath,$(BIN_DIR)

SVM_ZIP = libsvm-$(PLATFORM)-$(SVM_VERSION).zip

$(PROJ_DIR)$(SVM_ZIP):
echo "Building svm-$(PLATFORM)..."
mkdir -p $(BIN_DIR)/
curl -L https://github.com/spacemeshos/svm/releases/download/v$(SVM_VERSION)/svm-$(PLATFORM)-v$(SVM_VERSION).zip -o $(PROJ_DIR)$(SVM_ZIP)
unzip $(PROJ_DIR)$(SVM_ZIP) -d $(BIN_DIR)/
chmod +x $(BIN_DIR)/$(SVM_CLI)
ls $(BIN_DIR)

get-svm: $(PROJ_DIR)$(SVM_ZIP)
.PHONY: get-svm
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down