FabricSharp icon indicating copy to clipboard operation
FabricSharp copied to clipboard

Building Failure in branch v1.4

Open BigBang019 opened this issue 4 years ago • 2 comments

Environment:

  • go version go1.13 linux/amd64
  • docker version 20.10.10
make docker

Failure happens:

Successfully tagged hyperledger/forkbase:latest
docker tag hyperledger/forkbase hyperledger/forkbase:amd64-0.4.15
Building .build/docker/bin/peer
-lpthread" github.com/hyperledger/fabric/peer && cp -r /usr/local/share/ustore_release.alpha/* /usr/external/ustore_build/: -c: line 0: unexpected EOF while looking for matching `"'
-lpthread" github.com/hyperledger/fabric/peer && cp -r /usr/local/share/ustore_release.alpha/* /usr/external/ustore_build/: -c: line 1: syntax error: unexpected end of file

It turns out to happen here:

$(BUILD_DIR)/docker/bin/peer: $(PROJECT_FILES) forkbase-docker
	@echo "Building $@"
	@mkdir -p $(BUILD_DIR)/docker/bin \
			$(BUILD_DIR)/docker/peer/pkg \
			$(BUILD_DIR)/docker/peer/ustore_build
	@$(DRUN) \
		-v $(abspath $(BUILD_DIR)/docker/bin):/opt/gopath/bin \
		-v $(abspath $(BUILD_DIR)/docker/peer/pkg):/opt/gopath/pkg \
		-v $(abspath $(BUILD_DIR)/docker/peer/ustore_build):/usr/external/ustore_build \
		$(BASE_DOCKER_NS)/forkbase:$(BASE_DOCKER_TAG) \
		/bin/bash -c \
        'cd /provdb && make go lib_dasl && cd /opt/gopath/src/$(PKGNAME) && CGO_LDFLAGS="-lprovdb_dasl -lustore" CGO_CXXFLAGS="-std=c++11 -I/provdb/src" go install -tags "$(GO_TAGS)" -ldflags "$(DOCKER_GO_LDFLAGS)" $(pkgmap.$(@F)) && cp -r /usr/local/share/ustore_release.alpha/* /usr/external/ustore_build/'
	@touch $@

After I add a statement

@echo "$(DOCKER_GO_LDFLAGS)"
@echo "--------\n$(pkgmap.$(@F))\n---------"

The result is:

-X github.com/hyperledger/fabric/common/metadata.Version=1.4.2 -X github.com/hyperledger/fabric/common/metadata.CommitSHA=5ae1a18ad -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.4.15 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger -linkmode external -extldflags '-static -lpthread'
--------
github.com/hyperledger/fabric/peer
---------

And I changed the DOCKER_GO_LDFLAGS defined in docker-env.mk from

ifeq ($(DOCKER_DYNAMIC_LINK),false)
DOCKER_GO_LDFLAGS += -linkmode external -extldflags '-static -lpthread'
endif

to

ifeq ($(DOCKER_DYNAMIC_LINK),false)
DOCKER_GO_LDFLAGS += -linkmode external -extldflags "-static -lpthread"
endif

Another error reported:

cd /opt/gopath/src/ustore && swig -go -cgo -c++ -intgosize 64 -outdir /opt/gopath/src/ustore ustore.i
g++-4.8 -std=c++11 -fPIC -o src/status.o -c src/status.cc 
g++-4.8 -std=c++11 -fPIC -D GO_USE_DASL -o src/db_dasl.o -c src/db.cc
g++-4.8 -std=c++11 -fPIC -shared -o /usr/local/share/ustore_release.alpha/lib/libprovdb_dasl.so src/status.o src/db_dasl.o
flag provided but not defined: -lpthread
usage: go install [-i] [build flags] [packages]
Run 'go help install' for details.
make: *** [Makefile:243: .build/docker/bin/peer] Error 2

Why args of -lpthread is left blank?

BigBang019 avatar Oct 29 '21 05:10 BigBang019

I also encountered this problem, did you find a solution

yqcong avatar Mar 10 '22 10:03 yqcong

@yqcong I reimplemented fabric++ in v2.2: https://github.com/BigBang019/fabric/tree/fabric++

BigBang019 avatar Mar 11 '22 13:03 BigBang019