Skip to content

Commit 6f4ef7c

Browse files
committed
[build-script] Begin tracking ar in build-script toolchains and start passing -DCMAKE_AR to cmake.
I am currently working on being able to build cmake build-script projects as always being cross compiled by using toolchain files (1). CMake expects in means that I need to be able to specify CMAKE_AR in said toolchain. (1) We still build for the host machine (of course), but instead of building it normally with cmake, we build it as if we are cross compiling meaning we are cross compiling for the host on the host. This makes it so that the host build is no longer different from cross compilation builds making Swift's cross compilation build more robust since it will be tested and less mysterious.
1 parent 6b1b9ba commit 6f4ef7c

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

utils/swift_build_support/swift_build_support/cmake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def common_options(self):
138138
define("CMAKE_C_COMPILER:PATH", toolchain.cc)
139139
define("CMAKE_CXX_COMPILER:PATH", toolchain.cxx)
140140
define("CMAKE_LIBTOOL:PATH", toolchain.libtool)
141+
define("CMAKE_AR:PATH", toolchain.ar)
141142

142143
if args.cmake_generator == 'Xcode':
143144
define("CMAKE_CONFIGURATION_TYPES",

utils/swift_build_support/swift_build_support/toolchain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _getter(self):
6262
_register("llvm_cov", "llvm-cov")
6363
_register("lipo", "lipo")
6464
_register("libtool", "libtool")
65+
_register("ar", "ar")
6566
_register("sccache", "sccache")
6667
_register("swiftc", "swiftc")
6768

utils/swift_build_support/tests/test_cmake.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def default_args(self):
4848
return Namespace(host_cc="/path/to/clang",
4949
host_cxx="/path/to/clang++",
5050
host_libtool="/path/to/libtool",
51+
host_ar="/path/to/ar",
5152
enable_asan=False,
5253
enable_ubsan=False,
5354
enable_tsan=False,
@@ -81,6 +82,7 @@ def cmake(self, args):
8182
toolchain.cc = args.host_cc
8283
toolchain.cxx = args.host_cxx
8384
toolchain.libtool = args.host_libtool
85+
toolchain.ar = args.host_ar
8486
if args.distcc:
8587
toolchain.distcc = self.mock_distcc_path()
8688
if args.sccache:
@@ -97,6 +99,7 @@ def test_common_options_defaults(self):
9799
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
98100
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
99101
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
102+
"-DCMAKE_AR:PATH=/path/to/ar",
100103
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
101104

102105
def test_common_options_asan(self):
@@ -110,6 +113,7 @@ def test_common_options_asan(self):
110113
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
111114
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
112115
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
116+
"-DCMAKE_AR:PATH=/path/to/ar",
113117
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
114118

115119
def test_common_options_ubsan(self):
@@ -123,6 +127,7 @@ def test_common_options_ubsan(self):
123127
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
124128
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
125129
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
130+
"-DCMAKE_AR:PATH=/path/to/ar",
126131
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
127132

128133
def test_common_options_tsan(self):
@@ -136,6 +141,7 @@ def test_common_options_tsan(self):
136141
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
137142
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
138143
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
144+
"-DCMAKE_AR:PATH=/path/to/ar",
139145
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
140146

141147
def test_common_options_asan_ubsan(self):
@@ -150,6 +156,7 @@ def test_common_options_asan_ubsan(self):
150156
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
151157
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
152158
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
159+
"-DCMAKE_AR:PATH=/path/to/ar",
153160
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
154161

155162
def test_common_options_ubsan_tsan(self):
@@ -164,6 +171,7 @@ def test_common_options_ubsan_tsan(self):
164171
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
165172
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
166173
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
174+
"-DCMAKE_AR:PATH=/path/to/ar",
167175
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
168176

169177
def test_common_options_asan_ubsan_tsan(self):
@@ -179,6 +187,7 @@ def test_common_options_asan_ubsan_tsan(self):
179187
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
180188
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
181189
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
190+
"-DCMAKE_AR:PATH=/path/to/ar",
182191
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
183192

184193
def test_common_options_lsan(self):
@@ -192,6 +201,7 @@ def test_common_options_lsan(self):
192201
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
193202
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
194203
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
204+
"-DCMAKE_AR:PATH=/path/to/ar",
195205
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
196206

197207
def test_common_options_coverage_sanitizer(self):
@@ -205,6 +215,7 @@ def test_common_options_coverage_sanitizer(self):
205215
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
206216
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
207217
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
218+
"-DCMAKE_AR:PATH=/path/to/ar",
208219
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
209220

210221
def test_common_options_export_compile_commands(self):
@@ -218,6 +229,7 @@ def test_common_options_export_compile_commands(self):
218229
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
219230
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
220231
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
232+
"-DCMAKE_AR:PATH=/path/to/ar",
221233
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
222234

223235
def test_common_options_distcc(self):
@@ -232,6 +244,7 @@ def test_common_options_distcc(self):
232244
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
233245
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
234246
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
247+
"-DCMAKE_AR:PATH=/path/to/ar",
235248
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
236249

237250
def test_common_options_sccache(self):
@@ -246,6 +259,7 @@ def test_common_options_sccache(self):
246259
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
247260
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
248261
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
262+
"-DCMAKE_AR:PATH=/path/to/ar",
249263
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
250264

251265
def test_common_options_launcher(self):
@@ -263,6 +277,7 @@ def test_common_options_launcher(self):
263277
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
264278
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
265279
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
280+
"-DCMAKE_AR:PATH=/path/to/ar",
266281
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
267282

268283
def test_common_options_xcode(self):
@@ -275,6 +290,7 @@ def test_common_options_xcode(self):
275290
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
276291
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
277292
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
293+
"-DCMAKE_AR:PATH=/path/to/ar",
278294
"-DCMAKE_CONFIGURATION_TYPES=" +
279295
"Debug;Release;MinSizeRel;RelWithDebInfo"])
280296

@@ -288,6 +304,7 @@ def test_common_options_clang_compiler_version(self):
288304
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
289305
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
290306
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
307+
"-DCMAKE_AR:PATH=/path/to/ar",
291308
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
292309

293310
def test_common_options_clang_user_visible_version(self):
@@ -300,6 +317,7 @@ def test_common_options_clang_user_visible_version(self):
300317
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
301318
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
302319
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
320+
"-DCMAKE_AR:PATH=/path/to/ar",
303321
"-DLLVM_VERSION_MAJOR:STRING=9",
304322
"-DLLVM_VERSION_MINOR:STRING=0",
305323
"-DLLVM_VERSION_PATCH:STRING=0",
@@ -318,6 +336,7 @@ def test_common_options_build_ninja(self):
318336
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
319337
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
320338
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
339+
"-DCMAKE_AR:PATH=/path/to/ar",
321340
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
322341

323342
def test_common_options_full(self):
@@ -341,6 +360,7 @@ def test_common_options_full(self):
341360
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
342361
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
343362
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
363+
"-DCMAKE_AR:PATH=/path/to/ar",
344364
"-DCMAKE_CONFIGURATION_TYPES=" +
345365
"Debug;Release;MinSizeRel;RelWithDebInfo",
346366
"-DLLVM_VERSION_MAJOR:STRING=9",

0 commit comments

Comments
 (0)