Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v3 0/1] go-runtime: prevent host leakage into target objects
@ 2017-10-04 18:21 Matt Madison
  2017-10-04 18:21 ` [PATCH v3 1/1] " Matt Madison
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Madison @ 2017-10-04 18:21 UTC (permalink / raw)
  To: openembedded-core; +Cc: otavio, saul.wold

Updated patch for fixing go builds for musl with x86-64
targets.

New in v3:
 * Put back the Yocto bug number missing in v2.

New in v2:
 * Remove runtime support for go's race detector for
   musl targets.  Go includes pre-built binaries for
   this, which are built against glibc and lead to
   linker errors for the missing glibc symbols.

Matt Madison (1):
  go-runtime: prevent host leakage into target objects

 meta/recipes-devtools/go/go-runtime.inc | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v3 1/1] go-runtime: prevent host leakage into target objects
  2017-10-04 18:21 [PATCH v3 0/1] go-runtime: prevent host leakage into target objects Matt Madison
@ 2017-10-04 18:21 ` Matt Madison
  2017-10-05  0:02   ` Saul Wold
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Madison @ 2017-10-04 18:21 UTC (permalink / raw)
  To: openembedded-core; +Cc: otavio, saul.wold

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>
---
 meta/recipes-devtools/go/go-runtime.inc | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index 934d1aa..f181dc7 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
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 1/1] go-runtime: prevent host leakage into target objects
  2017-10-04 18:21 ` [PATCH v3 1/1] " Matt Madison
@ 2017-10-05  0:02   ` Saul Wold
  0 siblings, 0 replies; 3+ messages in thread
From: Saul Wold @ 2017-10-05  0:02 UTC (permalink / raw)
  To: Matt Madison, openembedded-core; +Cc: otavio

On Wed, 2017-10-04 at 18:21 +0000, Matt Madison wrote:
> 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>
Thanks Matt!

Acked-by: Saul Wold <sgw@linux.intel.com>
Tested-by: Saul Wold <sgw@linux.intel.com>


> ---
>  meta/recipes-devtools/go/go-runtime.inc | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-
> devtools/go/go-runtime.inc
> index 934d1aa..f181dc7 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
> -- 
> 2.7.4
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-05  0:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-04 18:21 [PATCH v3 0/1] go-runtime: prevent host leakage into target objects Matt Madison
2017-10-04 18:21 ` [PATCH v3 1/1] " Matt Madison
2017-10-05  0:02   ` Saul Wold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox