Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gollvm: reference to undefined identifier 'syscall.RUSAGE_SELF', while build grpc related package #41382

Closed
advancedwebdeveloper opened this issue Sep 14, 2020 · 9 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@advancedwebdeveloper
Copy link

Hi. I was building internals of linkerd and caught a bug, during the build phase, for a protobuf/grpc related package.

What version of Go are you using (go version)?

$ go version

go version go1.15rc2 gollvm LLVM 12.0.0git linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oceanfish81/.cache/go-build"
GOENV="/home/oceanfish81/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/oceanfish81/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/oceanfish81/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/tools"
GCCGO="/usr/local/bin/llvm-goc"
AR="ar"
CC="/usr/bin/clang"
CXX="/usr/bin/clang++"
CGO_ENABLED="1"
GOMOD="/home/oceanfish81/linkerd2/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build000799681=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

~/linkerd2/pkg/tap$ go build

What did you expect to see?

Required sources should be pulled and all packages should be compiled, using llvm-goc, as expected.

What did you see instead?

go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading k8s.io/apimachinery v0.17.4
go: downloading k8s.io/client-go v0.17.4
go: downloading github.com/servicemeshinterface/smi-sdk-go v0.3.0
go: downloading k8s.io/kube-aggregator v0.17.4
go: downloading github.com/prometheus/client_golang v1.2.1
go: downloading k8s.io/api v0.17.4
go: downloading github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4
go: downloading github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
go: downloading k8s.io/apiextensions-apiserver v0.17.4
go: downloading github.com/prometheus/procfs v0.0.5
go: downloading github.com/prometheus/common v0.7.0
go: downloading github.com/Azure/go-autorest/autorest v0.9.0
go: downloading k8s.io/utils v0.0.0-20191114184206-e782cd3c129f
go: downloading github.com/gogo/protobuf v1.3.0
go: downloading github.com/googleapis/gnostic v0.3.1
go: downloading github.com/Azure/go-autorest/tracing v0.5.0
go: downloading github.com/Azure/go-autorest/logger v0.1.0
go: downloading github.com/gophercloud/gophercloud v0.1.0
go: downloading github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96
go: downloading github.com/Azure/go-autorest/autorest/adal v0.5.0
go: downloading k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
go: downloading github.com/Azure/go-autorest/autorest/date v0.1.0
go: downloading github.com/evanphx/json-patch v4.5.0+incompatible
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/cespare/xxhash/v2 v2.1.0
go: downloading github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: downloading github.com/json-iterator/go v1.1.8
go: downloading github.com/pkg/errors v0.9.1

google.golang.org/grpc/internal/syscall

../../../go/pkg/mod/google.golang.org/grpc@v1.29.1/internal/syscall/syscall_linux.go:50:28: error: reference to undefined identifier 'syscall.RUSAGE_SELF'

It seems that an error is related to func GetRusage() (rusage *Rusage) .

Ivan

@ianlancetaylor ianlancetaylor changed the title [gollvm] reference to undefined identifier 'syscall.RUSAGE_SELF', while build grpc related package gollvm: reference to undefined identifier 'syscall.RUSAGE_SELF', while build grpc related package Sep 14, 2020
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 14, 2020
@ianlancetaylor ianlancetaylor added this to the gollvm milestone Sep 14, 2020
@ianlancetaylor
Copy link
Contributor

CC @thanm @cherrymui

In gccgo syscall.RUSAGE_SELF is defined in the sysinfo.go file created by mksysinfo.sh. Not sure what is happening for GoLLVM.

@thanm
Copy link
Contributor

thanm commented Sep 14, 2020

I can't reproduce this -- works ok for me.

As Ian mentions, syscall.RUSAGE_SELF is auto-generated as part of the build. If you examine your gollvm build area, you should see it here:

$ cd <build_area_root>
$ fgrep RUSAGE_SELF tools/gollvm/libgo/sysinfo.go
const _RUSAGE_SELF = 0
const RUSAGE_SELF = _RUSAGE_SELF
$

If not, it sounds as though something went haywire with your build.

@advancedwebdeveloper
Copy link
Author

@thanm , I will check that tomorrow.
Thanks for the tip

@advancedwebdeveloper
Copy link
Author

I can't reproduce this -- works ok for me.

As Ian mentions, syscall.RUSAGE_SELF is auto-generated as part of the build. If you examine your gollvm build area, you should see it here:

$ cd <build_area_root>
$ fgrep RUSAGE_SELF tools/gollvm/libgo/sysinfo.go
const _RUSAGE_SELF = 0
const RUSAGE_SELF = _RUSAGE_SELF
$

If not, it sounds as though something went haywire with your build.

@thanm , some related files are generated/built (see attachments) - but I don't see _RUSAGE_SELF inside sysinfo.go. But I do see it inside sysinfo.macros.txt .

@thanm, @cherrymui : what should I check/investigate, during gollvm's rebuild process, to find out why it's not auto-generating properly ?

gollvm_build.zip

Ivan

@advancedwebdeveloper
Copy link
Author

I was able to compile by adding

const _RUSAGE_SELF = 0
const RUSAGE_SELF = _RUSAGE_SELF

to the source file, under a local package visibility.
That's a bypass - so the original cause/problem persists.

Ivan

@thanm
Copy link
Contributor

thanm commented Sep 15, 2020

Thanks for posting the zip file with build artifacts. I can see the problem now; I'll send a patch shortly to address this.

@gopherbot
Copy link

Change https://golang.org/cl/254941 mentions this issue: libgo: additional type/const reference in sysinfo.c

@advancedwebdeveloper
Copy link
Author

Thanks for posting the zip file with build artifacts. I can see the problem now; I'll send a patch shortly to address this.

Finally. Looking forward to test it/rebuild llvm

gopherbot pushed a commit to golang/gofrontend that referenced this issue Sep 16, 2020
Add a few more explicit references to enumeration constants
(RUSAGE_SELF, DT_UNKNOWN) in sysinfo.c to insure that their hosting enums
are emitted into DWARF, when using a clang host compiler during
the gollvm build.

Updates golang/go#41382.
Updates golang/go#41404.

Change-Id: Id0ed7a82ae5dc98ccffa5269a7147e0171c9b0ea
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/254941
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>
kraj pushed a commit to kraj/gcc that referenced this issue Sep 16, 2020
Add a few more explicit references to enumeration constants
(RUSAGE_SELF, DT_UNKNOWN) in sysinfo.c to insure that their hosting enums
are emitted into DWARF, when using a clang host compiler during
the gollvm build.

Updates golang/go#41382.
Updates golang/go#41404.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/254941
@thanm
Copy link
Contributor

thanm commented Sep 16, 2020

This should be fixed now at head. Please reopen if not.

@thanm thanm closed this as completed Sep 16, 2020
@golang golang locked and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants