|
48 | 48 | "SWIFT_FEATURE_DISABLE_SWIFT_SANDBOX", |
49 | 49 | "SWIFT_FEATURE_DISABLE_SYSTEM_INDEX", |
50 | 50 | "SWIFT_FEATURE_EMIT_BC", |
| 51 | + "SWIFT_FEATURE_EMIT_C_MODULE", |
51 | 52 | "SWIFT_FEATURE_EMIT_PRIVATE_SWIFTINTERFACE", |
52 | 53 | "SWIFT_FEATURE_EMIT_SWIFTDOC", |
53 | 54 | "SWIFT_FEATURE_EMIT_SWIFTINTERFACE", |
|
67 | 68 | "SWIFT_FEATURE_INTERNALIZE_AT_LINK", |
68 | 69 | "SWIFT_FEATURE_LAYERING_CHECK", |
69 | 70 | "SWIFT_FEATURE_MODULAR_INDEXING", |
| 71 | + "SWIFT_FEATURE_MODULE_HOME_IS_CWD", |
70 | 72 | "SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD", |
71 | 73 | "SWIFT_FEATURE_NO_ASAN_VERSION_CHECK", |
72 | 74 | "SWIFT_FEATURE_OPT", |
@@ -646,6 +648,52 @@ def compile_action_configs( |
646 | 648 | ], |
647 | 649 | ), |
648 | 650 |
|
| 651 | + # Explicitly set the working directory to ensure that the |
| 652 | + # `FILE_SYSTEM_OPTIONS` block of PCM files is hermetic. |
| 653 | + # |
| 654 | + # IMPORTANT: When writing a PCM file, Clang *unconditionally* includes |
| 655 | + # the working directory in the `FILE_SYSTEM_OPTIONS` block. Thus, the |
| 656 | + # only way to ensure that these files are hermetic is to pass |
| 657 | + # `-working-directory=.`. We cannot pass this to Swift, however, because |
| 658 | + # the driver unfortunately resolves whatever path is given to it and |
| 659 | + # then passes all of the source files as absolute paths to the |
| 660 | + # frontend, which makes other outputs non-hermetic. Therefore, we *only* |
| 661 | + # pass this flag to Clang. Having the two values not be literally |
| 662 | + # identical should still be safe, because we're only passing a value |
| 663 | + # here that is *effectively* the same as the default. |
| 664 | + ActionConfigInfo( |
| 665 | + actions = all_compile_action_names() + [ |
| 666 | + SWIFT_ACTION_PRECOMPILE_C_MODULE, |
| 667 | + ], |
| 668 | + configurators = [ |
| 669 | + add_arg("-Xcc", "-working-directory"), |
| 670 | + add_arg("-Xcc", "."), |
| 671 | + ], |
| 672 | + features = [[ |
| 673 | + SWIFT_FEATURE_EMIT_C_MODULE, |
| 674 | + SWIFT_FEATURE_USE_C_MODULES, |
| 675 | + SWIFT_FEATURE_MODULE_HOME_IS_CWD, |
| 676 | + ]], |
| 677 | + ), |
| 678 | + # Treat paths embedded into .pcm files as workspace-relative, not |
| 679 | + # modulemap-relative. |
| 680 | + ActionConfigInfo( |
| 681 | + actions = all_compile_action_names() + [ |
| 682 | + SWIFT_ACTION_COMPILE_MODULE_INTERFACE, |
| 683 | + SWIFT_ACTION_PRECOMPILE_C_MODULE, |
| 684 | + SWIFT_ACTION_SYMBOL_GRAPH_EXTRACT, |
| 685 | + ], |
| 686 | + configurators = [ |
| 687 | + add_arg("-Xcc", "-Xclang"), |
| 688 | + add_arg("-Xcc", "-fmodule-file-home-is-cwd"), |
| 689 | + ], |
| 690 | + features = [[ |
| 691 | + SWIFT_FEATURE_EMIT_C_MODULE, |
| 692 | + SWIFT_FEATURE_USE_C_MODULES, |
| 693 | + SWIFT_FEATURE_MODULE_HOME_IS_CWD, |
| 694 | + ]], |
| 695 | + ), |
| 696 | + |
649 | 697 | # Treat paths in .modulemap files as workspace-relative, not modulemap- |
650 | 698 | # relative. |
651 | 699 | ActionConfigInfo( |
@@ -1099,7 +1147,7 @@ def compile_action_configs( |
1099 | 1147 | SWIFT_ACTION_PRECOMPILE_C_MODULE, |
1100 | 1148 | ], |
1101 | 1149 | configurators = [ |
1102 | | - add_arg("-file-prefix-map", "__BAZEL_XCODE_DEVELOPER_DIR__=DEVELOPER_DIR"), |
| 1150 | + add_arg("-file-prefix-map", "__BAZEL_XCODE_DEVELOPER_DIR__=/PLACEHOLDER_DEVELOPER_DIR"), |
1103 | 1151 | ], |
1104 | 1152 | features = [SWIFT_FEATURE_FILE_PREFIX_MAP], |
1105 | 1153 | ), |
|
0 commit comments