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

cmd/go: consider adding -Wl,-Bsymbolic-functions to cgo flags whitelist #41199

Closed
kortschak opened this issue Sep 2, 2020 · 2 comments
Closed
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@kortschak
Copy link
Contributor

File issue accroding to https://github.com/golang/go/wiki/InvalidFlag

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

$ go version
go version go1.15.1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/user/bin"
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/user/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/user/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/user/go/src/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build146708921=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ go build
go build github.com/rgonomic/rgo/sexp: invalid flag in pkg-config --libs: -Wl,-Bsymbolic-functions

(note that this code is not currently in public, but is available here:https://play.golang.org/p/1PSnYTv7aNG)

The libR.pc file specifies invalid flags as far as cgo is concerned.

$ cat /usr/lib/pkgconfig/libR.pc
rhome=/usr/lib/R
rlibdir=${rhome}/lib
rincludedir=/usr/share/R/include

Name: libR
Description: R as a library
Version: 4.0.2
Libs: -Wl,--export-dynamic -fopenmp  -Wl,-Bsymbolic-functions -Wl,-z,relro -L${rlibdir} -lR
Cflags: -I${rincludedir} -I${rincludedir}
Libs.private:

What did you expect to see?

Successful build.

What did you see instead?

$ go build
go build github.com/rgonomic/rgo/sexp: invalid flag in pkg-config --libs: -Wl,-Bsymbolic-functions

Obviously, CGO_LDFLAGS_ALLOW="-Wl,-Bsymbolic-functions" go build works.

Additional information

The Intel notes for this flag have the following:

CAUTION:
This option can have unintended side-effects of disabling symbol preemption in the shared library.

@ianlancetaylor ianlancetaylor changed the title cmd/cgo: consider adding -Wl,-Bsymbolic-functions to cgo flags whitelist cmd/go: consider adding -Wl,-Bsymbolic-functions to cgo flags whitelist Sep 2, 2020
@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Sep 2, 2020
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Sep 2, 2020
@ianlancetaylor
Copy link
Contributor

The file to change is cmd/go/internal/work/security.go.

@gopherbot
Copy link

Change https://golang.org/cl/252698 mentions this issue: cmd/go: add -Wl,-Bsymbolic-functions to cgo flags whitelist

@golang golang locked and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants