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

Commit

Permalink
Get rid of spurious diagnostics when compiling system modules with Xc…
Browse files Browse the repository at this point in the history
…ode 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
  • Loading branch information
allevato authored and swiple-rules-gardener committed May 26, 2021
1 parent 214f725 commit c497e6e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions swift/internal/compiling.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,19 @@ def compile_action_configs(
swift_toolchain_config.action_config(
actions = [swift_action_names.PRECOMPILE_C_MODULE],
configurators = [
# `-Xclang -emit-module` ought to be unnecessary if `-emit-pcm`
# is present because ClangImporter configures the invocation to
# use the `GenerateModule` action. However, it does so *after*
# creating the invocation by parsing the command line via a
# helper shared by `-emit-pcm` and other operations, so the
# changing of the action to `GenerateModule` occurs too late;
# the argument parser doesn't know that this will be the
# intended action and it emits a spurious diagnostic:
# "'-fsystem-module' only allowed with '-emit-module'". So, for
# system modules we'll pass `-emit-module` as well; it gets rid
# of the diagnostic and doesn't appear to cause other issues.
swift_toolchain_config.add_arg("-Xcc", "-Xclang"),
swift_toolchain_config.add_arg("-Xcc", "-emit-module"),
swift_toolchain_config.add_arg("-Xcc", "-Xclang"),
swift_toolchain_config.add_arg("-Xcc", "-fsystem-module"),
],
Expand Down

0 comments on commit c497e6e

Please sign in to comment.