aboutsummaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMatt Madison <matt@madison.systems>2017-10-04 18:21:52 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-10-06 12:03:32 +0100
commit070f4af529c84a3c8c0b1ffc7b138bdd9e8439b7 (patch)
treec15e3568a9031da4e498146c4365b606a5807207 /meta
parent1bc4c1d880096083d1891a74024fb225a6340b9b (diff)
downloadopenembedded-core-contrib-070f4af529c84a3c8c0b1ffc7b138bdd9e8439b7.tar.gz
go-runtime: prevent host leakage into target objects
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. Also fix an issue with x86-64 targets running MUSL by removing the pre-built (for glibc) objects for the race detector runtime before building. [YOCTO #12136] Signed-off-by: Matt Madison <matt@madison.systems> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/go/go-runtime.inc19
1 files changed, 15 insertions, 4 deletions
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index 934d1aaeb93..f181dc7a299 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -15,7 +15,13 @@ export CC_FOR_TARGET="${CC}"
export CXX_FOR_TARGET="${CXX}"
export GOROOT_OVERRIDE = "1"
-do_configure[noexec] = "1"
+do_configure() {
+ :
+}
+
+do_configure_libc-musl() {
+ rm -f ${S}/src/runtime/race/*.syso
+}
do_compile() {
export GOBIN="${B}/bin"
@@ -23,9 +29,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 +51,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