Skip to content

Can't build any projects on ubuntu 24.04 #69356

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

Closed
MiroYld opened this issue Sep 9, 2024 · 7 comments
Closed

Can't build any projects on ubuntu 24.04 #69356

MiroYld opened this issue Sep 9, 2024 · 7 comments

Comments

@MiroYld
Copy link

MiroYld commented Sep 9, 2024

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

$ go version
go version go1.23.1 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/miro/.cache/go-build'
GOENV='/home/miro/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/miro/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/miro/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/snap/go/10711'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/snap/go/10711/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/miro/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/miro/packer-builder-arm-image/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3084240163=/tmp/go-build -gno-record-gcc-switches'
uname -sr: Linux 6.8.0-41-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 24.04.1 LTS
Release:	24.04
Codename:	noble
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.39-0ubuntu8.3) stable release version 2.39.
gdb --version: GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git

What did you do?

When I try to go build on any project I have those errors

# runtime/cgo
In file included from gcc_context.c:7:
libcgo.h:97:15: error: unnecessary parentheses in declaration of ‘_cgo_get_context_function’ [-Werror=parentheses]
   97 | extern void (*(_cgo_get_context_function(void)))(struct context_arg*);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libcgo.h:97:15: note: remove parentheses
   97 | extern void (*(_cgo_get_context_function(void)))(struct context_arg*);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |               -                               -
cc1plus: all warnings being treated as errors

I'm using ubuntu 24.04

@seankhliao
Copy link
Member

you're using a C++ compiler for C

@seankhliao
Copy link
Member

Duplicate of #27186

@seankhliao seankhliao marked this as a duplicate of #27186 Sep 9, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
@chickenandpork
Copy link

I hope this helps the next person:

If you run into this while cross-compiling, check whether your "gcc"is a "g++":

     abi_libc_version = "unknown",
     tool_paths = {
-        "gcc": "bin/x86_64-pc-linux-gnu-g++",
+        "gcc": "bin/x86_64-pc-linux-gnu-gcc",
         "cpp": "bin/x86_64-pc-linux-gnu-cpp",
         "ar": "bin/x86_64-pc-linux-gnu-ar",

(Honestly, I might be putting this here for when my future-self hits this, still has a goldfish memory, and doesn't recall)

@doglex
Copy link

doglex commented Feb 27, 2025

Windows 11 same.

if using gcc env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-cc go build -buildmode=c-shared -o x.so x.go,then

gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:57:9: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
   57 |         sigset_t ign, oset;
      |         ^~~~~~~~
      |         _sigset_t
gcc_linux_amd64.c:62:9: error: implicit declaration of function 'sigfillset' [-Wimplicit-function-declaration]
   62 |         sigfillset(&ign);
      |         ^~~~~~~~~~
gcc_linux_amd64.c:57:23: error: unused variable 'oset' [-Werror=unused-variable]
   57 |         sigset_t ign, oset;
      |                       ^~~~
cc1.exe: all warnings being treated as errors

if using g++ env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-g++ go build -buildmode=c-shared -o x.so x.go, then

In file included from gcc_context.c:7:
libcgo.h:97:15: error: unnecessary parentheses in declaration of '_cgo_get_context_function' [-Werror=parentheses]
   97 | extern void (*(_cgo_get_context_function(void)))(struct context_arg*);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libcgo.h:97:15: note: remove parentheses
   97 | extern void (*(_cgo_get_context_function(void)))(struct context_arg*);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |               -                               -
cc1plus.exe: all warnings being treated as errors

@ianlancetaylor
Copy link
Contributor

@doglex This issue is closed.

Note that it doesn't make sense to say GOOS=linux and CC=x86_64-w64-mingw32-cc. If GOOS=linux, you must use a Linux compiler. If you are using a mingw compiler, you must say GOOS=windows.

@doglex
Copy link

doglex commented Mar 3, 2025

@doglex This issue is closed.

Note that it doesn't make sense to say GOOS=linux and CC=x86_64-w64-mingw32-cc. If GOOS=linux, you must use a Linux compiler. If you are using a mingw compiler, you must say GOOS=windows.

I want do some cross-compling, compile some dynamic library for linux from windows.
And CGO needs enabled because "import C" exists in my code.
Maybe the "Mingw64" is the problem.
I will try docker for windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants