File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,26 @@ $(call set-feature, EXT_F)
116116ifeq ($(call has, EXT_F) , 1)
117117AR := ar
118118ifeq ("$(CC_IS_CLANG ) ", "1")
119- AR = llvm-ar
119+ # On macOS, system ar works with Apple Clang's LTO
120+ ifeq ($(UNAME_S),Darwin)
121+ # macOS: system ar is sufficient
122+ else
123+ # Non-macOS with Clang: check if LTO is enabled
124+ ifeq ($(call has, LTO), 1)
125+ # LTO requires llvm-ar to handle LLVM bitcode in object files
126+ LLVM_AR := $(shell which llvm-ar 2>/dev/null)
127+ ifeq ($(LLVM_AR),)
128+ $(error llvm-ar not found. Install LLVM or disable LTO with ENABLE_LTO=0)
129+ endif
130+ AR = llvm-ar
131+ else
132+ # LTO disabled: prefer llvm-ar if available, otherwise use system ar
133+ LLVM_AR := $(shell which llvm-ar 2>/dev/null)
134+ ifneq ($(LLVM_AR),)
135+ AR = llvm-ar
136+ endif
137+ endif
138+ endif
120139endif
121140ifeq ("$(CC_IS_EMCC ) ", "1")
122141AR = emar
You can’t perform that action at this time.
0 commit comments