@@ -792,50 +792,49 @@ def _collect_clang_module_inputs(
792
792
)
793
793
794
794
def _clang_modulemap_dependency_args (module ):
795
- """Returns `swiftc` arguments for the module map of a Clang module.
795
+ """Returns a `swiftc` argument for the module map of a Clang module.
796
796
797
797
Args:
798
798
module: A struct containing information about the module, as defined by
799
799
`swift_common.create_module`.
800
800
801
801
Returns:
802
- A list of arguments to pass to `swiftc`.
802
+ The argument to pass to `swiftc` (without the `-Xcc` prefix) .
803
803
"""
804
804
module_map = module .clang .module_map
805
805
if types .is_string (module_map ):
806
806
module_map_path = module_map
807
807
else :
808
808
module_map_path = module_map .path
809
809
810
- return [
811
- "-Xcc" ,
812
- "-fmodule-map-file={}" .format (module_map_path ),
813
- ]
810
+ return "-fmodule-map-file={}" .format (module_map_path )
814
811
815
812
def _clang_module_dependency_args (module ):
816
813
"""Returns `swiftc` arguments for a precompiled Clang module, if possible.
817
814
818
- If no precompiled module was emitted for this module, then this function
819
- falls back to the textual module map.
815
+ If a precompiled module is present for this module, then flags for both it
816
+ and the module map are returned (the latter is required in order to map
817
+ headers to mdules in some scenarios, since the precompiled modules are
818
+ passed by name). If no precompiled module is present for this module, then
819
+ this function falls back to the textual module map alone.
820
820
821
821
Args:
822
822
module: A struct containing information about the module, as defined by
823
823
`swift_common.create_module`.
824
824
825
825
Returns:
826
- A list of arguments to pass to `swiftc`.
826
+ A list of arguments to pass to `swiftc` (without the `-Xcc` prefix) .
827
827
"""
828
828
args = []
829
829
if module .clang .precompiled_module :
830
- args .extend ([
831
- "-Xcc" ,
830
+ args .append (
832
831
"-fmodule-file={}={}" .format (
833
832
module .name ,
834
833
module .clang .precompiled_module .path ,
835
834
),
836
- ] )
835
+ )
837
836
if module .clang .module_map :
838
- args .extend (_clang_modulemap_dependency_args (module ))
837
+ args .append (_clang_modulemap_dependency_args (module ))
839
838
return args
840
839
841
840
def _dependencies_clang_modulemaps_configurator (prerequisites , args ):
@@ -846,7 +845,15 @@ def _dependencies_clang_modulemaps_configurator(prerequisites, args):
846
845
if module .clang
847
846
]
848
847
849
- args .add_all (modules , map_each = _clang_modulemap_dependency_args )
848
+ # Uniquify the arguments because different modules might be defined in the
849
+ # same module map file, so it only needs to be present once on the command
850
+ # line.
851
+ args .add_all (
852
+ modules ,
853
+ before_each = "-Xcc" ,
854
+ map_each = _clang_modulemap_dependency_args ,
855
+ uniquify = True ,
856
+ )
850
857
851
858
return _collect_clang_module_inputs (
852
859
cc_info = prerequisites .cc_info ,
@@ -864,7 +871,15 @@ def _dependencies_clang_modules_configurator(prerequisites, args):
864
871
if module .clang
865
872
]
866
873
867
- args .add_all (modules , map_each = _clang_module_dependency_args )
874
+ # Uniquify the arguments because different modules might be defined in the
875
+ # same module map file, so it only needs to be present once on the command
876
+ # line.
877
+ args .add_all (
878
+ modules ,
879
+ before_each = "-Xcc" ,
880
+ map_each = _clang_module_dependency_args ,
881
+ uniquify = True ,
882
+ )
868
883
869
884
return _collect_clang_module_inputs (
870
885
cc_info = prerequisites .cc_info ,
0 commit comments