Automated rollback of commit d6b7a8dbcd307ae93be9f4e7b5e90d32febdd4d5.
*** Reason for rollback ***
Keeping -fdebug-prefix-map until we have a better understanding of
DBGVersion 2 issues.
PiperOrigin-RevId: 186337767
diff --git a/src/TulsiGenerator/BazelBuildSettingsFeatures.swift b/src/TulsiGenerator/BazelBuildSettingsFeatures.swift
index 53f2438..32834b4 100644
--- a/src/TulsiGenerator/BazelBuildSettingsFeatures.swift
+++ b/src/TulsiGenerator/BazelBuildSettingsFeatures.swift
@@ -13,6 +13,6 @@
// limitations under the License.
let bazelBuildSettingsFeatures = [
- // Export dSYMs to allow us to establish source maps that can handle multiple potential paths.
- "TULSI_ALL_DSYM",
+ // For non-distributed builds.
+ "TULSI_DEBUG_PREFIX_MAP",
]
diff --git a/src/TulsiGenerator/Scripts/bazel_build.py b/src/TulsiGenerator/Scripts/bazel_build.py
index 38b1cf2..4c6e2b3 100755
--- a/src/TulsiGenerator/Scripts/bazel_build.py
+++ b/src/TulsiGenerator/Scripts/bazel_build.py
@@ -188,7 +188,7 @@
# The build configurations handled by this parser.
KNOWN_CONFIGS = ['Debug', 'Release', 'Fastbuild']
- def __init__(self, sdk_version, platform_name, arch):
+ def __init__(self, sdk_version, platform_name, arch, main_group_path):
self.targets = []
self.startup_options = collections.defaultdict(list)
self.build_options = collections.defaultdict(
@@ -213,6 +213,18 @@
],
})
+ # Options specific to debugger integration in Xcode.
+ xcode_version_major = int(os.environ['XCODE_VERSION_MAJOR'])
+ if xcode_version_major < 800:
+ xcode_lldb_options = [
+ '--copt=-Xclang', '--copt=-fdebug-compilation-dir',
+ '--copt=-Xclang', '--copt=%s' % main_group_path,
+ '--objccopt=-Xclang', '--objccopt=-fdebug-compilation-dir',
+ '--objccopt=-Xclang', '--objccopt=%s' % main_group_path,
+ ]
+ self.build_options['Debug'].extend(xcode_lldb_options)
+ self.build_options['Release'].extend(xcode_lldb_options)
+
self.sdk_version = sdk_version
self.platform_name = platform_name
@@ -497,6 +509,8 @@
self.generate_dsym = (os.environ.get('TULSI_ALL_DSYM', 'NO') == 'YES' or
os.environ.get('TULSI_MUST_USE_DSYM', 'NO') == 'YES')
+ self.use_debug_prefix_map = os.environ.get('TULSI_DEBUG_PREFIX_MAP',
+ 'NO') == 'YES'
self.extra_remap_path = os.environ.get('TULSI_EXTRA_REMAP_PATH', '')
self.remap_dotted_paths = os.environ.get('TULSI_REMAP_DOTTED_PATHS',
'NO') == 'YES'
@@ -541,11 +555,6 @@
self.xcode_version_major = int(os.environ['XCODE_VERSION_MAJOR'])
self.xcode_version_minor = int(os.environ['XCODE_VERSION_MINOR'])
- # Warn if the user is on an unsupported version of Xcode.
- if self.xcode_version_major < 800:
- _PrintXcodeWarning('Tulsi debugging is no longer supported for Xcode 7.')
- _PrintXcodeWarning('Use Tulsi 0.4.185727384.20180214 for Xcode < 8.')
-
# Path where Xcode expects the artifacts to be written to. This is not the
# codesigning_path as device vs simulator builds have different signing
# requirements, so Xcode expects different paths to be signed. This is
@@ -602,7 +611,8 @@
parser = _OptionsParser(self.sdk_version,
self.platform_name,
- self.arch)
+ self.arch,
+ self.main_group_path)
timer = Timer('Parsing options', 'parsing_options').Start()
message, exit_code = parser.ParseOptions(args[1:])
timer.End()
@@ -614,6 +624,27 @@
self.bazel_bin_path = os.path.abspath(parser.bazel_bin_path)
self.bazel_executable = parser.bazel_executable
+ # Use -fdebug-prefix-map to have debug symbols match Xcode-visible sources.
+ #
+ # NOTE: Use of -fdebug-prefix-map leads to producing binaries that cannot be
+ # reused across multiple machines by a distributed build system, unless the
+ # absolute paths to files visible to Xcode match perfectly between all of
+ # those machines.
+ #
+ # For this reason, -fdebug-prefix-map is provided as a default for non-
+ # distributed purposes.
+ if self.use_debug_prefix_map:
+ # Add the debug source maps now that we have bazel_executable.
+ source_maps = self._ExtractTargetSourceMaps()
+
+ prefix_maps = []
+ for source_map in source_maps:
+ prefix_maps.append('--copt=-fdebug-prefix-map=%s=%s' %
+ source_map)
+
+ # Extend our list of build options with maps just prior to building.
+ parser.build_options[_OptionsParser.ALL_CONFIGS].extend(prefix_maps)
+
self.build_path = os.path.join(self.bazel_bin_path,
os.environ.get('TULSI_BUILD_PATH', ''))
@@ -710,7 +741,7 @@
# correction applies to debug prefix maps as well.
if self.xcode_version_major >= 800:
timer = Timer('Updating .lldbinit', 'updating_lldbinit').Start()
- clear_source_map = self.generate_dsym
+ clear_source_map = self.generate_dsym or self.use_debug_prefix_map
exit_code = self._UpdateLLDBInit(clear_source_map)
timer.End()
if exit_code: