[OE-core] [PATCH] go-runtime: prevent host leakage into target objects
Matt Madison
matt at madison.systems
Fri Sep 29 14:15:51 UTC 2017
When building for a target whose architecture matches
the build host's, the second pass through make.bash
to build the shareable runtime would also overwrite
the target's static cgo library with host-compatibile
binaries.
Fix this by running the host-side build once and
target-only passes of make.bash twice, for static
and shareable. This ensures that what gets installed
is target-compatible.
[YOCTO #12136]
Signed-off-by: Matt Madison <matt at madison.systems>
---
meta/recipes-devtools/go/go-runtime.inc | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index 934d1aa..bd26e2e 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -23,9 +23,13 @@ do_compile() {
rm -rf ${GOBIN} ${B}/pkg
mkdir ${GOBIN}
cd src
- GO_FLAGS="" ./make.bash
+ ./make.bash --host-only
+ cp ${B}/pkg/tool/${BUILD_GOTUPLE}/go_bootstrap ${B}
+ rm -rf ${B}/pkg/${TARGET_GOTUPLE}
+ ./make.bash --target-only
if [ -n "${GO_DYNLINK}" ]; then
- GO_FLAGS="-buildmode=shared" GO_LDFLAGS="-extldflags \"${LDFLAGS}\"" ./make.bash
+ cp ${B}/go_bootstrap ${B}/pkg/tool/${BUILD_GOTUPLE}
+ GO_FLAGS="-buildmode=shared" GO_LDFLAGS="-extldflags \"${LDFLAGS}\"" ./make.bash --target-only
fi
cd ${B}
}
@@ -41,8 +45,9 @@ do_install() {
rm -rf ${D}${libdir}/go/pkg/obj
rm -rf ${D}${libdir}/go/pkg/bootstrap
find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do
- [ "$srcdir" = "./cmd" ] || cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
+ cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
done
+ rm -f ${D}${libdir}/go/src/cmd/dist/dist
}
# Remove test binaries that cannot be relocated
--
2.7.4
More information about the Openembedded-core
mailing list