diff options
author | Dmitry Shevchenko <dmishe@google.com> | 2016-07-08 17:13:22 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-07-11 09:39:16 +0000 |
commit | 758a73e794756add970a08a16890167296923376 (patch) | |
tree | 03fe0c3fefa25f37446ecbcea0091555239057ee /tools/build_defs/apple | |
parent | e2f9adab37975cc6565f218b26021afa0796e2fd (diff) |
Make swift_library explicitly specify the module maps it is using.
* This seems to fix an issue with Clang loading the same header twice when it's discovering module maps implicitly. Also makes the command line cleaner.
--
MOS_MIGRATED_REVID=126922449
Diffstat (limited to 'tools/build_defs/apple')
-rw-r--r-- | tools/build_defs/apple/swift.bzl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tools/build_defs/apple/swift.bzl b/tools/build_defs/apple/swift.bzl index ce946a44c4..7df084208b 100644 --- a/tools/build_defs/apple/swift.bzl +++ b/tools/build_defs/apple/swift.bzl @@ -60,6 +60,7 @@ def _module_name(ctx): def _swift_library_impl(ctx): """Implementation for swift_library Skylark rule.""" + # TODO(b/29772303): Assert xcode version. cpu = ctx.fragments.apple.ios_cpu() platform = ctx.fragments.apple.ios_cpu_platform() sdk_version = ctx.fragments.apple.sdk_version_for_platform(platform) @@ -83,16 +84,18 @@ def _swift_library_impl(ctx): dep_libs += swift.transitive_libs dep_modules += swift.transitive_modules - objc_includes = set() # Everything that needs to be included with -I - objc_files = set() # All inputs required for the compile action + objc_includes = set() # Everything that needs to be included with -I + objc_files = set() # All inputs required for the compile action + objc_module_maps = set() # Module maps for dependent targets objc_defines = set() for objc in objc_providers: objc_includes += objc.include - objc_includes = objc_includes.union([x.dirname for x in objc.module_map]) objc_files += objc.header objc_files += objc.module_map + objc_module_maps += objc.module_map + files = set(objc.static_framework_file) + set(objc.dynamic_framework_file) objc_files += files framework_dirs += _parent_dirs(objc.framework_dir) @@ -137,13 +140,22 @@ def _swift_library_impl(ctx): clang_args = _intersperse( "-Xcc", + # Add the current directory to clang's search path. - # This instance of clang is spawned by swiftc to compile module maps and is - # not passed the current directory as a search path by default. + # This instance of clang is spawned by swiftc to compile module maps and + # is not passed the current directory as a search path by default. ["-iquote", "."] + # Pass DEFINE or copt values from objc configuration and rules to clang + ["-D" + x for x in objc_defines] + ctx.fragments.objc.copts - + _clang_compilation_mode_flags(ctx)) + + _clang_compilation_mode_flags(ctx) + + # Load module maps explicitly instead of letting Clang discover them on + # search paths. This is needed to avoid a case where Clang may load the + # same header both in modular and non-modular contexts, leading to + # duplicate definitions in the same file. + # https://llvm.org/bugs/show_bug.cgi?id=19501 + + ["-fmodule-map-file=%s" % x.path for x in objc_module_maps]) args = [ "swiftc", |