-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Description
Go version
1.22.3
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/gavin/.cache/go-build'
GOENV='/home/gavin/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/gavin/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/gavin/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/gavin/Projects/sql-builder-xd/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-build2614403304=/tmp/go-build -gno-record-gcc-switches'
What did you do?
Tried to create a cgo package and use CString.
// #cgo CFLAGS: -g -Wall
// #include <stdlib.h>
// #include "native/sql_builder_rs.h"
import "C"
func FunctionWithString(table string) error {
st, err := C.CString(table)
if err != nil {
return err
}
C.external_function(C.new_rust_string(st))
}
What did you see happen?
golang gives an error that CString was defined twice, and then tries to use a CString function that doesn't exist.
# github.com/IoIxD/sql-builder-xd
$WORK/b001/_cgo_gotypes.go:75:6: _Cfunc_CString redeclared in this block
$WORK/b001/_cgo_gotypes.go:53:6: other declaration of _Cfunc_CString
./bridge.go:9:12: undefined: _C2func_CString
./bridge.go:13:1: missing return
What did you expect to see?
I expected CString to work, and a compiler error to not be given...at least from Golang.
I don't think Rust is relevant here because I actually expected to get a linker error because I haven't linked to the Rust library yet, I'm just including the header file.
It might also be that I'm on Arch Linux, a decision that I regret. If Arch is at fault here, I am willing to switch to Fedora.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.