`go run` will build binaries for the target system and try to execute
them. This will fail when cross-compiling unless you provide a wrapper.

Signed-off-by: James Le Cuirot <[email protected]>
---
 eclass/go-env.eclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass
index a38c208d7bf1..295ecf5a5fd3 100644
--- a/eclass/go-env.eclass
+++ b/eclass/go-env.eclass
@@ -20,7 +20,7 @@ esac
 if [[ -z ${_GO_ENV_ECLASS} ]]; then
 _GO_ENV_ECLASS=1
 
-inherit flag-o-matic multiprocessing toolchain-funcs
+inherit flag-o-matic multiprocessing sysroot toolchain-funcs
 
 # @FUNCTION: go-env_set_compile_environment
 # @DESCRIPTION:
@@ -77,6 +77,13 @@ go-env_set_compile_environment() {
                CGO_CPPFLAGS=${CPPFLAGS} \
                CGO_CXXFLAGS=${CXXFLAGS} \
                CGO_LDFLAGS=${LDFLAGS}
+
+       # go run will build binaries for the target system and try to execute 
them.
+       # This will fail when cross-compiling unless you provide a wrapper.
+       local script
+       if script=$(sysroot_make_run_prefixed); then
+               GOFLAGS+=" -exec=${script}" "${@}"
+       fi
 }
 
 # @FUNCTION: go-env_goos
-- 
2.53.0


Reply via email to