Skip to content

Make it possible to configure Swift test options with CMake #34407

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 1 commit into from
Oct 27, 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
2 changes: 1 addition & 1 deletion test/Frontend/embed-bitcode-tvos.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; REQUIRES: CODEGENERATOR=AArch64
; RUN: llvm-as %s -o %t.bc
; RUN: %swift -target arm64-apple-tvos9 -c -module-name someModule -embed-bitcode -disable-llvm-optzns -o %t2.o %t.bc -dump-clang-diagnostics 2> %t.diags.txt
; RUN: %swiftc_driver_plain -frontend -target arm64-apple-tvos9 -c -module-name someModule -embed-bitcode -disable-llvm-optzns -o %t2.o %t.bc -dump-clang-diagnostics 2> %t.diags.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%target-swift-frontend can replace %swiftc_driver_plain -frontend here. We'll take the last -target on the command line anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I went with %swiftc_driver_plain is because that avoids the addition of swift_driver_test_options or swift_frontend_test_options. We are using these configs to specify import paths required for cross compiling, and if the paths get passed to this test it will fail with something like:

swift/test/Frontend/embed-bitcode-tvos.ll:16:23: error: CHECK-IMPORTER-NOT: excluded string found in input
; CHECK-IMPORTER-NOT: argument unused
                      ^
<stdin>:2:10: note: found here
warning: argument unused during compilation: '-isystem /some/sysroot'
         ^~~~~~~~~~~~~~~

This matches the behavior of the embed-bitcode.ll test.

; RUN: llvm-objdump --macho --private-headers %t2.o | %FileCheck %s
; RUN: %FileCheck -check-prefix CHECK-IMPORTER %s < %t.diags.txt

Expand Down
20 changes: 11 additions & 9 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ if test_options:
config.swift_test_options += ' '
config.swift_test_options += test_options

config.swift_frontend_test_options = os.environ.get('SWIFT_FRONTEND_TEST_OPTIONS', '')
config.swift_frontend_test_options += os.environ.get('SWIFT_FRONTEND_TEST_OPTIONS', '')
config.swift_frontend_test_options += ' -ignore-module-source-info'
config.swift_driver_test_options = os.environ.get('SWIFT_DRIVER_TEST_OPTIONS', '')
config.swift_driver_test_options += os.environ.get('SWIFT_DRIVER_TEST_OPTIONS', '')
config.swift_driver_test_options += ' -Xfrontend'
config.swift_driver_test_options += ' -ignore-module-source-info'
config.sil_test_options = os.environ.get('SIL_TEST_OPTIONS', '')
Expand Down Expand Up @@ -1062,8 +1062,8 @@ if run_vendor == 'apple':
target_options_for_mock_sdk_after
config.target_swiftc_driver = (
("%s %s -toolchain-stdlib-rpath %s " +
"-Xlinker -rpath -Xlinker /usr/lib/swift ")%
(xcrun_prefix, config.swiftc, target_options))
"-Xlinker -rpath -Xlinker /usr/lib/swift %s ")%
(xcrun_prefix, config.swiftc, target_options, config.swift_driver_test_options))
config.target_clang = (
"%s clang++ %s" %
(xcrun_prefix, config.target_cc_options))
Expand Down Expand Up @@ -1146,8 +1146,9 @@ elif run_os in ['windows-msvc']:
subst_target_swift_ide_test_mock_sdk_after = ''

config.target_swiftc_driver = \
('%r -target %s %s %s' % (config.swiftc, config.variant_triple, \
resource_dir_opt, mcp_opt))
('%r -target %s %s %s %s' % (config.swiftc, config.variant_triple, \
resource_dir_opt, mcp_opt, \
config.swift_driver_test_options))
config.target_swift_modulewrap = \
('%r -modulewrap -target %s' % (config.swiftc, config.variant_triple))
config.target_swift_emit_pcm = \
Expand Down Expand Up @@ -1254,8 +1255,8 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
subst_target_swift_ide_test_mock_sdk = config.target_swift_ide_test
subst_target_swift_ide_test_mock_sdk_after = ""
config.target_swiftc_driver = (
"%s -target %s -toolchain-stdlib-rpath %s %s" %
(config.swiftc, config.variant_triple, resource_dir_opt, mcp_opt))
"%s -target %s -toolchain-stdlib-rpath %s %s %s" %
(config.swiftc, config.variant_triple, resource_dir_opt, mcp_opt, config.swift_driver_test_options))
config.target_swift_modulewrap = (
'%s -modulewrap -target %s' %
(config.swiftc, config.variant_triple))
Expand Down Expand Up @@ -1384,7 +1385,8 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
'-Xclang-linker', '--sysroot={}'.format(config.variant_sdk),
'-tools-directory', tools_directory,
android_link_paths_opt, resource_dir_opt, mcp_opt,
'-use-ld=%s' % config.android_linker_name])
'-use-ld=%s' % config.android_linker_name,
config.swift_driver_test_options])
config.target_swift_modulewrap = ' '.join([
config.swiftc, '-modulewrap',
'-target', config.variant_triple])
Expand Down
2 changes: 2 additions & 0 deletions test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ config.swift_test_results_dir = \
config.coverage_mode = "@SWIFT_ANALYZE_CODE_COVERAGE@"
config.lldb_build_root = "@LLDB_BUILD_DIR@"
config.libdispatch_build_path = "@SWIFT_PATH_TO_LIBDISPATCH_BUILD@"
config.swift_driver_test_options = "@SWIFT_DRIVER_TEST_OPTIONS@"
config.swift_frontend_test_options = "@SWIFT_FRONTEND_TEST_OPTIONS@"

# --- Darwin ---
config.darwin_xcrun_toolchain = "@SWIFT_DARWIN_XCRUN_TOOLCHAIN@"
Expand Down
3 changes: 3 additions & 0 deletions validation-test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ config.variant_sdk = "@VARIANT_SDK@"
config.swift_test_results_dir = \
lit_config.params.get("swift_test_results_dir", "@SWIFT_TEST_RESULTS_DIR@")

config.swift_driver_test_options = "@SWIFT_DRIVER_TEST_OPTIONS@"
config.swift_frontend_test_options = "@SWIFT_FRONTEND_TEST_OPTIONS@"

# --- Darwin Configuration ---
config.darwin_xcrun_toolchain = "@SWIFT_DARWIN_XCRUN_TOOLCHAIN@"

Expand Down