Date: Monday, March 2, 2020 @ 03:32:25 Author: anatolik Revision: 588431
tinygo: add Go compiler for microcontrollers/wasm Added: tinygo/ tinygo/repos/ tinygo/trunk/ tinygo/trunk/PKGBUILD tinygo/trunk/disable_static_llvm.patch ---------------------------+ PKGBUILD | 65 ++++++++++++++++++++++++++++++++++++++++++++ disable_static_llvm.patch | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) Added: tinygo/trunk/PKGBUILD =================================================================== --- tinygo/trunk/PKGBUILD (rev 0) +++ tinygo/trunk/PKGBUILD 2020-03-02 03:32:25 UTC (rev 588431) @@ -0,0 +1,65 @@ +# Maintainer: Anatol Pomozov <[email protected]> + +pkgname=tinygo +pkgver=0.12.0 +pkgrel=1 +pkgdesc='Go compiler for small places. Microcontrollers, WebAssembly, and command-line tools. Based on LLVM.' +arch=(x86_64) +url='https://github.com/tinygo-org/tinygo' +license=(BSD) +options=(!strip) +depends=(llvm-libs clang) +makedepends=(go llvm git) +# use gt as we need to fetch submodules +source=(git+https://github.com/tinygo-org/tinygo#tag=v$pkgver + git+https://github.com/NordicSemiconductor/nrfx + git+https://github.com/ARM-software/CMSIS + git+https://github.com/avr-rust/avr-mcu + git+https://github.com/tinygo-org/cmsis-svd + git+https://github.com/llvm-mirror/compiler-rt + git+https://github.com/CraneStation/wasi-libc + disable_static_llvm.patch) +sha256sums=('SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'e56a93e3517c37e75f5278b8b2bf27f6297cb119ba9cb8d3a678627e204b07a6') + +prepare() { + cd tinygo + + git submodule init + git config -f .gitmodules 'submodule.lib/nrfx.url' "$srcdir/nrfx" + git config -f .gitmodules 'submodule.lib/CMSIS.url' "$srcdir/CMSIS" + git config -f .gitmodules 'submodule.lib/avr.url' "$srcdir/avr-mcu" + git config -f .gitmodules 'submodule.lib/cmsis-svd.url' "$srcdir/cmsis-svd" + git config -f .gitmodules 'submodule.lib/compiler-rt.url' "$srcdir/compiler-rt" + git config -f .gitmodules 'submodule.lib/wasi-libc.url' "$srcdir/wasi-libc" + git submodule sync + git submodule update + + patch -p1 < ../disable_static_llvm.patch +} + +build() { + cd tinygo + make +} + +check() { + cd tinygo + # it reqreires a lot of dependencies. todo enable the tests + # make test tinygo-test smoketest +} + +package() { + cd tinygo + make release + + install -d "$pkgdir"/usr/bin "$pkgdir"/usr/lib/tinygo + mv build/release/tinygo/* "$pkgdir"/usr/lib/tinygo + ln -s /usr/lib/tinygo/bin/tinygo "$pkgdir"/usr/bin/tinygo +} Property changes on: tinygo/trunk/PKGBUILD ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: tinygo/trunk/disable_static_llvm.patch =================================================================== --- tinygo/trunk/disable_static_llvm.patch (rev 0) +++ tinygo/trunk/disable_static_llvm.patch 2020-03-02 03:32:25 UTC (rev 588431) @@ -0,0 +1,59 @@ +diff --git a/Makefile b/Makefile +index 81bbfac..6630a36 100644 +--- a/Makefile ++++ b/Makefile +@@ -8,9 +8,9 @@ CLANG_SRC ?= llvm-project/clang + LLD_SRC ?= llvm-project/lld + + # Default tool selection. +-CLANG ?= clang-9 +-LLVM_AR ?= llvm-ar-9 +-LLVM_NM ?= llvm-nm-9 ++CLANG ?= clang ++LLVM_AR ?= llvm-ar ++LLVM_NM ?= llvm-nm + + # Go binary and GOROOT to select + GO ?= go +@@ -153,11 +152,10 @@ lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a: + + # Build the Go compiler. + tinygo: +- @if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo " make llvm-source"; echo " make $(LLVM_BUILDDIR)"; exit 1; fi +- CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) build -o build/tinygo$(EXE) -tags byollvm . ++ CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) build -o build/tinygo$(EXE) . + + test: wasi-libc +- CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test -v -tags byollvm ./cgo ./compileopts ./interp ./transform . ++ CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test -v ./cgo ./compileopts ./interp ./transform . + + tinygo-test: + cd tests/tinygotest && tinygo test +@@ -289,7 +287,6 @@ release: tinygo gen-device wasi-libc + @mkdir -p build/release/tinygo/pkg/armv7em-none-eabi + @echo copying source files + @cp -p build/tinygo$(EXE) build/release/tinygo/bin +- @cp -p $(abspath $(CLANG_SRC))/lib/Headers/*.h build/release/tinygo/lib/clang/include + @cp -rp lib/CMSIS/CMSIS/Include build/release/tinygo/lib/CMSIS/CMSIS + @cp -rp lib/CMSIS/README.md build/release/tinygo/lib/CMSIS + @cp -rp lib/compiler-rt/lib/builtins build/release/tinygo/lib/compiler-rt/lib +@@ -302,4 +299,3 @@ release: tinygo gen-device wasi-libc + ./build/tinygo build-builtins -target=armv6m-none-eabi -o build/release/tinygo/pkg/armv6m-none-eabi/compiler-rt.a + ./build/tinygo build-builtins -target=armv7m-none-eabi -o build/release/tinygo/pkg/armv7m-none-eabi/compiler-rt.a + ./build/tinygo build-builtins -target=armv7em-none-eabi -o build/release/tinygo/pkg/armv7em-none-eabi/compiler-rt.a +- tar -czf build/release.tar.gz -C build/release tinygo +diff --git a/builder/config.go b/builder/config.go +index 8bb3a11..5010842 100644 +--- a/builder/config.go ++++ b/builder/config.go +@@ -25,8 +25,8 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) { + if err != nil { + return nil, fmt.Errorf("could not read version from GOROOT (%v): %v", goroot, err) + } +- if major != 1 || (minor != 11 && minor != 12 && minor != 13) { +- return nil, fmt.Errorf("requires go version 1.11, 1.12, or 1.13, got go%d.%d", major, minor) ++ if major != 1 || (minor != 11 && minor != 12 && minor != 13 && minor != 14) { ++ return nil, fmt.Errorf("requires go version 1.11, 1.12, or 1.13, or 1.14, got go%d.%d", major, minor) + } + clangHeaderPath := getClangHeaderPath(goenv.Get("TINYGOROOT")) + return &compileopts.Config{
