[PATCH 4/4] go-env.eclass: Create named go run wrapper rather than using -exec
James Le Cuirot <[email protected]>
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
Some projects unset GOOS and GOARCH before running `go run` in order to
force the build host. Giving the wrapper using `GOFLAGS="-exec=..."`
breaks this because that expects the target host. `go run` can also find
the wrapper in the PATH as `go_${GOOS}_${GOARCH}_exec`, so take this
more targetted approach instead.
Signed-off-by: James Le Cuirot <[email protected]>
---
eclass/go-env.eclass | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass
index f8de40a596d0..af843a8e81ba 100644
--- a/eclass/go-env.eclass
+++ b/eclass/go-env.eclass
@@ -167,9 +167,12 @@ go-env_set_compile_environment() {
# 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
+ local script go_exec
if script=$(sysroot_make_run_prefixed); then
- GOFLAGS+=" -exec=${script}" "${@}"
+ go_exec="${T}/go-exec"
+ PATH="${go_exec}:${PATH}"
+ mkdir -p "${go_exec}" || die
+ ln -snfr "${script}" "${go_exec}/go_${GOOS}_${GOARCH}_exec" || die
fi
}
--
2.53.0