Skip to content

Commit 214e517

Browse files
gottesmmDougGregor
authored andcommitted
[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. (cherry picked from commit 6f4ef7c)
1 parent fe15893 commit 214e517

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
@@ -152,6 +152,7 @@ def common_options(self, product=None):
152152
define("CMAKE_CXX_COMPILER:PATH", toolchain.cxx)
153153
define("CMAKE_Swift_COMPILER:PATH", toolchain.swiftc)
154154
define("CMAKE_LIBTOOL:PATH", toolchain.libtool)
155+
define("CMAKE_AR:PATH", toolchain.ar)
155156

156157
if args.cmake_generator == 'Xcode':
157158
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
@@ -49,6 +49,7 @@ def default_args(self):
4949
host_cxx="/path/to/clang++",
5050
host_swiftc="/path/to/swiftc",
5151
host_libtool="/path/to/libtool",
52+
host_ar="/path/to/ar",
5253
enable_asan=False,
5354
enable_ubsan=False,
5455
enable_tsan=False,
@@ -83,6 +84,7 @@ def cmake(self, args):
8384
toolchain.cxx = args.host_cxx
8485
toolchain.swiftc = args.host_swiftc
8586
toolchain.libtool = args.host_libtool
87+
toolchain.ar = args.host_ar
8688
if args.distcc:
8789
toolchain.distcc = self.mock_distcc_path()
8890
if args.sccache:
@@ -100,6 +102,7 @@ def test_common_options_defaults(self):
100102
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
101103
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
102104
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
105+
"-DCMAKE_AR:PATH=/path/to/ar",
103106
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
104107

105108
def test_common_options_asan(self):
@@ -114,6 +117,7 @@ def test_common_options_asan(self):
114117
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
115118
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
116119
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
120+
"-DCMAKE_AR:PATH=/path/to/ar",
117121
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
118122

119123
def test_common_options_ubsan(self):
@@ -128,6 +132,7 @@ def test_common_options_ubsan(self):
128132
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
129133
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
130134
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
135+
"-DCMAKE_AR:PATH=/path/to/ar",
131136
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
132137

133138
def test_common_options_tsan(self):
@@ -142,6 +147,7 @@ def test_common_options_tsan(self):
142147
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
143148
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
144149
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
150+
"-DCMAKE_AR:PATH=/path/to/ar",
145151
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
146152

147153
def test_common_options_asan_ubsan(self):
@@ -157,6 +163,7 @@ def test_common_options_asan_ubsan(self):
157163
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
158164
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
159165
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
166+
"-DCMAKE_AR:PATH=/path/to/ar",
160167
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
161168

162169
def test_common_options_ubsan_tsan(self):
@@ -172,6 +179,7 @@ def test_common_options_ubsan_tsan(self):
172179
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
173180
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
174181
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
182+
"-DCMAKE_AR:PATH=/path/to/ar",
175183
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
176184

177185
def test_common_options_asan_ubsan_tsan(self):
@@ -188,6 +196,7 @@ def test_common_options_asan_ubsan_tsan(self):
188196
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
189197
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
190198
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
199+
"-DCMAKE_AR:PATH=/path/to/ar",
191200
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
192201

193202
def test_common_options_lsan(self):
@@ -202,6 +211,7 @@ def test_common_options_lsan(self):
202211
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
203212
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
204213
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
214+
"-DCMAKE_AR:PATH=/path/to/ar",
205215
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
206216

207217
def test_common_options_coverage_sanitizer(self):
@@ -216,6 +226,7 @@ def test_common_options_coverage_sanitizer(self):
216226
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
217227
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
218228
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
229+
"-DCMAKE_AR:PATH=/path/to/ar",
219230
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
220231

221232
def test_common_options_export_compile_commands(self):
@@ -230,6 +241,7 @@ def test_common_options_export_compile_commands(self):
230241
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
231242
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
232243
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
244+
"-DCMAKE_AR:PATH=/path/to/ar",
233245
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
234246

235247
def test_common_options_distcc(self):
@@ -245,6 +257,7 @@ def test_common_options_distcc(self):
245257
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
246258
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
247259
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
260+
"-DCMAKE_AR:PATH=/path/to/ar",
248261
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
249262

250263
def test_common_options_sccache(self):
@@ -260,6 +273,7 @@ def test_common_options_sccache(self):
260273
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
261274
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
262275
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
276+
"-DCMAKE_AR:PATH=/path/to/ar",
263277
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
264278

265279
def test_common_options_launcher(self):
@@ -278,6 +292,7 @@ def test_common_options_launcher(self):
278292
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
279293
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
280294
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
295+
"-DCMAKE_AR:PATH=/path/to/ar",
281296
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
282297

283298
def test_common_options_xcode(self):
@@ -291,6 +306,7 @@ def test_common_options_xcode(self):
291306
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
292307
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
293308
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
309+
"-DCMAKE_AR:PATH=/path/to/ar",
294310
"-DCMAKE_CONFIGURATION_TYPES=" +
295311
"Debug;Release;MinSizeRel;RelWithDebInfo"])
296312

@@ -305,6 +321,7 @@ def test_common_options_clang_compiler_version(self):
305321
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
306322
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
307323
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
324+
"-DCMAKE_AR:PATH=/path/to/ar",
308325
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
309326

310327
def test_common_options_clang_user_visible_version(self):
@@ -318,6 +335,7 @@ def test_common_options_clang_user_visible_version(self):
318335
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
319336
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
320337
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
338+
"-DCMAKE_AR:PATH=/path/to/ar",
321339
"-DLLVM_VERSION_MAJOR:STRING=9",
322340
"-DLLVM_VERSION_MINOR:STRING=0",
323341
"-DLLVM_VERSION_PATCH:STRING=0",
@@ -337,6 +355,7 @@ def test_common_options_build_ninja(self):
337355
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
338356
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
339357
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
358+
"-DCMAKE_AR:PATH=/path/to/ar",
340359
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
341360

342361
def test_common_options_full(self):
@@ -361,6 +380,7 @@ def test_common_options_full(self):
361380
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
362381
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
363382
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
383+
"-DCMAKE_AR:PATH=/path/to/ar",
364384
"-DCMAKE_CONFIGURATION_TYPES=" +
365385
"Debug;Release;MinSizeRel;RelWithDebInfo",
366386
"-DLLVM_VERSION_MAJOR:STRING=9",

0 commit comments

Comments
 (0)