0

It is just a simple "Hello World" program, with the source code:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World")
}

I compiled it, with

go version go1.10.3 gccgo (GCC) 8.3.0 linux/amd64

and it reported the following error messages:

[victor@chroot-64:~/go]$ go build helloworld.go 
# command-line-arguments
/tmp/go-build724467564/b001/_buildid.s: Assembler messages:
/tmp/go-build724467564/b001/_buildid.s:1: Warning: entity size for SHF_MERGE not specified
/tmp/go-build724467564/b001/_buildid.s:1: Warning: group name for SHF_GROUP not specified
as: $WORK/b001/_buildid.o: warning: sh_link not set for section `.go.buildid'
# command-line-arguments
BFD: $WORK/b001/_buildid.o: warning: sh_link not set for section `.go.buildid'
# command-line-arguments
/usr/bin/ld: $WORK/b001/_pkg_.a(_buildid.o): warning: sh_link not set for section `.go.buildid'
/usr/bin/ld: unable to place orphaned sharable section .go.buildid (/tmp/go-build724467564/b001/_pkg_.a(_buildid.o))
collect2: error: ld returned 1 exit status
[victor@chroot-64:~/go]$

The go env command prints

[victor@chroot-64:~/go]$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/local"
GOTMPDIR=""
GOTOOLDIR="/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.3.0"
GCCGO="/usr/local/bin/gccgo8"
CC="gcc8"
CXX="g++8"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build455330439=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
Victor
  • 1,303
  • 1
  • 10
  • 28
  • What is your GOOS, GOARCH value? – sh.seo Mar 11 '19 at 09:10
  • @devdotlog GOARCH="amd64" GOOS="linux" – Victor Mar 11 '19 at 09:13
  • 1
    It may be permission problems. from your `go env` output, it’s using GOCACHE and GOROOT directory for the root user while your prompt suggest your are running as `victor` user. Also, a useful information is that you seems to running from a chroot jail. It would help to know more about your setup in order to help you, it doesn’t looks like a standard go installation. – mgagnon Mar 11 '19 at 11:40
  • @mgagnon It is actually running in a `schroot` jail. The victor's `$HOME` is `/root` in the jail, which is `~/root` physically. This directory can be written freely by any users. – Victor Mar 11 '19 at 12:27
  • 1
    Do you used gccgo intead of go. example is.... gccgo -c helloworld.go and gccgo -o helloworld helloworld.o – sh.seo Mar 11 '19 at 15:21
  • @devdotlog Wow. I've just tried it, and it succeeded. But why? – Victor Mar 11 '19 at 15:33
  • golang has two compiler gc, gccgo. gc is default. but your golang used gccgo now. https://stackoverflow.com/questions/25811445/what-are-the-primary-differences-between-gc-and-gccgo. – sh.seo Mar 11 '19 at 15:46
  • @devdotlog But the `gc` command doesn't even exist here. Do you mean `go` will always invoke `gc` even if it doesn't exist? If so, then it is a bug of gcc. – Victor Mar 11 '19 at 16:14

0 Answers0