Skip to content

Commit

Permalink
Skip building llvm_ext.cc on LLVM 18 or above (#14357)
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil authored Mar 13, 2024
1 parent 84b0cdb commit 2b0b506
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ 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)
CXXFLAGS += $(if $(debug),-g -O0)
CRYSTAL_VERSION ?= $(shell cat src/VERSION)

Expand All @@ -80,6 +79,13 @@ else
colorize = $(shell printf >&2 "\033[33m$1\033[0m\n")
endif

DEPS = $(LLVM_EXT_OBJ)
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
10 changes: 8 additions & 2 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ LLVM_CONFIG ?=
LLVM_VERSION := $(if $(LLVM_CONFIG),$(shell $(LLVM_CONFIG) --version))
LLVM_EXT_DIR = src\llvm\ext
LLVM_EXT_OBJ = $(LLVM_EXT_DIR)\llvm_ext.obj
DEPS = $(LLVM_EXT_OBJ)
CXXFLAGS += $(if $(static),$(if $(debug),/MTd /Od ,/MT ),$(if $(debug),/MDd /Od ,/MD ))
CRYSTAL_VERSION ?= $(shell type src\VERSION)

Expand All @@ -82,6 +81,13 @@ DATADIR ?= $(prefix)

colorize = $1

DEPS = $(LLVM_EXT_OBJ)
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 2b0b506

Please sign in to comment.