can't build golang.org/x/benchmarks package using gccgo

420 views
Skip to first unread message

Zhongwei Yao

unread,
Dec 10, 2015, 4:19:10 AM12/10/15
to golang-nuts
Hi, all, 
On an arm64 board, I try to build https://godoc.org/golang.org/x/benchmarks package using gccgo by following command:

$cd ~/project/benchmarks/bench
$go build -compiler gccgo bench.go
../../go-repo/src/vendor/golang.org/x/net/http2/hpack/huffman.go:14:20: error: reference to undefined identifier 'sync.Pool'
 var bufPool = sync.Pool{
                    ^
../../go-repo/src/vendor/golang.org/x/net/http2/hpack/huffman.go:14:24: error: expected ';' or newline after top level declaration
 var bufPool = sync.Pool{
                        ^
../../workspace/src/golang.org/x/benchmarks/driver/driver.go:25:15: error: import file 'runtime/trace' not found
  "runtime/trace"
               ^
../../workspace/src/golang.org/x/benchmarks/driver/driver.go:92:13: error: reference to undefined name 'trace'
   if err := trace.Start(f); err != nil {
             ^
../../workspace/src/golang.org/x/benchmarks/driver/driver.go:96:9: error: reference to undefined name 'trace'
   defer trace.Stop()
         ^

However, there is no problem when using "-compiler gc". Does anyone know how to solve it?

Here is my environment:
  go version devel +c28a8e4
  
  gccgo -v:
  Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/4.9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian/Linaro 4.9.2-10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libsanitizer --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-arm64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-arm64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-arm64 --with-arch-directory=arm64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-multiarch --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Debian/Linaro 4.9.2-10)

--
Best regards,
Zhongwei

Dave Cheney

unread,
Dec 10, 2015, 7:17:45 AM12/10/15
to golang-nuts
I believe gccgo 4.9 only implements the go 1.3 spec. sync.Pool was added in 1.4.

You will have to compile a newer gccgo to.compile that program.

BTW, did you know what go 1.5 and later support arm64 natively?

Thanks

Dave

Zhongwei Yao

unread,
Dec 10, 2015, 9:17:12 PM12/10/15
to Dave Cheney, golang-nuts
Hi, Dave, Thanks for your information! I've built and run several programs by gc without any problem on arm64. Programs include benchmark cases like build, garbage, http, json in golang.org/x/benchmark package. The gc is built from recently master branch. And we also have tried go 1.5.1 to run docker on arm64, it also works. If you want more details, please tell me.

What I want to do is comparing the performance between gccgo and gc. BTW, I'm new to golang. And I don't know why the community is supporting both gccgo and gc. Gccgo seems support a lot of architecture, but it is not well supported in cases like my problem.


Dave

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Best regards,
Zhongwei

Dave Cheney

unread,
Dec 10, 2015, 9:28:07 PM12/10/15
to golang-nuts, da...@cheney.net
I think gccgo is well supported and benefits from the mature gcc toolchain, ubuntu is just shipping an out of date version.

Zhongwei Yao

unread,
Dec 10, 2015, 9:48:49 PM12/10/15
to Dave Cheney, golang-nuts
OK, I'll give a try to newer gccgo.

Joost Shao

unread,
Jun 6, 2017, 3:24:13 AM6/6/17
to golang-nuts, da...@cheney.net
what about now ? i used gccgo-7 to compile framework echo, but failed .

error is blow:

ubuntu@ubuntu-zesty:~$ gccgo-7 -v
Using built-in specs.
COLLECT_GCC=gccgo-7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7-20170407-0ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.0.1 20170407 (experimental) [trunk revision 246759] (Ubuntu 7-20170407-0ubuntu2)


ubuntu@ubuntu-zesty:~$ go build -compiler gccgo  server.go
                                   ^
 var byteBufferPool bytebufferpool.Pool
                                  ^
  byteBufferPool bytebufferpool.Pool
                               ^
go/src/github.com/valyala/fasttemplate/template.go:140:2: error: return with value in function with no return type
  return t
  ^
go/src/github.com/valyala/fasttemplate/template.go:152:3: error: return with value in function with no return type
   return nil, err
   ^
go/src/github.com/valyala/fasttemplate/template.go:154:2: error: return with value in function with no return type
  return &t, nil
  ^
go/src/github.com/valyala/fasttemplate/template.go:267:2: error: not enough arguments to return
  return t.ExecuteFunc(w, func(w io.Writer, tag string) (int, error) { return stdTagFunc(w, tag, m) })
  ^


it seems not support import third party package.

anyone can help me ?

在 2015年12月11日星期五 UTC+8上午10:48:49,Zhongwei Yao写道:

Dave Cheney

unread,
Jun 6, 2017, 3:28:37 AM6/6/17
to Joost Shao, golang-nuts

Does the missing package exist in your gopath?

Joost Shao

unread,
Jun 6, 2017, 6:34:02 AM6/6/17
to golang-nuts, joosts...@gmail.com
thank you first, i have been stuck by gccgo-7.x for gopath and govendor many days.

gopath is ok, like below.

ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
.
└── fasttemplate
    ├── example_test.go
    ├── LICENSE
    ├── README.md
    ├── template.go
    ├── template_test.go
    ├── template_timing_test.go
    ├── unsafe_gae.go
    ├── unsafe.go
    └── vendor
        └── github.com
            └── valyala
                └── bytebufferpool
                    ├── bytebuffer_example_test.go
                    ├── bytebuffer.go
                    ├── bytebuffer_test.go
                    ├── bytebuffer_timing_test.go
                    ├── doc.go
                    ├── LICENSE
                    ├── pool.go
                    ├── pool_test.go
                    └── README.md

5 directories, 17 files



ubuntu@ubuntu-zesty:~$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ubuntu/go"
GORACE=""
GOROOT="/usr/lib/go-1.7"
GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"


content of main.go
ubuntu@ubuntu-zesty:~$ cat server.go
package main

import (
"net/http"
)

func main() {
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.Logger.Fatal(e.Start(":1323"))
}

by gc compile , the result is OK.
ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
WORK=/tmp/go-build058937444
mkdir -p $WORK/command-line-arguments/_obj/
mkdir -p $WORK/command-line-arguments/_obj/exe/
cd /home/ubuntu
/usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I ./go/pkg/linux_amd64 -pack ./server.go
cd .
/usr/lib/go-1.7/pkg/tool/linux_amd64/link -o $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=10569227a53a83251f5b0ba912d076c91ac34779 $WORK/command-line-arguments.a
mv $WORK/command-line-arguments/_obj/exe/a.out server

but by gccgo-7.0
ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
WORK=/tmp/go-build118667055
mkdir -p $WORK/github.com/mattn/
cd /home/ubuntu/go/src/github.com/mattn/go-isatty
/usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=github.com/mattn/go-isatty -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-isatty -o $WORK/github.com/mattn/go-isatty/_obj/_go_.o ./doc.go ./isatty_linux.go ./isatty_others.go
cd /home/ubuntu/go/src/github.com/mattn/go-colorable
/usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=github.com/mattn/go-colorable -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-colorable -o $WORK/github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go ./noncolorable.go
cd /home/ubuntu/go/src/github.com/mattn/go-isatty
cd /home/ubuntu/go/src/github.com/labstack/gommon/color
/usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g -m64 -fgo-pkgpath=github.com/labstack/gommon/color -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/labstack/gommon/color -o $WORK/github.com/labstack/gommon/color/_obj/_go_.o ./color.go
mkdir -p $WORK/github.com/valyala/
cd /home/ubuntu/go/src/github.com/valyala/fasttemplate
/usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g -m64 -fgo-pkgpath=github.com/valyala/fasttemplate -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/valyala/fasttemplate -o $WORK/github.com/valyala/fasttemplate/_obj/_go_.o ./template.go ./unsafe.go
                                   ^
 var byteBufferPool bytebufferpool.Pool
                                  ^
  byteBufferPool bytebufferpool.Pool
                               ^
go/src/github.com/valyala/fasttemplate/template.go:140:2: error: return with value in function with no return type
  return t
  ^
go/src/github.com/valyala/fasttemplate/template.go:152:3: error: return with value in function with no return type
   return nil, err
   ^
go/src/github.com/valyala/fasttemplate/template.go:154:2: error: return with value in function with no return type
  return &t, nil
  ^
go/src/github.com/valyala/fasttemplate/template.go:267:2: error: not enough arguments to return
  return t.ExecuteFunc(w, func(w io.Writer, tag string) (int, error) { return stdTagFunc(w, tag, m) })
  ^
mkdir -p $WORK/golang.org/x/crypto/
cd /home/ubuntu/go/src/golang.org/x/crypto/acme
/usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=golang.org/x/crypto/acme -fgo-relative-import-path=_/home/ubuntu/go/src/golang.org/x/crypto/acme -o $WORK/golang.org/x/crypto/acme/_obj/_go_.o ./acme.go ./jws.go ./types.go
cd /home/ubuntu/go/src/github.com/labstack/gommon/color
cd /home/ubuntu/go/src/golang.org/x/crypto/acme
cd /home/ubuntu/go/src/golang.org/x/crypto/acme/autocert
/usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g -m64 -fgo-pkgpath=golang.org/x/crypto/acme/autocert -fgo-relative-import-path=_/home/ubuntu/go/src/golang.org/x/crypto/acme/autocert -o $WORK/golang.org/x/crypto/acme/autocert/_obj/_go_.o ./autocert.go ./cache.go ./listener.go ./renewal.go

which confused me is what is "gccgo_linux_amd64" directory, i install gccgo-7.x with ubuntu ppa, i confused.

在 2017年6月6日星期二 UTC+8下午3:28:37,Dave Cheney写道:

Joost Shao

unread,
Jun 6, 2017, 6:35:23 AM6/6/17
to golang-nuts, joosts...@gmail.com, da...@cheney.net


在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:

Joost Shao

unread,
Jun 6, 2017, 6:35:55 AM6/6/17
to golang-nuts, joosts...@gmail.com, da...@cheney.net


在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:

Dave Cheney

unread,
Jun 6, 2017, 6:38:32 AM6/6/17
to Joost Shao, golang-nuts

I'd say gccgo does not support vendoring.

Joost Shao

unread,
Jun 6, 2017, 6:46:38 AM6/6/17
to golang-nuts, joosts...@gmail.com

i know that gccgo vendor not support.

hi, Dave, but even gopath also not supported ?

and what's  the road map?

在 2017年6月6日星期二 UTC+8下午6:38:32,Dave Cheney写道:

Joost Shao

unread,
Jun 6, 2017, 6:56:15 AM6/6/17
to golang-nuts, joosts...@gmail.com
which is OK

WORK=/tmp/go-buildxxx
mkdir -p $WORK/github.com/BurntSushi/
cd /home/ubuntu/go/src/github.com/BurntSushi/toml
/usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=github.com/BurntSushi/toml -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/BurntSushi/toml -o $WORK/github.com/BurntSushi/toml/_obj/_go_.o ./decode.go ./decode_meta.go ./doc.go ./encode.go ./encoding_types.go ./lex.go ./parse.go ./type_check.go ./type_fields.go
mkdir -p $WORK/command-line-arguments/_obj/
mkdir -p $WORK/command-line-arguments/_obj/exe/
/usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g -m64 -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/BurntSushi/toml/cmd/tomlv -o $WORK/command-line-arguments/_obj/_go_.o ./main.go
ar rc $WORK/libcommand-line-arguments.a $WORK/command-line-arguments/_obj/_go_.o
cd .
/usr/bin/gccgo -o $WORK/command-line-arguments/_obj/exe/a.out $WORK/command-line-arguments/_obj/_go_.o -Wl,-( -m64 -Wl,--whole-archive $WORK/github.com/BurntSushi/libtoml.a -Wl,--no-whole-archive -Wl,-)
mv $WORK/command-line-arguments/_obj/exe/a.out main



在 2017年6月6日星期二 UTC+8下午6:46:38,Joost Shao写道:
cd /home/ubuntu/go/src/<a href="http://golang.org/x/crypto/acme" rel="nofollow" target="_blank" onmousedown="this.href='http://golang.org/x/crypto/acme&#3

Dave Cheney

unread,
Jun 6, 2017, 7:08:35 AM6/6/17
to golang-nuts, joosts...@gmail.com


On Tuesday, 6 June 2017 20:46:38 UTC+10, Joost Shao wrote:

i know that gccgo vendor not support.

hi, Dave, but even gopath also not supported ?

I don't know what you mean by gopath support, the example you showed had the library inside the projects' vendor directory.
 

and what's  the road map?

I'm sorry I don't know. I recommend raising an issue, https://golang.org/issue/new

Joost Shao

unread,
Jun 6, 2017, 7:24:43 AM6/6/17
to golang-nuts, joosts...@gmail.com
hi, thank you , i really know what you mean, 

cd /home/ubuntu/go/src/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool

yes,  the compile -x included vendor , thank you again


在 2017年6月6日星期二 UTC+8下午7:08:35,Dave Cheney写道:

Ian Lance Taylor

unread,
Jun 6, 2017, 10:31:28 AM6/6/17
to Joost Shao, golang-nuts
On Tue, Jun 6, 2017 at 3:46 AM, Joost Shao <joosts...@gmail.com> wrote:
>
> i know that gccgo vendor not support.

To the best of my knowledge, gccgo does support vendoring. It was
fixed by https://golang.org/cl/39590 which was committed to GCC in SVN
revision 246864 which is included in the GCC 7 release.

Which version of the go tool are you using? The one that comes with
gccgo, or the one that comes with the gc toolchain? The go tool that
comes with the gc toolchain version 1.8.x does not support vendoring
with gccgo. The patch to the gc toolchain is
https://golang.org/cl/40432, and will be in the upcoming Go 1.9
release.

Ian
Reply all
Reply to author
Forward
0 new messages