herumi/bls-eth-go-binary

undefined: bls.SecretKeycompiler UndeclaredImportedName

TinyVege opened this issue · 26 comments

figure in visual studio

图片

go version

图片

go.mod

图片


SecretKey is defined in /bls/bls.go, but why UndeclaredImportedName occurs

herumi commented

Could you please install MSYS2 with g++, clang++ and make and type make in bls-eth-go-binary at first?

shigeo@fmv4 MINGW64 /c/prog/bls-eth-go-binary
$ make -j
make -f src//bls/Makefile.onelib BLS_DIR=src//bls MCL_DIR=src//bls/mcl OUT_DIR=/c/prog/bls-eth-go-binary ARCH=x86_64 ETH_CFLAGS=-DBLS_ETH all
make[1]: Entering directory '/c/prog/bls-eth-go-binary'
...(snip)

>shigeo@fmv4 MINGW64 /c/prog/bls-eth-go-binary
$ go run examples/sample.go
sample1
verify=true
sample2
sec:425fbb9ec2c1e92d2e060c619c1cabfe2c4376291bf7084ab954506b0989655e
1.pub:8ab6d70cc3978fcc0631032c98cd17854f7fc000b0f005d24468f7ed3aaa6bfd0b3f1b7466ea749e92fa1fe0ea667bfd
1.pub x=&{{{{[291fbbc13a8a1a7d 7be15c37cf31c2ce 560876efc038bd9c 390c83c1f2ffbf23 baa4aea5e732b371 1889c042321a09c5]} {[176be5fe5296445e 9d173a84ce4c1652 b844ef5b71dda92e c43f890022ed05b4 5cf04cf56f46dc08 13c728c36b7c4009]} {[8c5253743de5de98 4dd6a9da7c0b41d5 8341cff4030d470e 52c742606a0d0211 a3bfe25c19409fc8 4ff6e44855ee80b]}}}}
...(snip)

Could you please install MSYS2 with g++, clang++ and make and type make in bls-eth-go-binary at first?

shigeo@fmv4 MINGW64 /c/prog/bls-eth-go-binary
$ make -j
make -f src//bls/Makefile.onelib BLS_DIR=src//bls MCL_DIR=src//bls/mcl OUT_DIR=/c/prog/bls-eth-go-binary ARCH=x86_64 ETH_CFLAGS=-DBLS_ETH all
make[1]: Entering directory '/c/prog/bls-eth-go-binary'
...(snip)

>shigeo@fmv4 MINGW64 /c/prog/bls-eth-go-binary
$ go run examples/sample.go
sample1
verify=true
sample2
sec:425fbb9ec2c1e92d2e060c619c1cabfe2c4376291bf7084ab954506b0989655e
1.pub:8ab6d70cc3978fcc0631032c98cd17854f7fc000b0f005d24468f7ed3aaa6bfd0b3f1b7466ea749e92fa1fe0ea667bfd
1.pub x=&{{{{[291fbbc13a8a1a7d 7be15c37cf31c2ce 560876efc038bd9c 390c83c1f2ffbf23 baa4aea5e732b371 1889c042321a09c5]} {[176be5fe5296445e 9d173a84ce4c1652 b844ef5b71dda92e c43f890022ed05b4 5cf04cf56f46dc08 13c728c36b7c4009]} {[8c5253743de5de98 4dd6a9da7c0b41d5 8341cff4030d470e 52c742606a0d0211 a3bfe25c19409fc8 4ff6e44855ee80b]}}}}
...(snip)

okk, i have installed g++, clang++ and make
图片

but something goes wrong when i attempt to type make
图片

And below is the result of the command "go run sample.go"
图片
图片

herumi commented

okk, i have installed g++, clang++ and make

You must open the MSYS2 Mingw64 console and make, not Windows PowerShell or command prompt.

shigeo@fmv4 MINGW64 /c/prog/bls-eth-go-binary
$ make -j

And please attach not images but text of error messages.

DunkCSH@DESKTOP-KF7GIF8 MINGW64 ~/github.com/herumi/bls-eth-go-binary@v1.32.0
$ make -j
F:/program files/msys64/mingw64/bin/make.exe -f src//bls/Makefile.onelib BLS_DIR=src//bls MCL_DIR=src//bls/mcl OUT_DIR=/home/DunkCSH/github.com/herumi/bls-eth
-go-binary@v1.32.0 ARCH=x86_64 ETH_CFLAGS=-DBLS_ETH all
make[1]: Entering directory 'F:/program files/msys64/home/DunkCSH/github.com/herumi/bls-eth-go-binary@v1.32.0'
make[1]: src//bls/Makefile.onelib: No such file or directory
make[1]: *** No rule to make target 'src//bls/Makefile.onelib'. Stop.
make[1]: Leaving directory 'F:/program files/msys64/home/DunkCSH/github.com/herumi/bls-eth-go-binary@v1.32.0'
make: *** [Makefile:7: all] Error 2

actually i don't know how to enter the directory "C:\Users\DunkCSH\go\pkg\mod\github.com\herumi\bls-eth-go-binary@v1.32.0", instead i copy the "\herumi\bls-eth-go-binary@v1.32.0" to the /msys64/home/DunkCSH/github.com/herumi/bls-eth-go-binary@v1.32.0.

it also doen't work

DunkCSH@DESKTOP-KF7GIF8 MINGW64 ~/github.com/herumi/bls-eth-go-binary@v1.32.0
$ go run examples/sample.go
-bash: go: command not found

herumi commented

make[1]: src//bls/Makefile.onelib: No such file or directory

It seems not to get submodule.

How about git submodule update --init --recursive?

m1 pro mac
This kind of problem has also arisen

image

I used to use it all the time, but suddenly it's like this

$ go version
go version go1.21.3 darwin/arm64

Upgrading the version is also not feasible
github.com/herumi/bls-eth-go-binary

herumi commented

Could you please use a release branch?

git clone -b release https://github.com/heurmi/bls-eth-go-binary
cd bls-eth-go-binary
go run examples/sample.go

Could you please use a release branch?

git clone -b release https://github.com/heurmi/bls-eth-go-binary
cd bls-eth-go-binary
go run examples/sample.go

image

Still can't do it

herumi commented

Is it a clean repository?
My Mac is Mac Book M1 2020 and go1.21.4 darwin/arm64, there is no error and the test on GitHub Action runs well for macOS.

Please run the following and show me the error not as an image but as text.

go version
git clone -b release https://github.com/herumi/bls-eth-go-binary
cd bls-eth-go-binary/
git branch -av
git status
go test ./bls
go run examples/sample.go
% go version
go version go1.21.4 darwin/arm64
% git clone -b release https://github.com/herumi/bls-eth-go-binary
Cloning into 'bls-eth-go-binary'...
remote: Enumerating objects: 1835, done.
remote: Counting objects: 100% (518/518), done.
remote: Compressing objects: 100% (170/170), done.
remote: Total 1835 (delta 313), reused 466 (delta 286), pack-reused 1317
Receiving objects: 100% (1835/1835), 68.73 MiB | 10.33 MiB/s, done.
Resolving deltas: 100% (886/886), done.
% cd bls-eth-go-binary/
% git branch -av
* release                59dab8e fix(release): added libs for windows
  remotes/origin/HEAD    -> origin/master
  remotes/origin/dev     13cd678 update doc
  remotes/origin/master  f1945bf [skip ci] update bls
  remotes/origin/release 59dab8e fix(release): added libs for windows
% git status
On branch release
Your branch is up to date with 'origin/release'.

nothing to commit, working tree clean
% go test ./bls
ok      github.com/herumi/bls-eth-go-binary/bls 1.264s
% go run examples/sample.go
sample1
verify=true
sample2
sec:193bdaa606fb88c968d577ba8181909b4af444c5cb439cd0d4893ba8766a4735
1.pub:99d598009340e43aa53509dd1eb36a822855f57ad06cb761d54ba6f600aad0d486253a3d4271167aad208fbaa148eb5b
1.pub x=&{{{{[27588ad38475d1f9 9821737520f995b8 9869e552c18f7ad0 7fa482bfd2b06adc 630505dc3c084e31 1fff8e4d64c18cc]} {[13f759a2d4bad1b8 795d694db670ed15 74822dd10165225c 19f1c2a53dbbd58e 8e34935c214dd4fa 834586057301ba2]} {[c858e8c044c5ebb 6f2be19951d6f9d 2fd75b9bb13d514a c079fef7468919c5 80c558bf628de664 56b597ad985fdd]}}}}
2.pub:99d598009340e43aa53509dd1eb36a822855f57ad06cb761d54ba6f600aad0d486253a3d4271167aad208fbaa148eb5b
2.pub x=&{{{{[909ea1384806096a b2a569a23ba0c0d7 27604fe817d1a3ba a6f46c35ba3c8101 b3a3caac928a895c 66845de9db6b47e]} {[56a2086dc4d5b194 6b5c4bb4e7e01908 9ed29e24b5ee86e7 9c642203afa0c749 4b244246cfc10104 19877d93696eef42]} {[760900000002fffd ebf4000bc40c0002 5f48985753c758ba 77ce585370525745 5c071a97a256ec6d 15f65ec3fa80e493]}}}}
P.X=19d598009340e43aa53509dd1eb36a822855f57ad06cb761d54ba6f600aad0d486253a3d4271167aad208fbaa148eb5b
P.Y=06d426aa875f8bbd0f67644d18e44eb4c0a00a78e63ae741bded83fac6ca5377d76c4006d48ed3047bf69c355ffbec6d
P.Z=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
sample3
sec=0748d9d99f59ff1105d314967254398f2b6cedcb87925c23c999e990f3f29c6c
sample4
sec:4aac41b5cb665b93e031faa751944b1f14d77cb17322403cba8df1d6e4541a4d
pub:841c5235ec7f4eed02b3f3bb60622d3ed0aba74016f4850c6d7c962656a4b78d72a15caeef62dfe656d03990590c0026
sig:af7ab839885d3189502b1092895c4676357ef7a32863bd4253eb4c7ab12fc3aa5a9d9a82e1e641c1c85965c468e1d33018e8a0bbe1d4aef5e751b3c94876c4de312d7ccca34c9fe6b80d8dd00c6a499759cea7febfc661f80831f9547c158c84
$ go version
go version go1.21.3 darwin/arm64

$ git branch -av
* release                59dab8e fix(release): added libs for windows
  remotes/origin/HEAD    -> origin/master
  remotes/origin/dev     13cd678 update doc
  remotes/origin/master  f1945bf [skip ci] update bls
  remotes/origin/release 59dab8e fix(release): added libs for windows

$ git status
On branch release
Your branch is up to date with 'origin/release'.

nothing to commit, working tree clean

$ go test ./bls
# github.com/herumi/bls-eth-go-binary/bls [github.com/herumi/bls-eth-go-binary/bls.test]
bls/cast.go:9:28: undefined: SecretKey
bls/cast.go:9:40: undefined: Fr
bls/cast.go:13:26: undefined: Fr
bls/cast.go:13:31: undefined: SecretKey
bls/cast.go:19:28: undefined: PublicKey
bls/cast.go:19:40: undefined: G1
bls/cast.go:23:26: undefined: G1
bls/cast.go:23:31: undefined: PublicKey
bls/cast.go:29:23: undefined: Sign
bls/cast.go:29:30: undefined: G2
bls/cast.go:29:30: too many errors
FAIL	github.com/herumi/bls-eth-go-binary/bls [build failed]
FAIL

$ go run examples/sample.go
# github.com/herumi/bls-eth-go-binary/bls
bls/cast.go:9:28: undefined: SecretKey
bls/cast.go:9:40: undefined: Fr
bls/cast.go:13:26: undefined: Fr
bls/cast.go:13:31: undefined: SecretKey
bls/cast.go:19:28: undefined: PublicKey
bls/cast.go:19:40: undefined: G1
bls/cast.go:23:26: undefined: G1
bls/cast.go:23:31: undefined: PublicKey
bls/cast.go:29:23: undefined: Sign
bls/cast.go:29:30: undefined: G2
bls/cast.go:29:30: too many errors
herumi commented

I don't know why the error occurred.
What is the result of go env?
and can you exec

git submodule update --init --recursive
make -j

?

Same error for me. I think it is a win issue, since it does not have builtin make and similar commands.
Go env result: GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\start\AppData\Local\go-build
set GOENV=C:\Users\start\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\start\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\start\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\start\AppData\Local\Temp\go-build3046070729=/tmp/go-build -gno-record-gcc-switches

With mingw I get following error:
$ git submodule update --init --recursive
Submodule 'src/bls' (https://github.com/herumi/bls) registered for path 'src/bls'
Cloning into 'E:/Ethereum/bls-eth-go-binary/src/bls'...
Submodule path 'src/bls': checked out 'eb3f1043d1eab3f018fcddc3cb3c2329fb17349a'
Submodule 'mcl' (https://github.com/herumi/mcl) registered for path 'src/bls/mcl'
Cloning into 'E:/Ethereum/bls-eth-go-binary/src/bls/mcl'...
Submodule path 'src/bls/mcl': checked out '8f1530798c02c03dfd34f84a30e852c00151a6e8'

start@DESKTOP-R9KHT0F MINGW64 /e/Ethereum/bls-eth-go-binary (release)
$ make -j
C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe -f src//bls/Makefile.onelib BLS_DIR=src//bls MCL_DIR=src//bls/mcl OUT_DIR=/e/Ethereum/bls-eth-go-binary ARCH=x86_64 ETH_CFLAGS=-DBLS_ETH all
make[1]: Entering directory 'E:/Ethereum/bls-eth-go-binary'
g++ -c src//bls/src/bls_c384_256.cpp -o obj/bls_c384_256.o -O3 -fno-exceptions -fno-threadsafe-statics -fno-rtti -fno-stack-protector -DNDEBUG -DMCL_DONT_USE_OPENSSL -DMCL_SIZEOF_UNIT=8 -DMCL_MAX_BIT_SIZE=384 -DCYBOZU_DONT_USE_EXCEPTION -DCYBOZU_DONT_USE_STRING -D_FORTIFY_SOURCE=0 -Isrc//bls/include -Isrc//bls/mcl/include -DBLS_ETH -std=c++03 -DMCL_STATIC_CODE -DMCL_DONT_USE_XBYAK
process_begin: CreateProcess(NULL, g++ -c src//bls/src/bls_c384_256.cpp -o obj/bls_c384_256.o -O3 -fno-exceptions -fno-threadsafe-statics -fno-rtti -fno-stack-protector -DNDEBUG -DMCL_DONT_USE_OPENSSL -DMCL_SIZEOF_UNIT=8 -DMCL_MAX_BIT_SIZE=384 -DCYBOZU_DONT_USE_EXCEPTION -DCYBOZU_DONT_USE_STRING -D_FORTIFY_SOURCE=0 -Isrc//bls/include -Isrc//bls/mcl/include -DBLS_ETH -std=c++03 -DMCL_STATIC_CODE -DMCL_DONT_USE_XBYAK, ...) failed.
make (e=2): Das System kann die angegebene Datei nicht finden.
make[1]: *** [src//bls/Makefile.onelib:109: obj/bls_c384_256.o] Error 2
make[1]: Leaving directory 'E:/Ethereum/bls-eth-go-binary'
make: *** [Makefile:7: all] Error 2

And after giving it another try in mingw this:
$ make -j
make -f src//bls/Makefile.onelib BLS_DIR=src//bls MCL_DIR=src//bls/mcl OUT_DIR=/E/Ethereum/bls-eth-go-binary ARCH=x86_64 ETH_CFLAGS=-DBLS_ETH all
make[1]: Entering directory '/E/Ethereum/bls-eth-go-binary'
make -C src//bls/mcl obj/static_code.o
make[2]: Entering directory '/E/Ethereum/bls-eth-go-binary/src/bls/mcl'
g++ -o src/dump_code src/dump_code.cpp src/fp.cpp -g -I include -DMCL_DUMP_JIT -DMCL_MAX_BIT_SIZE=384 -DMCL_SIZEOF_UNIT=8 -DNDEBUG
In file included from src/fp.cpp:33:
src/bint_impl.hpp: In function 'mcl::Unit mcl::bint::divSmall(mcl::Unit*, size_t, mcl::Unit*, size_t, const mcl::Unit*, size_t)':
src/bint_impl.hpp:423:29: error: 'get_sub' was not declared in this scope; did you mean 'get_s'?
423 | u_ppp sub = get_sub(yn);
| ^~~~~~~
| get_s
src/bint_impl.hpp: In function 'size_t mcl::bint::divFullBit(mcl::Unit*, size_t, mcl::Unit*, size_t, const mcl::Unit*, size_t)':
src/bint_impl.hpp:463:21: error: 'get_sub' was not declared in this scope; did you mean 'get_s'?
463 | u_ppp sub = get_sub(yn);
| ^~~~~~~
| get_s
src/bint_impl.hpp:464:25: error: 'get_mulUnit' was not declared in this scope; did you mean 'mulUnit'?
464 | u_ppu mulUnit = get_mulUnit(yn);
| ^~~~~~~~~~~
| mulUnit
src/bint_impl.hpp: In function 'void mcl::bint::mulNM(mcl::Unit*, const mcl::Unit*, size_t, const mcl::Unit*, size_t)':
src/bint_impl.hpp:572:28: error: 'get_mulUnitAdd' was not declared in this scope; did you mean 'mulUnitAdd'?
572 | u_ppu mulUnitAdd = get_mulUnitAdd(xn);
| ^~~~~~~~~~~~~~
| mulUnitAdd
src/fp.cpp: In function 'void mcl::fp::setOp(Op&)':
src/fp.cpp:299:30: error: 'get_add' is not a member of 'mcl::bint'
299 | op.fp_addPre = bint::get_add(N);
| ^~~~~~~
src/fp.cpp:300:30: error: 'get_sub' is not a member of 'mcl::bint'
300 | op.fp_subPre = bint::get_sub(N);
| ^~~~~~~
src/fp.cpp:301:33: error: 'get_add' is not a member of 'mcl::bint'
301 | op.fpDbl_addPre = bint::get_add(N * 2);
| ^~~~~~~
src/fp.cpp:302:33: error: 'get_sub' is not a member of 'mcl::bint'
302 | op.fpDbl_subPre = bint::get_sub(N * 2);
| ^~~~~~~
src/fp.cpp:303:33: error: 'get_mul' is not a member of 'mcl::bint'
303 | op.fpDbl_mulPre = bint::get_mul(N);
| ^~~~~~~
src/fp.cpp:304:33: error: 'get_sqr' is not a member of 'mcl::bint'
304 | op.fpDbl_sqrPre = bint::get_sqr(N);
| ^~~~~~~
make[2]: *** [Makefile:298: src/dump_code] Error 1
make[2]: Leaving directory '/E/Ethereum/bls-eth-go-binary/src/bls/mcl'
make[1]: *** [src//bls/Makefile.onelib:96: src//bls/mcl/obj/static_code.o] Error 2
make[1]: Leaving directory '/E/Ethereum/bls-eth-go-binary'
make: *** [Makefile:7: all] Error 2

herumi commented

bls-eth-go-binary works fine on my mingw64 and GitHub Action, so unfortunately I can't work out why it doesn't work in your environment.

shigeo@pc MINGW64 /c/bls-eth-go-binary
$ git branch -v
  dev     869cc51 pdate windows/amd64 binary
  master  f1945bf [skip ci] update bls
* release 59dab8e fix(release): added libs for windows

shigeo@pc MINGW64 /c/bls-eth-go-binary
$ uname -a
MINGW64_NT-10.0-22631 pc 3.4.9.x86_64 2023-09-15 12:15 UTC x86_64 Msys

shigeo@pc MINGW64 /c/bls-eth-go-binary
$ go version
go version go1.19.4 windows/amd64

shigeo@pc MINGW64 /c/bls-eth-go-binary
$ gcc --version
gcc.exe (Rev6, Built by MSYS2 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

shigeo@pc MINGW64 /c/bls-eth-go-binary
$ clang --version
clang version 15.0.5
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/p/msys64/mingw64/bin

shigeo@pc MINGW64 /c/bls-eth-go-binary
$ go test ./bls
ok      github.com/herumi/bls-eth-go-binary/bls 2.561s
herumi commented

The release branch contains libraries, so you don't have to make.

any update? It also occurs to me on windows 64-bit.

In my local environment, the problem does not occur, so I can't fix your problem.

I verified the following script runs well on GitHub Action/msys2 windows.
https://github.com/herumi/bls-eth-go-binary/blob/master/.github/workflows/main.yml#L47-L51

git clone -b release https://github.com/herumi/bls-eth-go-binary
cd bls-eth-go-binary
go test -v ./bls

https://github.com/herumi/bls-eth-go-binary/actions/runs/7406347347/job/20150632550

same error on Mac m2, I had the same error on ubuntu but I solved by installing build-essentials, does anyone how to solve on Mac? I think is a compiler issue.

# github.com/herumi/bls-eth-go-binary/bls
bls/cast.go:9:28: undefined: SecretKey
bls/cast.go:9:40: undefined: Fr
bls/cast.go:13:26: undefined: Fr
bls/cast.go:13:31: undefined: SecretKey
bls/cast.go:19:28: undefined: PublicKey
bls/cast.go:19:40: undefined: G1
bls/cast.go:23:26: undefined: G1
bls/cast.go:23:31: undefined: PublicKey
bls/cast.go:29:23: undefined: Sign
bls/cast.go:29:30: undefined: G2
bls/cast.go:29:30: too many errors

Would you mind showing the results of the following commands? On my M1 Mac environment, all runs well.

git clone -b release https://github.com/herumi/bls-eth-go-binary
cd bls-eth-go-binary
go test -v ./bls
git submodule update --init --recursive
make clean && make
go test -v ./bls
go build -x examples/sample.go && ./sample

Hi herumi, I attached the output, it's strange that on your m1 works and on my m2 not, I tried on apple MacBook intel and it works too, do you use Xcode command line developer tools or brew? I tried both but still the same error.
go version
go version go1.21.6 darwin/arm64
output.txt

this is my go env, can you share your? I suspect it's a clang problem.

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/x/Library/Caches/go-build'
GOENV='/Users/x/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/x/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/x/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='0'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/79/rl88gvcs0sx33fnls1m4fgy00000gn/T/go-build4012601050=/tmp/go-build -gno-record-gcc-switches -fno-common'

% which go && go version
/opt/homebrew/bin/go
go version go1.21.6 darwin/arm64
bls-eth-go-binary% which cc && cc -v
/usr/bin/cc
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
bls-eth-go-binary% which clang && clang -v
/usr/bin/clang
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
bls-eth-go-binary% which c++ && c++ --version
/usr/bin/c++
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/shigeo/Library/Caches/go-build'
GOENV='/Users/shigeo/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/shigeo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/shigeo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.21.6/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.21.6/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/shigeo/b/bls-eth-go-binary/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/sb/8jl_7t854b5cxfdvt76bzmb00000gn/T/go-build3878131822=/tmp/go-build -gno-record-gcc-switches -fno-common'

GOROOT and CXX are different.

solved with go env -w CGO_ENABLED=1 thanks man

Oh, it's good information.
Though it's been a very long time, can others solve this? @duktig666 @georgyrudnev @TinyVege