Skip to content

Commit 9c4fbae

Browse files
allevatoswiple-rules-gardener
authored andcommitted
Pass -file-compilation-dir . explicitly to the Swift driver so that .swiftmodule files are hermetic.
PiperOrigin-RevId: 788420859
1 parent ed69bef commit 9c4fbae

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

swift/toolchains/config/compile_config.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,19 @@ def compile_action_configs(
445445
#### Flags controlling how Swift/Clang modular inputs are processed
446446

447447
action_configs += [
448+
# When `-g` is passed to the compiler, the driver will pass
449+
# `-file-compilation-dir <CWD>` to the frontend, which in turn passes
450+
# `-ffile-compilation-dir <CWD>` to Clang. This CWD is fully resolved so
451+
# it contains the absolute path to the workspace. If we pass
452+
# `-file-compilation-dir .`, then the driver/frontend preserve that
453+
# spelling, ensuring that the ClangImporter options section of the
454+
# `.swiftmodule` file is hermetic.
455+
ActionConfigInfo(
456+
actions = all_compile_action_names(),
457+
configurators = [
458+
add_arg("-file-compilation-dir", "."),
459+
],
460+
),
448461
# Explicitly set the working directory to ensure that the
449462
# `FILE_SYSTEM_OPTIONS` block of PCM files is hermetic.
450463
#

0 commit comments

Comments
 (0)