Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip building llvm_ext.cc on LLVM 18 or above #14357

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Comment on lines +83 to +87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Could we move this visually closer to the definition of DEPS to make it easier to reason about?
Or even put everything into a single conditional?

if (LLVM < 18)
  DEPS = $(LLVM_EXT_OBJ)
else
  DEPS =
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