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/cgo: after upgrade from 1.9.2 to 1.10, cgo compile fails with "invalid flag in #cgo LDFLAGS: -Wl,-z,relro" #24124

Closed
xiaoyulei opened this issue Feb 26, 2018 · 2 comments

Comments

@xiaoyulei
Copy link

xiaoyulei commented Feb 26, 2018

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

go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/xiaoyulei/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/mnt/hdd1/work/R"
GORACE=""
GOROOT="/mnt/hdd1/tools/go"
GOTMPDIR=""
GOTOOLDIR="/mnt/hdd1/tools/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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-build765024801=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I use cgo and code like this:

// #cgo CPPFLAGS: -I ../../../../c-kudu/src/kudu/raft-log -I ${SRCDIR}/clog/                                                                              
// #cgo CXXFLAGS: -std=c++11                                                                                                                              
// #cgo darwin LDFLAGS: -Wl,-undefined -Wl,dynamic_lookup                                                                                                 
// #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all                                                                                               
// #cgo linux LDFLAGS: -L${SRCDIR}/../../../../p/Dist/s/lib -llogging -L${SRCDIR}/clog -lkudutracelog -lrt -lstdc++ -lrt -lm -lpthread        
//                                                                                                                                                        
// #cgo linux LDFLAGS: -ldl -Wl,-z,relro -Wl,-z,noexecstack                                                                                               
// #cgo linux LDFLAGS: -lraftlog      -L${SRCDIR}/../../../../c-kudu                                                                                      
// #cgo linux LDFLAGS: -lboost_system -L${SRCDIR}/../../../../dep/boost/lib                                                                      
// #cgo linux LDFLAGS: -lboost_thread -L${SRCDIR}/../../../../dep/boost/lib                                                                      
// #cgo linux LDFLAGS: -Wl,-dn                                                                                                                            
// #cgo linux LDFLAGS: -lz            -L${SRCDIR}/../../../../dep/zlib/lib                                                                       
// #cgo linux LDFLAGS: -lvmem         -L${SRCDIR}/../../../../dep/nvml/lib                                                                       
// #cgo linux LDFLAGS: -lglog         -L${SRCDIR}/../../../../dep/glog/lib                                                                       
// #cgo linux LDFLAGS: -lunwind       -L${SRCDIR}/../../../../dep/unwind/lib                                                                     
// #cgo linux LDFLAGS: -lgflags       -L${SRCDIR}/../../../../dep/gflags/lib                                                                     
// #cgo linux LDFLAGS: -ltcmalloc     -L${SRCDIR}/../../../../dep/gperftools/lib                                                                 
// #cgo linux LDFLAGS: -lprotobuf     -L${SRCDIR}/../../../../dep/protobuf-2.6.1/lib                                                             
// #cgo linux LDFLAGS: -lcrcutil      -L${SRCDIR}/../../../../dep/crcutil/lib                                                                    
// #cgo linux LDFLAGS: -lev           -L${SRCDIR}/../../../../dep/libev/lib                                                                      
// #cgo linux LDFLAGS: -llzma         -L${SRCDIR}/../../../../dep/xz/lib                                                                         
// #cgo linux LDFLAGS: -Wl,-dy                                                                                                                            
// #cgo linux LDFLAGS: -lsecurec      -L${SRCDIR}/../../../../dep/securec/lib                                                                    
//                                                                                                                                                        
// #include <stdlib.h>                                                                                                                                    
// #include <string.h>                                                                                                                                    
// #include "raft_log.h"                                                                                                                                  
// #include "kudu_trace_log.h"

go build report error message:invalid flag in #cgo LDFLAGS: -Wl,-z,relro

What did you expect to see?

go build success

What did you see instead?

go build fail:invalid flag in #cgo LDFLAGS: -Wl,-z,relro

@tklauser
Copy link
Member

There is a general issue to cover all whitelist options in #23749. Please also see https://github.com/golang/go/wiki/InvalidFlag. I added a comment mentioning the -Wl,-z,relro

@tklauser tklauser changed the title after upgrade from 1.9.2 to 1.10, cgo compile fail cmd/cgo: after upgrade from 1.9.2 to 1.10, cgo compile fails with "invalid flag in #cgo LDFLAGS: -Wl,-z,relro" Feb 26, 2018
@bradfitz
Copy link
Contributor

Closing in favor of #23749

@golang golang locked and limited conversation to collaborators Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants