diff options
author | Ayke van Laethem <[email protected]> | 2021-02-08 13:16:24 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-02-09 08:03:54 +0100 |
commit | 9f5bd2c460cfcf5dca40fe043d8a51a25f1a79b3 (patch) | |
tree | 9e244ad17f1f3a62ced670755dc3469d72f3a889 /Makefile | |
parent | d6cdf8ca289487b75d6310998eba45aa56545156 (diff) | |
download | tinygo-9f5bd2c460cfcf5dca40fe043d8a51a25f1a79b3.tar.gz tinygo-9f5bd2c460cfcf5dca40fe043d8a51a25f1a79b3.zip |
ci: only build the necessary LLVM libraries and tools
This should improve rebuild time, but perhaps more importantly massively
reduces cache size which then reduces incremental build time.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -54,32 +54,46 @@ ifeq ($(OS),Windows_NT) CGO_LDFLAGS += -static -static-libgcc -static-libstdc++ CGO_LDFLAGS_EXTRA += -lversion - LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/liblibclang.a + LIBCLANG_NAME = libclang else ifeq ($(shell uname -s),Darwin) MD5SUM = md5 - LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a + LIBCLANG_NAME = clang else ifeq ($(shell uname -s),FreeBSD) MD5SUM = md5 - LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a + LIBCLANG_NAME = clang START_GROUP = -Wl,--start-group END_GROUP = -Wl,--end-group else - LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a + LIBCLANG_NAME = clang START_GROUP = -Wl,--start-group END_GROUP = -Wl,--end-group endif -CLANG_LIBS = $(START_GROUP) -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 $(END_GROUP) -lstdc++ +# Libraries that should be linked in for the statically linked Clang. +CLANG_LIB_NAMES = clangAnalysis clangARCMigrate clangAST clangASTMatchers clangBasic clangCodeGen clangCrossTU clangDriver clangDynamicASTMatchers clangEdit clangFormat clangFrontend clangFrontendTool clangHandleCXX clangHandleLLVM clangIndex clangLex clangParse clangRewrite clangRewriteFrontend clangSema clangSerialization clangStaticAnalyzerCheckers clangStaticAnalyzerCore clangStaticAnalyzerFrontend clangTooling clangToolingASTDiff clangToolingCore clangToolingInclusions +CLANG_LIBS = $(START_GROUP) $(addprefix -l,$(CLANG_LIB_NAMES)) $(END_GROUP) -lstdc++ -LLD_LIBS = $(START_GROUP) -llldCOFF -llldCommon -llldCore -llldDriver -llldELF -llldMachO -llldMinGW -llldReaderWriter -llldWasm -llldYAML $(END_GROUP) +# Libraries that should be linked in for the statically linked LLD. +LLD_LIB_NAMES = lldCOFF lldCommon lldCore lldDriver lldELF lldMachO lldMinGW lldReaderWriter lldWasm lldYAML +LLD_LIBS = $(START_GROUP) $(addprefix -l,$(LLD_LIB_NAMES)) $(END_GROUP) +# Other libraries that are needed to link TinyGo. +EXTRA_LIB_NAMES = LLVMInterpreter + +# These build targets appear to be the only ones necessary to build all TinyGo +# dependencies. Only building a subset significantly speeds up rebuilding LLVM. +# The Makefile rules convert a name like lldELF to lib/liblldELF.a to match the +# library path (for ninja). +# This list also includes a few tools that are necessary as part of the full +# TinyGo build. +NINJA_BUILD_TARGETS = clang llvm-config llvm-ar llvm-nm $(addprefix lib/lib,$(addsuffix .a,$(LIBCLANG_NAME) $(CLANG_LIB_NAMES) $(LLD_LIB_NAMES) $(EXTRA_LIB_NAMES))) # For static linking. ifneq ("$(wildcard $(LLVM_BUILDDIR)/bin/llvm-config*)","") CGO_CPPFLAGS+=$(shell $(LLVM_BUILDDIR)/bin/llvm-config --cppflags) -I$(abspath $(LLVM_BUILDDIR))/tools/clang/include -I$(abspath $(CLANG_SRC))/include -I$(abspath $(LLD_SRC))/include CGO_CXXFLAGS=-std=c++14 - CGO_LDFLAGS+=$(LIBCLANG_PATH) -L$(abspath $(LLVM_BUILDDIR)/lib) $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA) + CGO_LDFLAGS+=$(abspath $(LLVM_BUILDDIR))/lib/lib$(LIBCLANG_NAME).a -L$(abspath $(LLVM_BUILDDIR)/lib) $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA) endif @@ -146,7 +160,7 @@ $(LLVM_BUILDDIR)/build.ninja: llvm-source # Build LLVM. $(LLVM_BUILDDIR): $(LLVM_BUILDDIR)/build.ninja - cd $(LLVM_BUILDDIR); ninja + cd $(LLVM_BUILDDIR); ninja $(NINJA_BUILD_TARGETS) # Build wasi-libc sysroot |