Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit c497e6e

Browse files
allevatoswiple-rules-gardener
authored andcommitted
Get rid of spurious diagnostics when compiling system modules with Xcode 12.5:
``` <unknown>:0: error: invalid argument '-fsystem-module' only allowed with '-emit-module' ``` This happens because ClangImporter changes the invocation's action to `GenerateModule` *after* the invocation is created by parsing the `-Xcc` flags from the Swift command line, and Clang's argument parser emits a diagnostic if `-fsystem-module` is used with any other action. PiperOrigin-RevId: 375942286
1 parent 214f725 commit c497e6e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

swift/internal/compiling.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,19 @@ def compile_action_configs(
472472
swift_toolchain_config.action_config(
473473
actions = [swift_action_names.PRECOMPILE_C_MODULE],
474474
configurators = [
475+
# `-Xclang -emit-module` ought to be unnecessary if `-emit-pcm`
476+
# is present because ClangImporter configures the invocation to
477+
# use the `GenerateModule` action. However, it does so *after*
478+
# creating the invocation by parsing the command line via a
479+
# helper shared by `-emit-pcm` and other operations, so the
480+
# changing of the action to `GenerateModule` occurs too late;
481+
# the argument parser doesn't know that this will be the
482+
# intended action and it emits a spurious diagnostic:
483+
# "'-fsystem-module' only allowed with '-emit-module'". So, for
484+
# system modules we'll pass `-emit-module` as well; it gets rid
485+
# of the diagnostic and doesn't appear to cause other issues.
486+
swift_toolchain_config.add_arg("-Xcc", "-Xclang"),
487+
swift_toolchain_config.add_arg("-Xcc", "-emit-module"),
475488
swift_toolchain_config.add_arg("-Xcc", "-Xclang"),
476489
swift_toolchain_config.add_arg("-Xcc", "-fsystem-module"),
477490
],

0 commit comments

Comments
 (0)