Is there a way to build hyperledger fabric using gccgo? I want to do this in order to use -finstrument-functions option of gcc to trace function calls. But I encountered two problems. My steps are as follows.

  1. find the build command

make -n release

echo "Building release/linux-amd64/bin/configtxgen for linux-amd64"

mkdir -p release/linux-amd64/bin CGO_CFLAGS=" "

GOOS=linux GOARCH=amd64 go build -o /home/yiifburj/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxgen -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/tools/configtxgen/metadata.Version=1.1.0" github.com/hyperledger/fabric/common/tools/configtxgen

  1. modify the build command to use gccgo

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -compiler gccgo -o /home/yiifburj/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxgen -tags "nopkcs11" -gccgoflags "-X github.com/hyperledger/fabric/common/tools/configtxgen/metadata.Version=1.1.0" github.com/hyperledger/fabric/common/tools/configtxgen

#github.com/hyperledger/fabric/bccsp/factory

bccsp/factory/pluginfactory.go:12:8: error: import file ‘plugin’ not found
"plugin"

bccsp/factory/pluginfactory.go:56:15: error: reference to undefined name

‘plugin’ plug, err := plugin.Open(config.PluginOpts.Library)

First, as above, "plugin" couldn't be found when gccgo is invoked by go build. Another one is how to pass ldflags -X when use gccgo? It seems that -X is a parameter only invalid in gc tools not gccgo.

Anyone can help me? Thanks.

You'll need to use the correct version of GCC in order to get support for the versions of Go supported by the various Fabric releases.

  • Fabric 1.1 requires Go 1.9.x
  • Fabric 1.2.x requires Go 1.10.x
  • The upcoming Fabric 1.3 also requires Go 1.10

gccgo did not support Go 1.9 (GCC 7 had support for Go 1.8). GCC 8 adds support for Go 1.10.

So you should use Fabric v1.2 and GCC 8.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.