Repository navigation
Expand file tree
/
Copy pathMakefile.worktree
More file actions
45 lines (41 loc) · 2.84 KB
/
Copy pathMakefile.worktree
File metadata and controls
45 lines (41 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Shared dependency configuration, included by the root and component Makefiles.
CATALYST_ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
CATALYST_WORKTREE_CONFIG := $(CATALYST_ROOT_DIR)/.catalyst-worktree
CATALYST_WORKTREE_CHECKOUT := $(shell cat "$(CATALYST_WORKTREE_CONFIG)" 2>/dev/null)
# Compare only the dependencies whose builds are shared between checkouts.
dependency-version = $(strip $(shell sed -n 's/^$(1)=//p' "$(2)/.dep-versions" 2>/dev/null))
define check-worktree-dependency-versions
$(foreach dependency,llvm stablehlo enzyme,\
$(if $(filter 1,$(words $(call dependency-version,$(dependency),$(CATALYST_ROOT_DIR)))),,\
$(error Missing or invalid $(dependency) version in $(CATALYST_ROOT_DIR)/.dep-versions))\
$(if $(filter 1,$(words $(call dependency-version,$(dependency),$(1)))),,\
$(error Missing or invalid $(dependency) version in $(1)/.dep-versions))\
$(if $(filter $(call dependency-version,$(dependency),$(CATALYST_ROOT_DIR)),$(call dependency-version,$(dependency),$(1))),,\
$(error Incompatible shared $(dependency): worktree requires $(call dependency-version,$(dependency),$(CATALYST_ROOT_DIR)), but $(1)/.dep-versions specifies $(call dependency-version,$(dependency),$(1)); use a checkout with matching dependency versions)))
endef
ifneq ($(strip $(CATALYST_WORKTREE_CHECKOUT)),)
export LLVM_SRC_DIR = $(CATALYST_WORKTREE_CHECKOUT)/mlir/llvm-project
export LLVM_BUILD_DIR = $(LLVM_SRC_DIR)/build
export STABLEHLO_SRC_DIR = $(CATALYST_WORKTREE_CHECKOUT)/mlir/stablehlo
export STABLEHLO_BUILD_DIR = $(STABLEHLO_SRC_DIR)/build
export ENZYME_SRC_DIR = $(CATALYST_WORKTREE_CHECKOUT)/mlir/Enzyme
export ENZYME_BUILD_DIR = $(ENZYME_SRC_DIR)/build
export MLIR_LIB_DIR ?= $(LLVM_BUILD_DIR)/lib
export ENZYME_LIB_DIR ?= $(ENZYME_BUILD_DIR)/Enzyme
ifneq ($(filter llvm stablehlo enzyme clean-llvm clean-stablehlo clean-enzyme reset-llvm pack-llvm-dev,$(MAKECMDGOALS)),)
$(error Dependencies are shared from $(CATALYST_WORKTREE_CHECKOUT); run dependency targets in that checkout)
endif
# Cleanup and setup must remain available when shared builds have disappeared.
ifneq ($(filter-out worktree help clean% format%,$(MAKECMDGOALS)),)
$(call check-worktree-dependency-versions,$(CATALYST_WORKTREE_CHECKOUT))
ifeq ($(wildcard $(LLVM_BUILD_DIR)/lib/cmake/mlir/MLIRConfig.cmake),)
$(error Shared LLVM/MLIR build is missing in $(LLVM_BUILD_DIR); run make clean-worktree and make worktree with a compatible built checkout)
endif
ifeq ($(wildcard $(STABLEHLO_BUILD_DIR)/lib/libStablehloOps.a),)
$(error Shared StableHLO build is missing in $(STABLEHLO_BUILD_DIR); run make clean-worktree and make worktree with a compatible built checkout)
endif
ifeq ($(wildcard $(ENZYME_BUILD_DIR)/Enzyme/libEnzymeStatic-*.a),)
$(error Shared Enzyme build is missing in $(ENZYME_BUILD_DIR); run make clean-worktree and make worktree with a compatible built checkout)
endif
endif
endif