diff options
author | Ayke van Laethem <[email protected]> | 2019-04-04 02:21:54 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-04-05 13:30:38 +0200 |
commit | 1778d9285820ad8c0f1834ed5674dcf760f73014 (patch) | |
tree | 316a0433ec392b70fd2dcad41a7d893561fb0512 | |
parent | 86f87787489be061698bb03cc9fb5e7e3be65cb3 (diff) | |
download | tinygo-1778d9285820ad8c0f1834ed5674dcf760f73014.tar.gz tinygo-1778d9285820ad8c0f1834ed5674dcf760f73014.zip |
Makefile: automatically build LLVM when needed
-rw-r--r-- | Makefile | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -3,7 +3,7 @@ all: tinygo tinygo: build/tinygo -.PHONY: all tinygo static run-test run-blinky run-blinky2 clean fmt gen-device gen-device-nrf gen-device-avr +.PHONY: all tinygo llvm-build llvm-source static run-test run-blinky run-blinky2 clean fmt gen-device gen-device-nrf gen-device-avr TARGET ?= unix @@ -40,6 +40,11 @@ $(error Unknown target) endif +# Default build and source directories, as created by `make llvm-build`. +LLVM_BUILDDIR ?= llvm-build +CLANG_SRC ?= llvm/tools/clang +LLD_SRC ?= llvm/tools/lld + LLVM_COMPONENTS = all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines debuginfodwarf executionengine instrumentation interpreter ipo irreader linker lto mc mcjit objcarcopts option profiledata scalaropts support target CLANG_LIBS = -Wl,--start-group $(abspath $(LLVM_BUILDDIR))/lib/libclang.a -lclangAnalysis -lclangARCMigrate -lclangAST -lclangASTMatchers -lclangBasic -lclangCodeGen -lclangCrossTU -lclangDriver -lclangDynamicASTMatchers -lclangEdit -lclangFormat -lclangFrontend -lclangFrontendTool -lclangHandleCXX -lclangHandleLLVM -lclangIndex -lclangLex -lclangParse -lclangRewrite -lclangRewriteFrontend -lclangSema -lclangSerialization -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangStaticAnalyzerFrontend -lclangTooling -lclangToolingASTDiff -lclangToolingCore -lclangToolingInclusions -lclangToolingRefactor -Wl,--end-group -lstdc++ @@ -107,6 +112,25 @@ gen-device-stm32: ./tools/gen-device-svd.py lib/cmsis-svd/data/STMicro/ src/device/stm32/ --source=https://github.com/posborne/cmsis-svd/tree/master/data/STMicro go fmt ./src/device/stm32 + +# Get LLVM sources. +llvm/README.txt: + git clone -b release_80 https://github.com/llvm-mirror/llvm.git llvm +llvm/tools/clang/README.txt: + git clone -b release_80 https://github.com/llvm-mirror/clang.git llvm/tools/clang +llvm/tools/lld/README.md: + git clone -b release_80 https://github.com/llvm-mirror/lld.git llvm/tools/lld +llvm-source: llvm/README.txt llvm/tools/clang/README.txt llvm/tools/lld/README.md + +# Configure LLVM. +llvm-build/build.ninja: llvm-source + mkdir -p llvm-build; cd llvm-build; cmake -G Ninja ../llvm "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;WebAssembly" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF -DLIBCLANG_BUILD_STATIC=ON + +# Build LLVM. +llvm-build: llvm-build/build.ninja + cd llvm-build; ninja + + # Build the Go compiler. build/tinygo: @mkdir -p build @@ -115,6 +139,9 @@ build/tinygo: static: CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o build/tinygo -tags byollvm . +static-test: + CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go test -tags byollvm . + release: static gen-device @mkdir -p build/release/tinygo/bin @mkdir -p build/release/tinygo/lib/CMSIS/CMSIS |