Skip to content

[build-script] Add sanitizer support to indexstore-db product #30963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1728,20 +1728,36 @@ sourcekit-lsp
# Test IndexStore-DB
#===------------------------------------------------------------------------===#

[preset: buildbot_indexstoredb_macos]
[preset: buildbot_indexstoredb_macos,no_sanitize]
mixin-preset=mixin_swiftpm_package_macos_platform
release
assertions
indexstore-db
sourcekit-lsp

[preset: buildbot_indexstoredb_linux]
[preset: buildbot_indexstoredb_linux,no_sanitize]
mixin-preset=mixin_swiftpm_package_linux_platform
release
assertions
indexstore-db
sourcekit-lsp

[preset: buildbot_indexstoredb_macos,sanitize]
mixin-preset=buildbot_indexstoredb_macos,no_sanitize
test-indexstore-db-sanitize-all

[preset: buildbot_indexstoredb_linux,sanitize]
mixin-preset=buildbot_indexstoredb_linux,no_sanitize
test-indexstore-db-sanitize-all

# Default: sanitize-all
[preset: buildbot_indexstoredb_macos]
mixin-preset=buildbot_indexstoredb_macos,sanitize

# Default: sanitize-all
[preset: buildbot_indexstoredb_linux]
mixin-preset=buildbot_indexstoredb_linux,sanitize

#===------------------------------------------------------------------------===#
# Test Swift Corelibs XCTest
#===------------------------------------------------------------------------===#
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ def create_argument_parser():

option(['--indexstore-db'], toggle_true('build_indexstoredb'),
help='build IndexStoreDB')
option('--test-indexstore-db-sanitize-all',
toggle_true('test_indexstoredb_sanitize_all'),
help='run indexstore-db tests under all sanitizers')
option(['--sourcekit-lsp'], toggle_true('build_sourcekitlsp'),
help='build SourceKitLSP')
option('--install-swiftsyntax', toggle_true('install_swiftsyntax'),
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'build_skstresstester': False,
'build_swiftevolve': False,
'build_indexstoredb': False,
'test_indexstoredb_sanitize_all': False,
'build_sourcekitlsp': False,
'install_swiftpm': False,
'install_swiftsyntax': False,
Expand Down Expand Up @@ -503,6 +504,8 @@ class BuildScriptImplOption(_BaseOption):
EnableOption('--libdispatch', dest='build_libdispatch'),
EnableOption('--libicu', dest='build_libicu'),
EnableOption('--indexstore-db', dest='build_indexstoredb'),
EnableOption('--test-indexstore-db-sanitize-all',
dest='test_indexstoredb_sanitize_all'),
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
EnableOption('--install-swiftsyntax', dest='install_swiftsyntax'),
EnableOption('--swiftsyntax-verify-generated-files',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def should_test(self, host_target):
return self.args.test_indexstoredb

def test(self, host_target):
run_build_script_helper('test', host_target, self, self.args)
run_build_script_helper('test', host_target, self, self.args,
self.args.test_indexstoredb_sanitize_all)

def should_install(self, host_target):
return False
Expand All @@ -45,13 +46,13 @@ def install(self, host_target):
pass


def run_build_script_helper(action, host_target, product, args):
def run_build_script_helper(action, host_target, product, args,
sanitize_all=False):
script_path = os.path.join(
product.source_dir, 'Utilities', 'build-script-helper.py')

toolchain_path = targets.toolchain_path(args.install_destdir,
args.install_prefix)

is_release = product.is_release()
configuration = 'release' if is_release else 'debug'
helper_cmd = [
Expand All @@ -66,4 +67,13 @@ def run_build_script_helper(action, host_target, product, args):
if args.verbose_build:
helper_cmd.append('--verbose')

if sanitize_all:
helper_cmd.append('--sanitize-all')
elif args.enable_asan:
helper_cmd.extend(['--sanitize', 'address'])
elif args.enable_ubsan:
helper_cmd.extend(['--sanitize', 'undefined'])
elif args.enable_tsan:
helper_cmd.extend(['--sanitize', 'thread'])

shell.call(helper_cmd)