Skip to content

Commit 43bb415

Browse files
authored
Merge pull request #30963 from benlangmuir/isdb-san
[build-script] Add sanitizer support to indexstore-db product
2 parents f9610de + 65fe324 commit 43bb415

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

utils/build-presets.ini

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,20 +1728,36 @@ sourcekit-lsp
17281728
# Test IndexStore-DB
17291729
#===------------------------------------------------------------------------===#
17301730

1731-
[preset: buildbot_indexstoredb_macos]
1731+
[preset: buildbot_indexstoredb_macos,no_sanitize]
17321732
mixin-preset=mixin_swiftpm_package_macos_platform
17331733
release
17341734
assertions
17351735
indexstore-db
17361736
sourcekit-lsp
17371737

1738-
[preset: buildbot_indexstoredb_linux]
1738+
[preset: buildbot_indexstoredb_linux,no_sanitize]
17391739
mixin-preset=mixin_swiftpm_package_linux_platform
17401740
release
17411741
assertions
17421742
indexstore-db
17431743
sourcekit-lsp
17441744

1745+
[preset: buildbot_indexstoredb_macos,sanitize]
1746+
mixin-preset=buildbot_indexstoredb_macos,no_sanitize
1747+
test-indexstore-db-sanitize-all
1748+
1749+
[preset: buildbot_indexstoredb_linux,sanitize]
1750+
mixin-preset=buildbot_indexstoredb_linux,no_sanitize
1751+
test-indexstore-db-sanitize-all
1752+
1753+
# Default: sanitize-all
1754+
[preset: buildbot_indexstoredb_macos]
1755+
mixin-preset=buildbot_indexstoredb_macos,sanitize
1756+
1757+
# Default: sanitize-all
1758+
[preset: buildbot_indexstoredb_linux]
1759+
mixin-preset=buildbot_indexstoredb_linux,sanitize
1760+
17451761
#===------------------------------------------------------------------------===#
17461762
# Test Swift Corelibs XCTest
17471763
#===------------------------------------------------------------------------===#

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ def create_argument_parser():
567567

568568
option(['--indexstore-db'], toggle_true('build_indexstoredb'),
569569
help='build IndexStoreDB')
570+
option('--test-indexstore-db-sanitize-all',
571+
toggle_true('test_indexstoredb_sanitize_all'),
572+
help='run indexstore-db tests under all sanitizers')
570573
option(['--sourcekit-lsp'], toggle_true('build_sourcekitlsp'),
571574
help='build SourceKitLSP')
572575
option('--install-swiftsyntax', toggle_true('install_swiftsyntax'),

utils/build_swift/tests/expected_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
'build_skstresstester': False,
9292
'build_swiftevolve': False,
9393
'build_indexstoredb': False,
94+
'test_indexstoredb_sanitize_all': False,
9495
'build_sourcekitlsp': False,
9596
'install_swiftpm': False,
9697
'install_swiftsyntax': False,
@@ -503,6 +504,8 @@ class BuildScriptImplOption(_BaseOption):
503504
EnableOption('--libdispatch', dest='build_libdispatch'),
504505
EnableOption('--libicu', dest='build_libicu'),
505506
EnableOption('--indexstore-db', dest='build_indexstoredb'),
507+
EnableOption('--test-indexstore-db-sanitize-all',
508+
dest='test_indexstoredb_sanitize_all'),
506509
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
507510
EnableOption('--install-swiftsyntax', dest='install_swiftsyntax'),
508511
EnableOption('--swiftsyntax-verify-generated-files',

utils/swift_build_support/swift_build_support/products/indexstoredb.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def should_test(self, host_target):
3636
return self.args.test_indexstoredb
3737

3838
def test(self, host_target):
39-
run_build_script_helper('test', host_target, self, self.args)
39+
run_build_script_helper('test', host_target, self, self.args,
40+
self.args.test_indexstoredb_sanitize_all)
4041

4142
def should_install(self, host_target):
4243
return False
@@ -45,13 +46,13 @@ def install(self, host_target):
4546
pass
4647

4748

48-
def run_build_script_helper(action, host_target, product, args):
49+
def run_build_script_helper(action, host_target, product, args,
50+
sanitize_all=False):
4951
script_path = os.path.join(
5052
product.source_dir, 'Utilities', 'build-script-helper.py')
5153

5254
toolchain_path = targets.toolchain_path(args.install_destdir,
5355
args.install_prefix)
54-
5556
is_release = product.is_release()
5657
configuration = 'release' if is_release else 'debug'
5758
helper_cmd = [
@@ -66,4 +67,13 @@ def run_build_script_helper(action, host_target, product, args):
6667
if args.verbose_build:
6768
helper_cmd.append('--verbose')
6869

70+
if sanitize_all:
71+
helper_cmd.append('--sanitize-all')
72+
elif args.enable_asan:
73+
helper_cmd.extend(['--sanitize', 'address'])
74+
elif args.enable_ubsan:
75+
helper_cmd.extend(['--sanitize', 'undefined'])
76+
elif args.enable_tsan:
77+
helper_cmd.extend(['--sanitize', 'thread'])
78+
6979
shell.call(helper_cmd)

0 commit comments

Comments
 (0)