@@ -141,35 +141,39 @@ endif
141141ENABLE_JIT ?= 0
142142$(call set-feature, JIT)
143143ifeq ($(call has, JIT) , 1)
144- OBJS_EXT += jit.o
145- # tier-2 JIT compiler powered LLVM
146- LLVM_CONFIG = llvm-config-17
147- LLVM_CONFIG := $(shell which $(LLVM_CONFIG ) )
148- ifndef LLVM_CONFIG
149- # Try Homebrew on macOS
150- LLVM_CONFIG = /opt/homebrew/opt/llvm@17/bin/llvm-config
151- LLVM_CONFIG := $(shell which $(LLVM_CONFIG ) )
152- ifdef LLVM_CONFIG
153- LDFLAGS += -L/opt/homebrew/opt/llvm@17/lib
154- endif
155- endif
156- ifneq ("$(LLVM_CONFIG ) ", "")
157- ifneq ("$(findstring -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS, "$(shell $(LLVM_CONFIG ) --cflags) ") ", "")
158- ENABLE_T2C := 1
159- $(call set-feature, T2C)
160- OBJS_EXT += t2c.o
161- CFLAGS += -g $(shell $(LLVM_CONFIG ) --cflags)
162- LDFLAGS += $(shell $(LLVM_CONFIG ) --libs)
163- else
164- ENABLE_T2C := 0
165- $(call set-feature, T2C)
166- $(warning No llvm-config-17 installed. Check llvm-config-17 installation in advance)
167- endif
168- endif
169-
170- ifneq ($(processor ) ,$(filter $(processor ) ,x86_64 aarch64 arm64) )
171- $(error JIT mode only supports for x64 and arm64 target currently.)
172- endif
144+ OBJS_EXT += jit.o
145+ ENABLE_T2C ?= 1
146+ $(call set-feature, T2C)
147+ ifeq ($(call has, T2C), 1)
148+ # tier-2 JIT compiler is powered by LLVM
149+ LLVM_CONFIG = llvm-config-18
150+ LLVM_CONFIG := $(shell which $(LLVM_CONFIG ) )
151+ ifndef LLVM_CONFIG
152+ # Try Homebrew on macOS
153+ LLVM_CONFIG = /opt/homebrew/opt/llvm@18/bin/llvm-config
154+ LLVM_CONFIG := $(shell which $(LLVM_CONFIG ) )
155+ ifdef LLVM_CONFIG
156+ LDFLAGS += -L/opt/homebrew/opt/llvm@18/lib
157+ endif
158+ endif
159+ ifeq ("$(LLVM_CONFIG)", "")
160+ $(error No llvm-config-18 installed. Check llvm-config-18 installation in advance, or use "ENABLE_T2C=0" to disable tier-2 LLVM compiler)
161+ endif
162+ ifeq ("$(findstring -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS, "$(shell $(LLVM_CONFIG) --cflags)")", "")
163+ $(error No llvm-config-18 installed. Check llvm-config-18 installation in advance, or use "ENABLE_T2C=0" to disable tier-2 LLVM compiler)
164+ endif
165+ CHECK_LLVM_LIBS := $(shell $(LLVM_CONFIG ) --libs 2>/dev/null 1>&2; echo $$? )
166+ ifeq ("$(CHECK_LLVM_LIBS)", "0")
167+ OBJS_EXT += t2c.o
168+ CFLAGS += -g $(shell $(LLVM_CONFIG ) --cflags)
169+ LDFLAGS += $(shell $(LLVM_CONFIG ) --libs)
170+ else
171+ $(error No llvm-config-18 installed. Check llvm-config-18 installation in advance, or use "ENABLE_T2C=0" to disable tier-2 LLVM compiler)
172+ endif
173+ endif
174+ ifneq ($(processor),$(filter $(processor),x86_64 aarch64 arm64))
175+ $(error JIT mode only supports for x64 and arm64 target currently.)
176+ endif
173177
174178src/rv32_jit.c :
175179 $(Q ) tools/gen-jit-template.py $(CFLAGS ) > $@
0 commit comments