[Buildroot] GOLANG Compilation Issue: build constraints exclude all Go files

Sven Klomp mail at klomp.eu
Fri Feb 19 13:26:51 UTC 2021


On 18.02.21 20:08, Arnout Vandecappelle wrote:
>
>   Without looking at the details, I suspect that this attempts to build a Go
> binary for the host, and then run it to start the build for the target. That
> makes it impossible to pass in environment variables meant for the target.
>
>   If this is just for yourself, you can probably get away with just using
> HOST_GO_COMMON_ENV or HOST_GO_CROSS_ENV instead of HOST_GO_TARGET_ENV - at
> least, if it doesn't need cgo.
>
>   For upstream, however, we would want a proper solution. That probably means
> building the host executable with HOST_GO_HOST_ENV, then "manually" running the
> generated executable with HOST_GO_TARGET_ENV.
>
Thanks for the hints. I got it compiled in two runs as you proposed:

define SYNCTHING_BUILD_CMDS

     cd $(SYNCTHING_SRC_PATH); \
       $(GO_HOST_ENV) \
       GOPATH="$(@D)/$(SYNCTHING_WORKSPACE)" \
       $(SYNCTHING_GO_ENV) \
         $(GO_BIN) build build.go

     cd $(SYNCTHING_SRC_PATH); \
       $(GO_TARGET_ENV) \
       GOARCH= \
       GO111MODULE=on \
       GOPATH="$(@D)/$(SYNCTHING_WORKSPACE)" \
       $(SYNCTHING_GO_ENV) \
         ./build -goarch arm -gocmd $(GO_BIN) -version v1.13.1 
-no-upgrade build

endef

However, I had to overwrite GO111MODULE=on which conflicts with the 
statement here:
https://git.busybox.net/buildroot/commit/?id=f7a2870dd1fef9ee41e78ea1bcbb2ec61e82eb67
"It is not desirable to have Go modules enabled in Buildroot in the 
normal case, as Buildroot manages downloading the sources, and third 
party dependency managers are typically not used."

How to handle modules without automatically download it? Syncthing uses 
dozens of modules...

Sven



More information about the buildroot mailing list