diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -13,6 +13,8 @@ # (src/tools/xref.sh): build/xref/report.txt and report.json; # make xref XREF_ARGS=--check compares with tests/xref.baseline # make genome build/core/genome.bin from src/, with the fixpoint check +# make NOLLVM=1 leave the llvm backend out of zy (it is in by default when an +# llvm-config with headers is on PATH, or LLVM_CONFIG names one) # make build/bin/zyi the interpreter alone (zy has a jit on arm64 and on x86-64 linux) # make lsp build/bin/zclsp, the language server # make web build/web/: the page, its script and zc.wasm @@ -95,9 +97,30 @@ $(B)/core/genome.bin: $(ZC_DEPS) $(BIN)/zc0$(EXE) $(BIN)/mkgenome$(EXE) src/core cp $(B)/s1/genome.bin $@ @echo "fixpoint: $$(( $$(wc -c < $@) / 8 )) words, $@ updated" -# the vm core with the compiler genome inside: a jit on arm64 and x86-64 linux, else the interpreter +# the llvm backend (-DZYLLVM) goes into zy whenever an llvm with headers is found: +# LLVM_CONFIG when given, else llvm-config, else llvm-config-19 on PATH. llvm-config can +# exist without the headers (a runtime-only install), so the gate is llvm-c/Core.h. +# NOLLVM=1 leaves it out. zy does not record which way it was built: after changing +# NOLLVM or the llvm, rebuild it (rm build/bin/zy, or make clean). +ifneq ($(NOLLVM),1) + ifeq ($(origin LLVM_CONFIG),undefined) + LLVM_CONFIG := $(firstword $(shell command -v llvm-config llvm-config-19 2>/dev/null)) + endif + ifneq ($(LLVM_CONFIG),) + ifneq ($(wildcard $(shell $(LLVM_CONFIG) --includedir 2>/dev/null)/llvm-c/Core.h),) + LLVM_CFLAGS := -DZYLLVM $(shell $(LLVM_CONFIG) --cflags) + LLVM_LIBS := $(shell $(LLVM_CONFIG) --ldflags --libs) + endif + endif + ifeq ($(LLVM_CFLAGS),) + $(info note: no llvm-config with headers found, building zy without the llvm backend (NOLLVM=1 silences this)) + endif +endif + +# the vm core with the compiler genome inside: a jit on arm64 and x86-64 linux, else the +# interpreter; plus the llvm backend when found (above) $(BIN)/zy$(EXE): src/core/core.c $(IO) $(B)/core/genome.bin $(CORE_H) | $(BIN) - $(CC) $(CFLAGS) -DJTYPE=int src/core/core.c $(IO) $(COREINC) -o $@ + $(CC) $(CFLAGS) -DJTYPE=int $(LLVM_CFLAGS) src/core/core.c $(IO) $(COREINC) -o $@ $(LLVM_LIBS) # the interpreter alone, even on a host with a jit: make build/bin/zyi, to compare against zy $(BIN)/zyi$(EXE): src/core/core.c $(IO) $(B)/core/genome.bin $(CORE_H) | $(BIN) $(CC) $(CFLAGS) -DZYINTERP -DJTYPE=int src/core/core.c $(IO) $(COREINC) -o $@ |
