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

runtime/cgo: linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration] #54695

Closed
kmlebedev opened this issue Aug 26, 2022 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@kmlebedev
Copy link

kmlebedev commented Aug 26, 2022

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

go version go1.19 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
```
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/tochka/Library/Caches/go-build"
GOENV="/Users/tochka/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/tochka/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/tochka/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/tochka/GolandProjects/seaweedfs/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zv/tqq_jjhx3sb04kjw8565qmf00000gn/T/go-build1384732046=/tmp/go-build -gno-record-gcc-switches -fno-common"
```

What did you do?

  1. git clone https://github.com/seaweedfs/seaweedfs.git
  2. cd ../weed; CGO_ENABLED=1 GOOS=linux go build -race -tags "" -ldflags "-extldflags -static "

What did you expect to see?

make dev
export SWCOMMIT=fa2ccd8e
export SWLDFLAGS="-X github.com/seaweedfs/seaweedfs/weed/util.COMMIT="
cd ../weed; CGO_ENABLED=0 GOOS=linux go build  -tags "" -ldflags "-extldflags -static "; mv weed ../docker/
docker build --no-cache -t chrislusf/seaweedfs:local -f Dockerfile.local .

What did you see instead?

make dev_race
export SWCOMMIT=fa2ccd8e
export SWLDFLAGS="-X github.com/seaweedfs/seaweedfs/weed/util.COMMIT="
cd ../weed; CGO_ENABLED=1 GOOS=linux go build -race -tags "" -ldflags "-extldflags -static "; mv weed ../docker/
# runtime/cgo
linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:67:13: note: did you mean 'setregid'?
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/unistd.h:593:6: note: 'setregid' declared here
linux_syscall.c:73:13: error: implicit declaration of function 'setresuid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:73:13: note: did you mean 'setreuid'?
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/unistd.h:595:6: note: 'setreuid' declared here
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 26, 2022
@kmlebedev kmlebedev changed the title runtime: linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration] runtime/cgo: linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration] Aug 26, 2022
@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 26, 2022
@ianlancetaylor
Copy link
Contributor

You are cross-compiling from Darwin to Linux with CGO_ENABLED=1. That requires setting CC to a cross-compiler that generates Linux objects using Linux header files. You aren't doing that.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2022
@kmlebedev
Copy link
Author

@ianlancetaylor I tried setting https://words.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/

  1. CC="x86_64-linux-musl-gcc" CXX="x86_64-linux-musl-g++" :
cd ../weed; CGO_ENABLED=1 CC="x86_64-linux-musl-gcc" CXX="x86_64-linux-musl-g++" GOOS=linux go build -race -tags "" -ldflags "-extldflags -static "; mv weed ../docker/
# github.com/seaweedfs/seaweedfs/weed
runtime.mallocgc: relocation target __tsan_malloc not defined
runtime.runfinq: relocation target __tsan_finalizer_goroutine not defined
runtime.(*sweepLocked).sweep: relocation target __tsan_free not defined
runtime.goexit1: relocation target __tsan_go_end not defined
runtime.gfget: relocation target __tsan_malloc not defined
runtime.(*p).init: relocation target __tsan_proc_create not defined
runtime.(*p).destroy: relocation target __tsan_go_end not defined
runtime.(*p).destroy: relocation target __tsan_proc_destroy not defined
runtime.RaceDisable: relocation target __tsan_go_ignore_sync_begin not defined
runtime.RaceEnable: relocation target __tsan_go_ignore_sync_end not defined
runtime.raceinit: relocation target __tsan_init not defined
runtime.raceinit: relocation target __tsan_map_shadow not defined
runtime.racefini: relocation target __tsan_fini not defined
runtime.racemapshadow: relocation target __tsan_map_shadow not defined
runtime.racegostart: relocation target __tsan_go_start not defined
runtime.raceacquireg: relocation target __tsan_acquire not defined
runtime.raceacquirectx: relocation target __tsan_acquire not defined
runtime.racereleaseg: relocation target __tsan_release not defined
runtime.racereleaseacquireg: relocation target __tsan_release_acquire not defined
runtime.racereleasemergeg: relocation target __tsan_release_merge not defined
runtime.stackalloc: relocation target __tsan_malloc not defined
/usr/local/go/pkg/tool/darwin_amd64/link: too many errors

and
2. CC="x86_64-linux-musl-gcc" CXX="x86_64-linux-musl-g++" :

cd ../weed; CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" CXX="x86_64-w64-mingw32-g++" GOOS=linux go build -race -tags "" -ldflags "-extldflags -static "; mv weed ../docker/
# runtime/cgo
gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:63:9: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
   63 |         sigset_t ign, oset;
      |         ^~~~~~~~
      |         _sigset_t
gcc_linux_amd64.c:68:9: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
   68 |         sigfillset(&ign);
      |         ^~~~~~~~~~
gcc_linux_amd64.c:63:23: error: unused variable 'oset' [-Werror=unused-variable]
   63 |         sigset_t ign, oset;
      |                       ^~~~
cc1: all warnings being treated as errors

As it turned out, this is not a completely trivial task, maybe there is an up-to-date instruction?

@kmlebedev
Copy link
Author

It seems that this has not yet been resolved.
#42382
@dr2chase Please reopen the issue

@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@golang golang locked and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. 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

5 participants