Skip to content

Commit e1387a4

Browse files
committed
feat: replacing CoreCompiler with LLVM.xcframework 2.0 xD
1 parent 4b05c51 commit e1387a4

61 files changed

Lines changed: 25 additions & 5409 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ llvm-project/
2020
libffi/
2121
tools/
2222
LLVM**.xcframework/
23-
Clang**.xcframework/
24-
CoreCompiler.framework/CoreCompiler
2523
LLVM-iphoneos/
26-
CoreCompiler.framework/Headers/*
2724
swift*
2825
brotli
2926
CoreCompilerSupportLibs
@@ -39,3 +36,5 @@ sourcekit-lsp
3936
wasi-libc
4037
wasmkit
4138
zlib
39+
llvm.a
40+
Headers/

CoreCompiler.framework/Info.plist

Lines changed: 0 additions & 24 deletions
This file was deleted.

CoreCompiler.framework/Modules/module.modulemap

Lines changed: 0 additions & 5 deletions
This file was deleted.

Makefile

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ define log_info
1515
endef
1616

1717
# Main Target
18-
all: CoreCompiler.framework/CoreCompiler
18+
all: LLVM.xcframework
1919

2020
# Fetch & Build Swift and LLVM for iOS
2121
swift:
@@ -52,33 +52,37 @@ SWIFT_STATIC_LIBS = $(wildcard $(SWIFT_TOOLCHAIN_ROOT)/lib/libswift*.a) \
5252
$(wildcard $(ROOT)/build/LLVMClangSwift_iphoneos/cmark-iphoneos-arm64/src/libcmark-gfm.a) \
5353
$(wildcard $(ROOT)/build/LLVMClangSwift_iphoneos/cmark-iphoneos-arm64/extensions/libcmark-gfm-extensions.a)
5454
SWIFT_HOST_COMPILER_DYLIBS = $(wildcard $(SWIFT_TOOLCHAIN_ROOT)/lib/swift/host/compiler/lib_Compiler*.dylib)
55-
SWIFT_LINK_PATHS = -L$(SWIFT_TOOLCHAIN_ROOT)/lib \
56-
-L$(SWIFT_TOOLCHAIN_ROOT)/lib/swift/iphoneos \
57-
-L$(SWIFT_TOOLCHAIN_ROOT)/lib/swift/iphoneos/$(APPLE_ARCH) \
58-
-L$(SWIFT_TOOLCHAIN_ROOT)/lib/swift/host/compiler
59-
INC = -ISource -ISwiftToolchain-iphoneos/include -Illvm-project/lld/include -Illvm-project/clang/include -Illvm-project/llvm/include -Ibuild/LLVMClangSwift_iphoneos/llvm-iphoneos-arm64/tools/clang/include -Iswift/include -Iswift/stdlib/public/SwiftShims
6055

61-
CoreCompiler.framework/CoreCompiler: swift-toolchain
62-
$(call log_info,building CoreCompiler framework)
56+
LLVM.xcframework: swift-toolchain
57+
LLVM.xcframework:
58+
$(call log_info,bundling CoreCompilerSupportLibs)
6359
-rm -rf CoreCompilerSupportLibs
64-
-rm *.o
65-
clang -c -target $(TARGET_TRIPLE) -isysroot $(SDK) $(INC) Source/CoreCompiler/*.c
66-
clang -c -fobjc-arc -ObjC -target $(TARGET_TRIPLE) -isysroot $(SDK) $(INC) Source/CoreCompiler/*.m
67-
clang++ -c -Wno-elaborated-enum-base -std=c++17 -target $(TARGET_TRIPLE) -isysroot $(SDK) $(INC) Source/CoreCompiler/*.cpp
68-
clang++ -fobjc-arc -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections -fdata-sections -Wl,-dead_strip -flto=full -Os -fno-exceptions -Wl,-x -Wl,-S -Wl,-dead_strip_dylibs -ObjC -target $(TARGET_TRIPLE) -isysroot $(SDK) $(SWIFT_LINK_PATHS) *.o $(SWIFT_STATIC_LIBS) $(SWIFT_HOST_COMPILER_DYLIBS) -framework CoreFoundation -lz -lxml2 -lswiftCore -o CoreCompiler.framework/CoreCompiler -shared -fPIC -install_name @rpath/CoreCompiler.framework/CoreCompiler
69-
-rm *.o
70-
-rm -rf CoreCompiler.framework/Headers
71-
mkdir -p CoreCompiler.framework/Headers
72-
cp Source/CoreCompiler/*.h CoreCompiler.framework/Headers/
7360
mkdir CoreCompilerSupportLibs
7461
cp $(SWIFT_HOST_COMPILER_DYLIBS) CoreCompilerSupportLibs/
62+
$(call log_info,bundling LLVM xcframework headers)
63+
-rm -rf Headers
64+
mkdir Headers
65+
cp -r SwiftToolchain-iphoneos/include/* Headers/
66+
cp -r llvm-project/lld/include/* Headers/
67+
cp -r llvm-project/clang/include/* Headers/
68+
cp -r llvm-project/llvm/include/* Headers/
69+
cp -r build/LLVMClangSwift_iphoneos/llvm-iphoneos-arm64/tools/clang/include/* Headers/
70+
rm -rf Headers/swift/Bridging
71+
cp -r swift/include/* Headers/
72+
cp -r swift/stdlib/public/SwiftShims/* Headers/
73+
$(call log_info,create llvm.a)
74+
-rm -rf llvm.a
75+
libtool -static -o llvm.a $(SWIFT_STATIC_LIBS)
76+
$(call log_info,bundling LLVM xcframework)
77+
-rm -rf LLVM.xcframework
78+
xcodebuild -create-xcframework -library "./llvm.a" -headers "Headers" -output LLVM.xcframework
7579

7680
# Cleanup
7781
clean-artifacts:
7882
-rm *.o
7983
-rm -rf CoreCompilerSupportLibs
80-
-rm CoreCompiler.framework/CoreCompiler
81-
-rm CoreCompiler.framework/Headers/*
84+
-rm -rf LLVM.xcframework
85+
-rm -rf Headers
8286

8387
clean: clean-artifacts
8488
$(call log_info,cleaning up)
@@ -89,7 +93,5 @@ clean: clean-artifacts
8993
! -name .git \
9094
! -name .gitignore \
9195
! -name .github \
92-
! -name CoreCompiler.framework \
93-
! -name Source \
9496
! -name Scripts \
9597
-exec rm -rf {} +

0 commit comments

Comments
 (0)