From 1b0aeaa4e84be4449a73b24a0a57c04c02589a81 Mon Sep 17 00:00:00 2001 From: Marco Vanotti Date: Wed, 10 Jul 2019 17:54:20 -0700 Subject: Makefile: build fuchsia go binaries using the sdk This commit removes a dependency on fuchsia's tools/devshell/contrib/go, which was removed recently[0]. Now to build go binaries for fuchsia we are not relying on the fuchsia.git repo at all. The code just needs a copy of the fuchsia //third_party/go repository, the fuchsia sdk and a copy of clang. Users should download the sdk and clang beforehand (see documentation for links), and then run (with the correct environment variables): ``` $ make TARGETOS=fuchsia TARGETARCH=amd64 \ SOURCEDIR=$HOME/fuchsia \ FX_SDK_PATH=${HOME}/sdk/fuchsia-sdk \ CLANG_PATH=${HOME}/sdk/clang \ fuchsia_go ``` After that, they will be able to build the syzkaller go binaries by doing: ``` $ make TARGETOS=fuchsia TARGETARCH=amd64 \ SOURCEDIR=$HOME/fuchsia \ FX_SDK_PATH=${HOME}/sdk/fuchsia-sdk \ CLANG_PATH=${HOME}/sdk/clang ``` This commits adds two scripts to tools/fuchsia, one for building go in fuchsia (just calls the ./make.all script in fuchsia's go repo), and one that replaces the devshell/contrib/go script. Given that go is unsupported in fuchsia, this change might break at any point. [0]: https://fuchsia-review.googlesource.com/c/fuchsia/+/291631 --- tools/fuchsia/build-go.sh | 32 ++++++++++++++++++++++++++++++++ tools/fuchsia/go | 26 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 tools/fuchsia/build-go.sh create mode 100755 tools/fuchsia/go (limited to 'tools') diff --git a/tools/fuchsia/build-go.sh b/tools/fuchsia/build-go.sh new file mode 100755 index 000000000..49ce0f418 --- /dev/null +++ b/tools/fuchsia/build-go.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# This script can be used to compile Go for fuchsia. +# You need to have a fuchsia checkout defined in the FX_SRC_PATH variable, +# The fuchsia sdk in the FX_SDK_PATH variable, and a CLANG compatible with +# fuchsia in CLANG_PATH. + +if [[ -z ${FX_SDK_PATH} ]]; then + echo "FX_SDK_PATH variable not set" + exit 1 +fi + +if [[ -z ${FX_SRC_PATH} ]]; then + echo "FX_SRC_PATH variable not set" + exit 1 +fi + +if [[ -z ${CLANG_PATH} ]]; then + echo "CLANG_PATH variable not set" + exit 1 +fi + +cd "${FX_SRC_PATH}/third_party/go/src" + +FUCHSIA_SHARED_LIBS=${FX_SDK_PATH}/arch/x64/lib \ + CLANG_PREFIX=${CLANG_PATH}/bin \ + FDIO_INCLUDE=${FX_SDK_PATH}/pkg/fdio/include \ + ZIRCON_SYSROOT=${FX_SDK_PATH}/arch/x64/sysroot \ + CC=${FX_SRC_PATH}/third_party/go/misc/fuchsia/clangwrap.sh \ + CGO_ENABLED=1 \ + GOOS=fuchsia \ + ./make.bash diff --git a/tools/fuchsia/go b/tools/fuchsia/go new file mode 100755 index 000000000..bff63d190 --- /dev/null +++ b/tools/fuchsia/go @@ -0,0 +1,26 @@ +#!/bin/bash + +if [[ -z ${FX_SDK_PATH} ]]; then + echo "FX_SDK_PATH variable not set" + exit 1 +fi + +if [[ -z ${FX_SRC_PATH} ]]; then + echo "FX_SRC_PATH variable not set" + exit 1 +fi + +if [[ -z ${CLANG_PATH} ]]; then + echo "CLANG_PATH variable not set" + exit 1 +fi + +FUCHSIA_SHARED_LIBS="${FX_SDK_PATH}/arch/x64/lib" \ + CLANG_PREFIX="${CLANG_PATH}/bin" \ + FDIO_INCLUDE="${FX_SDK_PATH}/pkg/fdio/include" \ + ZIRCON_SYSROOT="${FX_SDK_PATH}/arch/x64/sysroot" \ + CC="${FX_SRC_PATH}/third_party/go/misc/fuchsia/clangwrap.sh" \ + CGO_ENABLED=1 \ + GOOS=fuchsia \ + GOROOT="${FX_SRC_PATH}/third_party/go" \ + "${FX_SRC_PATH}/third_party/go/bin/go" "$@" -- cgit mrf-deployment