open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.08k stars 1.36k forks source link

android/amd64 requires external (cgo) linking, but cgo is not enabled #10516

Closed cforce closed 1 day ago

cforce commented 3 days ago

CGO is not enabled by default, and i never had issues until today.

I was building android/amd64 with ocb since a while, either something changed on ocb >=0.102.0 or in collector or some extension requires it? ..

2024-07-02T16:42:35.279Z INFO internal/command.go:125 OpenTelemetry Collector Builder {"version": "0.102.0", "date": "2024-06-04T08:26:04Z"} 2024-07-02T16:42:35.281Z INFO internal/command.go:161 Using config file {"path": "builder-dev.yaml"} 2024-07-02T16:42:35.281Z INFO builder/config.go:132 Using go {"go-executable": "/usr/local/go/bin/go"} 2024-07-02T16:42:35.281Z INFO builder/main.go:77 You're building a distribution with non-aligned version of the builder. Compilation may fail due to API changes. Please upgrade your builder or API {"builder-version": "0.102.0"} 2024-07-02T16:42:35.283Z INFO builder/main.go:100 Sources created {"path": "bin/collector"} 2024-07-02T16:43:01.151Z INFO builder/main.go:191 Getting go modules 2024-07-02T16:43:01.739Z INFO builder/main.go:111 Compiling 2024-07-02T16:43:01.739Z INFO builder/main.go:117 Debug compilation is enabled, the debug symbols will be left on the resulting binary Error: failed to compile the OpenTelemetry Collector distribution: go subcommand failed with args '[build -trimpath -o otelcollector -gcflags=all=-N -l -ldflags=]': exit status 1, error message: android/amd64 requires external (cgo) linking, but cgo is not enabled

cforce commented 2 days ago

seem like with 0.102.0 it did work and stopped with >=0.103.0 and or when upgraded to go1.22.4

cforce commented 2 days ago

https://github.com/golang/go/issues/30216

mx-psi commented 2 days ago

You probably need to explicitly enable cgo to do this (e.g. by setting the CGO_ENABLED=1 environment variable). Note however that Android is not currently a supported platform so anything may break without prior notice.

cc @evan-bradley since this may be relevant for #10028

cforce commented 2 days ago

It definitely worked earlier . Why does cross compile stopped working?

mx-psi commented 2 days ago

seem like with 0.102.0 it did work and stopped with >=0.103.0 and or when upgraded to go1.22.4

If you can point out which of these two is the culprit that would help us move forward with this

cforce commented 1 day ago

With

it worked ..

since

My gut feeling is that its related to the Go upgrade (maybe you will stgh here https://github.com/golang/go/issues/30216 https://github.com/golang/go/issues/62268#issuecomment-2208238908 or https://github.com/golang/go/issues/25963). but afaik i was forced to upgrade with switch to Otel 0.103.0

mx-psi commented 1 day ago

Can you try using Go 1.22.4 with otelcol_version 0.102.0?

cforce commented 1 day ago

1.22.4

same issue, so it's very liley the go upgrade

mx-psi commented 1 day ago

Thanks for checking! I think I am going to close this as wontfix then, since we don't have control over the Go compiler :smile: