Skip to content

Commit 33646d5

Browse files
authored
Refine swift build flags
1 parent 0cd3ff8 commit 33646d5

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

proposals/0403-swiftpm-mixed-language-targets.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,40 @@ the target’s C language sources. This is specified in the llbuild manifest
243243
(`debug.yaml` in the packag's `.build` directory).
244244

245245
##### Additional Swift build flags
246-
The following flags are used when compiling the **Swift** part of the target:
246+
The following flags are additionally used when compiling the Swift sub-target:
247247
1. `-import-underlying-module` This flag triggers a partial build of the
248248
underlying C language sources when building the Swift module. This critical
249249
flag enables the Swift sources to use C language types defined in the Clang
250250
part of the target.
251251
1. `-I /path/to/modulemap_dir` The above `-import-underlying-module` flag
252-
will look for a module map in the given header search path. This may be
253-
either the public headers directory or the build directory, depending on
254-
whether a custom module map is provided.
255-
1. `-I $(target’s path)` Adding the target's [path] allows for importing
256-
headers using paths relative to the root of the target. Because passing
257-
`-import-underlying-module` triggers a partial build of the C language
252+
will look for a module map in the given header search path. The module
253+
map used here cannot modularize the generated interop header as will be
254+
created from building the Swift sub-target and therefore does not exist
255+
yet. If a custom module map is provided, the public headers directory
256+
will be used as that is where the custom module map is enforced to be
257+
located. It's also enforced that this module map does not expose an
258+
interop header. If a custom module map is _not_ provided, the package
259+
manager will pass the target's build directory as that is where a module
260+
map will be synthesized. This module map will be _un-extended_, in that
261+
it does not modularize the generated interop header.
262+
1. _If a custom module is NOT provided,_ the package manager will synthesize
263+
two module maps. One is _extended_ in that it modualrizes the generated
264+
interop header. The other is _un-extended_ in that it does not modularize
265+
the generated interop header. A VFS Overlay file is created to swap the
266+
extended one (named `module.modulemap`) for the unextended one
267+
(`unextended-module.modulemap`) for the build.
268+
1. `-Xcc -I -Xcc $(TARGET_SRC_PATH)` Adding the target's [path] allows for
269+
importing headers using paths relative to the root of the target. Because
270+
passing `-import-underlying-module` triggers a partial build of the Clang
258271
sources, this is needed for resolving possible header imports.
272+
1. `-Xcc -I -Xcc $(TARGET_PUBLIC_HDRS)` Adding the target's public header's
273+
path allows for importing headers using paths relative to the public
274+
header's directory. Because passing `-import-underlying-module` triggers
275+
a partial build of the Clang sources, this is needed for resolving
276+
possible header imports.
259277

260278
##### Additional Clang build flags
261-
The following flags are used when compiling the **Clang** part of the target:
279+
The following flags are additionally used when compiling the Clang sub-target:
262280
1. `-I $(target’s path)` Adding the target's [path] allows for importing
263281
headers using paths relative to the root of the target.
264282
1. `-I /path/to/generated_swift_header/` The generated Swift header may be

0 commit comments

Comments
 (0)