forked from ProcursusTeam/Procursus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllvm.mk-swiftstdlib
159 lines (148 loc) · 7.58 KB
/
llvm.mk-swiftstdlib
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Keeping this here just in case I need to compile the swift stdlib sometime.
ifneq ($(PROCURSUS),1)
$(error Use the main Makefile)
endif
#SUBPROJECTS += llvm
LLVM_VERSION := 10.0.9
LLVM_MAJOR_V := 10
DEB_LLVM_V ?= $(LLVM_VERSION)
ifeq ($(MEMO_TARGET),iphoneos-arm64)
LLVM_DEFAULT_TRIPLE := arm64-apple-ios12.0
SWIFT_VARIANT := IOS
SWIFT_OLD := OFF
else ifeq ($(MEMO_TARGET),iphoneos-arm)
LLVM_DEFAULT_TRIPLE := arm-apple-ios8.0
SWIFT_VARIANT := IOS
SWIFT_OLD := ON
else ifeq ($(MEMO_TARGET),appletvos-arm64)
LLVM_DEFAULT_TRIPLE := arm64-apple-tvos10.0
SWIFT_VARIANT := TVOS
SWIFT_OLD := OFF
else ifeq ($(MEMO_TARGET),watchos-arm64)
LLVM_DEFAULT_TRIPLE := arm64-apple-watchos4.0
SWIFT_VARIANT := WATCHOS
SWIFT_OLD := OFF
else ifeq ($(MEMO_TARGET),watchos-arm)
LLVM_DEFAULT_TRIPLE := armv7k-apple-watchos2.0
SWIFT_VARIANT := WATCHOS
SWIFT_OLD := ON
endif
llvm-setup: setup
wget -q -nc -P $(BUILD_SOURCE) https://github.com/apple/llvm-project/archive/swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz
-[ ! -e "$(BUILD_SOURCE)/swift-swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz" ] && wget -O $(BUILD_SOURCE)/swift-swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz https://github.com/apple/swift/archive/swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz
-[ ! -e "$(BUILD_SOURCE)/swift-cmark-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz" ] && wget -O $(BUILD_SOURCE)/swift-cmark-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz https://github.com/apple/cmark/archive/swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz
$(call EXTRACT_TAR,swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz,llvm-project-swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a,llvm)
$(call EXTRACT_TAR,swift-swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz,swift-swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a,llvm/swift)
$(call EXTRACT_TAR,swift-cmark-swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a.tar.gz,swift-cmark-swift-5.3-DEVELOPMENT-SNAPSHOT-2020-06-08-a,llvm/cmark)
$(call DO_PATCH,llvm,llvm,-p1)
$(call DO_PATCH,swift,llvm/swift,-p1)
mkdir -p $(BUILD_WORK)/llvm/build
$(SED) -i 's|isysroot $${CMAKE_OSX_SYSROOT}|isysroot $${CMAKE_FIND_ROOT_PATH}|' $(BUILD_WORK)/llvm/lldb/tools/debugserver/source/CMakeLists.txt
ifneq ($(wildcard $(BUILD_WORK)/llvm/.build_complete),)
llvm:
@echo "Using previously built llvm."
else
llvm: llvm-setup libffi ncurses xz
cp -a $(TARGET_SYSROOT)/usr/include/mach/arm $(BUILD_BASE)/usr/include/mach
cp -a $(MACOSX_SYSROOT)/usr/include/{editline,kern} $(BUILD_BASE)/usr/include
cp -a $(MACOSX_SYSROOT)/usr/include/histedit.h $(BUILD_BASE)/usr/include
mv $(BUILD_BASE)/usr/include/stdlib.h $(BUILD_BASE)/usr/include/stdlib.h.old
cd $(BUILD_WORK)/llvm/build && cmake . -j$(shell $(GET_LOGICAL_CORES)) \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_CROSSCOMPILING=true \
-DCMAKE_INSTALL_NAME_TOOL=$(I_N_T) \
-DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_MAJOR_V) \
-DCMAKE_INSTALL_NAME_DIR=/usr/lib/llvm-$(LLVM_MAJOR_V)/lib \
-DCMAKE_INSTALL_RPATH=/usr/lib/llvm-$(LLVM_MAJOR_V) \
-DCMAKE_OSX_ARCHITECTURES="$(ARCHES)" \
-DCMAKE_OSX_SYSROOT="$(TARGET_SYSROOT)" \
-DCMAKE_FIND_ROOT_PATH="$(BUILD_BASE)" \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
-DCMAKE_C_FLAGS="-isystem $(BUILD_BASE)/usr/include -isystem $(BUILD_BASE)/usr/local/include $(PLATFORM_VERSION_MIN)" \
-DCMAKE_CXX_FLAGS="-isystem $(BUILD_BASE)/usr/include -isystem $(BUILD_BASE)/usr/local/include $(PLATFORM_VERSION_MIN)" \
-DCMAKE_EXE_LINKER_FLAGS="-L$(BUILD_BASE)/usr/lib -L$(BUILD_BASE)/usr/local/lib -F$(BUILD_BASE)/System/Library/Frameworks" \
-DCMAKE_MODULE_LINKER_FLAGS="-L$(BUILD_BASE)/usr/lib -L$(BUILD_BASE)/usr/local/lib -F$(BUILD_BASE)/System/Library/Frameworks" \
-DCMAKE_SHARED_LINKER_FLAGS="-L$(BUILD_BASE)/usr/lib -L$(BUILD_BASE)/usr/local/lib -F$(BUILD_BASE)/System/Library/Frameworks" \
-DCMAKE_STATIC_LINKER_FLAGS="" \
-DLLVM_ENABLE_FFI=ON \
-DCURSES_NCURSES_LIBRARY="$(BUILD_BASE)/usr/lib/libncursesw.dylib" \
-DNCURSES_LDFLAGS:INTERNAL=-lncursesw \
-DLIBXML2_LIBRARY="$(TARGET_SYSROOT)/usr/lib/libxml2.tbd" \
-DLIBXML2_INCLUDE_DIR="$(TARGET_SYSROOT)/usr/include/libxml" \
-DLibEdit_INCLUDE_DIRS="$(BUILD_BASE)/usr/include" \
-DLibEdit_LIBRARIES="$(TARGET_SYSROOT)/usr/lib/libedit.tbd" \
-DCORE_FOUNDATION_LIBRARY="$(TARGET_SYSROOT)/System/Library/Frameworks/CoreFoundation.framework" \
-DCORE_SERVICES_LIBRARY="$(TARGET_SYSROOT)/System/Library/Frameworks/CoreServices.framework" \
-DFOUNDATION_LIBRARY="$(TARGET_SYSROOT)/System/Library/Frameworks/Foundation.framework" \
-DFOUNDATION="$(TARGET_SYSROOT)/System/Library/Frameworks/Foundation.framework" \
-DSECURITY_LIBRARY="$(TARGET_SYSROOT)/System/Library/Frameworks/Security.framework" \
-DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_C_COMPILER=cc;-DCMAKE_CXX_COMPILER=c++;-DCMAKE_OSX_SYSROOT="$(MACOSX_SYSROOT)";-DCMAKE_OSX_ARCHITECTURES="";-DCMAKE_C_FLAGS="";-DCMAKE_CXX_FLAGS="";-DCMAKE_EXE_LINKER_FLAGS=""' \
-DCLANG_VERSION=$(LLVM_VERSION) \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DCLANG_LINK_CLANG_DYLIB=ON \
-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON \
-DLLVM_VERSION_SUFFIX="" \
-DLLVM_DEFAULT_TARGET_TRIPLE=$(LLVM_DEFAULT_TRIPLE) \
-DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
-DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;lldb;cmark;swift" \
-DLLVM_EXTERNAL_PROJECTS="cmark;swift" \
-DLLVM_EXTERNAL_SWIFT_SOURCE_DIR="$(BUILD_WORK)/llvm/swift" \
-DLLVM_EXTERNAL_CMARK_SOURCE_DIR="$(BUILD_WORK)/llvm/cmark" \
-DLLVM_INCLUDE_TESTS=OFF \
-DMIG_ARCHS=$(ARCHES) \
-DCFLAGS_SDK="$(SWIFT_VARIANT)" \
-DCFLAGS_DEPLOYMENT_VERSION_IOS=12.0 \
-DCFLAGS_DEPLOYMENT_VERSION_TVOS=10.0 \
-DCFLAGS_DEPLOYMENT_VERSION_WATCHOS=4.0 \
-DSWIFT_PRIMARY_VARIANT_SDK="$(SWIFT_VARIANT)" \
-DSWIFT_PRIMARY_VARIANT_ARCH="$(ARCHES)" \
-DSWIFT_HOST_VARIANT_SDK="$(SWIFT_VARIANT)" \
-DSWIFT_HOST_VARIANT="$(PLATFORM)" \
-DSWIFT_HOST_VARIANT_ARCH="$(ARCHES)" \
-DSWIFT_ENABLE_IOS32="$(SWIFT_OLD)" \
-DSWIFT_INCLUDE_TESTS=OFF \
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=ON \
-DSWIFT_NATIVE_SWIFT_TOOLS_PATH="$(BUILD_WORK)/llvm/build/NATIVE/bin" \
../llvm
mkdir -p $(BUILD_WORK)/llvm/build/NATIVE && cd $(BUILD_WORK)/llvm/build/NATIVE && cmake . -j$(shell $(GET_LOGICAL_CORES)) \
-DCMAKE_C_COMPILER=cc \
-DCMAKE_CXX_COMPILER=c++ \
-DCMAKE_OSX_SYSROOT="$(MACOSX_SYSROOT)" \
-DCMAKE_C_FLAGS="" \
-DCMAKE_CXX_FLAGS="" \
-DCMAKE_CXX_FLAGS="" \
-DCMAKE_EXE_LINKER_FLAGS="" \
-DSWIFT_INCLUDE_TESTS=OFF \
-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=ON \
-DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
-DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;lldb;cmark;swift" \
-DLLVM_EXTERNAL_PROJECTS="cmark;swift" \
-DLLVM_EXTERNAL_SWIFT_SOURCE_DIR="$(BUILD_WORK)/llvm/swift" \
-DLLVM_EXTERNAL_CMARK_SOURCE_DIR="$(BUILD_WORK)/llvm/cmark" \
../../llvm
+$(MAKE) -C $(BUILD_WORK)/llvm/build/NATIVE swift
+$(MAKE) -C $(BUILD_WORK)/llvm/build install \
DESTDIR="$(BUILD_STAGE)/llvm"
+$(MAKE) -C $(BUILD_WORK)/llvm/build install \
DESTDIR="$(BUILD_BASE)"
mv $(BUILD_BASE)/usr/include/stdlib.h.old $(BUILD_BASE)/usr/include/stdlib.h
touch $(BUILD_WORK)/llvm/.build_complete
endif
llvm-package: llvm-stage
# llvm.mk Package Structure
rm -rf $(BUILD_DIST)/llvm
mkdir -p $(BUILD_DIST)/llvm
# llvm.mk Prep llvm
cp -a $(BUILD_STAGE)/llvm/usr $(BUILD_DIST)/llvm
# llvm.mk Sign
$(call SIGN,llvm,general.xml)
# llvm.mk Make .debs
$(call PACK,llvm,DEB_LLVM_V)
# llvm.mk Build cleanup
rm -rf $(BUILD_DIST)/llvm
.PHONY: llvm llvm-package