Skip to content

Cgo and --compiler=gcc #1357

@jayconrod

Description

@jayconrod

Copied from bazel-go-discuss. cc @nathantchan


One of our verification builds uses gcc, and I currently cannot get past the installation portion of the stdlib rule. It's throwing errors like the following:

not-int-const: In function '__cgo_f_1_3':
not-int-const:1:60: error: invalid type argument of unary '*' (have 'int')
not-num-const: In function '__cgo_f_1_4':
not-num-const:1:73: error: expected expression before ';' token
not-str-lit: In function '__cgo_f_1_5':
not-str-lit:1:73: error: expected expression before ';' token
not-type: In function '__cgo_f_2_2':
not-type:2:39: error: '__cgo_undefined__2' undeclared (first use in this function)
not-type:2:39: note: each undeclared identifier is reported only once for each function it appears in
not-type:2:38: error: invalid operands to binary * (have 'int (*)(const struct sockaddr * __restrict__,  socklen_t,  char * __restrict__,  socklen_t,  char * __restrict__,  socklen_t,  int)' and 'const char *')
not-int-const: In function '__cgo_f_2_3':
not-int-const:2:67: error: invalid operands to binary * (have 'int (*)(const struct sockaddr * __restrict__,  socklen_t,  char * __restrict__,  socklen_t,  char * __restrict__,  socklen_t,  int)' and 'int')
not-num-const: In function '__cgo_f_2_4':
not-num-const:2:67: error: incompatible types when initializing type 'double' using type 'int (*)(const struct sockaddr * __restrict__,  socklen_t,  char * __restrict__,  socklen_t,  char * __restrict__,  socklen_t,  int)'
not-str-lit: In function '__cgo_f_2_5':
not-str-lit:2:1: error: invalid initializer
not-int-const: In function '__cgo_f_3_3':
not-int-const:3:65: error: invalid type argument of unary '*' (have 'int')
not-int-const:3:33: error: enumerator value for '__cgo_undefined__3' is not an integer constant
not-num-const: In function '__cgo_f_3_4':
not-num-const:3:78: error: expected expression before ';' token
not-num-const:3:78: error: initializer element is not constant
not-str-lit: In function '__cgo_f_3_5':
not-str-lit:3:78: error: expected expression before ';' token
not-str-lit:3:78: error: invalid initializer
completed: At top level:
completed:1:16: error: '__cgo__2' undeclared here (not in a function)
completed:1:1: error: initializer element is not constant

It doesn't seem like setting --compiler=gcc works right now in 0.9.0 of the go rules. Any ideas?

$ bazel test --compiler=gcc tests/...
...................
ERROR: No toolchain found for --cpu='k8' --compiler='gcc'. Valid toolchains are: [
  --cpu='armeabi-v7a' --compiler='compiler' --glibc='armeabi-v7a',
  --cpu='ios_x86_64' --compiler='compiler' --glibc='ios',
  --cpu='k8' --compiler='compiler' --glibc='local',
  --cpu='x64_windows' --compiler='cl' --glibc='msvcrt140',
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions