Skip to content

Commit

Permalink
Skip building llvm_ext.cc on LLVM 18 or above
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Mar 11, 2024
1 parent d15649f commit 75d073f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ EXPORTS_BUILD := \
CRYSTAL_CONFIG_LIBRARY_PATH=$(CRYSTAL_CONFIG_LIBRARY_PATH)
SHELL = sh
LLVM_CONFIG := $(shell src/llvm/ext/find-llvm-config)
LLVM_VERSION := $(if $(LLVM_CONFIG), $(shell $(LLVM_CONFIG) --version 2> /dev/null))
LLVM_VERSION := $(if $(LLVM_CONFIG),$(shell $(LLVM_CONFIG) --version 2> /dev/null))
LLVM_EXT_DIR = src/llvm/ext
LLVM_EXT_OBJ = $(LLVM_EXT_DIR)/llvm_ext.o
DEPS = $(LLVM_EXT_OBJ)
Expand All @@ -80,6 +80,12 @@ else
colorize = $(shell printf >&2 "\033[33m$1\033[0m\n")
endif

ifneq ($(LLVM_VERSION),)
ifeq ($(shell test $(firstword $(subst ., ,$(LLVM_VERSION))) -ge 18; echo $$?),0)
DEPS =
endif
endif

check_llvm_config = $(eval \
check_llvm_config := $(if $(LLVM_VERSION),\
$(call colorize,Using $(LLVM_CONFIG) [version=$(LLVM_VERSION)]),\
Expand Down Expand Up @@ -208,7 +214,7 @@ $(O)/primitives_spec: $(O)/crystal $(DEPS) $(SOURCES) $(SPEC_SOURCES)
@mkdir -p $(O)
$(EXPORT_CC) ./bin/crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec/primitives_spec.cr

$(O)/interpreter_spec: deps $(SOURCES) $(SPEC_SOURCES)
$(O)/interpreter_spec: $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(eval interpreter=1)
@mkdir -p $(O)
$(EXPORT_CC) ./bin/crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec/compiler/interpreter_spec.cr
Expand Down
8 changes: 7 additions & 1 deletion Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ DATADIR ?= $(prefix)

colorize = $1

ifneq ($(LLVM_VERSION),)
ifeq ($(shell if $(firstword $(subst ., ,$(LLVM_VERSION))) GEQ 18 echo 0),0)
DEPS =
endif
endif

check_llvm_config = $(eval \
check_llvm_config := $(if $(LLVM_VERSION),\
$(info $(call colorize,Using $(LLVM_CONFIG) [version=$(LLVM_VERSION)])),\
Expand Down Expand Up @@ -198,7 +204,7 @@ $(O)\primitives_spec.exe: $(O)\crystal.exe $(DEPS) $(SOURCES) $(SPEC_SOURCES)
@$(call MKDIR,"$(O)")
.\bin\crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o "$@" spec\primitives_spec.cr

$(O)\interpreter_spec: deps $(SOURCES) $(SPEC_SOURCES)
$(O)\interpreter_spec: $(DEPS) $(SOURCES) $(SPEC_SOURCES)
$(eval interpreter=1)
@$(call MKDIR, "$(O)")
.\bin\crystal build $(FLAGS) $(SPEC_WARNINGS_OFF) -o $@ spec\compiler\interpreter_spec.cr
Expand Down

0 comments on commit 75d073f

Please sign in to comment.