Use -fdebug-compilation-dir instead of -fdebug-prefix-map

Using -fdebug-prefix-map requires adding an absolute path on the command line.
This is bad for relocatable builds, and couldn't be good for goma caching.

This CL changes usage of -fdebug-prefix-map to -fdebug-compilation-dir, which we
can tell the compilation dir we want to set directly (in our case, ".").

The produced .o and .dwo files are identical in the build configuration that I
tested.

BUG=846610,439949
R=dpranke
CC=tikuta

Change-Id: I8cdbfea14f7330118b9f25ebfa6af5bdf447bf17
Reviewed-on: https://chromium-review.googlesource.com/1103546
Commit-Queue: Thomas Anderson <[email protected]>
Reviewed-by: Dirk Pranke <[email protected]>
Cr-Commit-Position: refs/heads/master@{#569345}
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 2d82ed5..20fd1d6 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -95,7 +95,7 @@
   # default only when goma is enabled on Linux because setting this to true may
   # make it harder to debug binaries.
   # See below reference for detail.
-  # https://chromium.googlesource.com/chromium/src/+/master/docs/linux_debugging.md#Source-level-debug-with-fdebug_prefix_map
+  # https://chromium.googlesource.com/chromium/src/+/master/docs/linux_debugging.md#Source-level-debug-with-fdebug_compilation_dir
   strip_absolute_paths_from_debug_symbols = is_linux && use_goma
 
   # Allow projects that wish to stay on C++11 to override Chromium's default.
@@ -513,16 +513,17 @@
   # TODO(zforman): Once nacl's toolchain is updated, remove check.
   if (symbol_level != 0 && is_clang && !is_nacl && !is_win && !is_mac &&
       !is_ios && strip_absolute_paths_from_debug_symbols) {
-    # This is resolved to path like "$HOME/chromium/src/out/Release".
     # If debug option is given, clang includes $cwd in debug info.
     # In such build, this flag generates reproducible obj files
     # even we use build directory like "out/feature_a" and "out/feature_b" if
     # we build same files with same compile flag other than this.
-    # Other paths are already givne in relative, no need to normalize it by
-    # using -fdebug-prefix-map.
-    absolute_path = rebase_path(root_out_dir)
-
-    cflags += [ "-fdebug-prefix-map=$absolute_path=." ]
+    # Other paths are already givne in relative, no need to normalize them.
+    cflags += [
+      "-Xclang",
+      "-fdebug-compilation-dir",
+      "-Xclang",
+      ".",
+    ]
   }
 
   # Tells the compiler not to use absolute paths when passing the default
diff --git a/docs/linux_debugging.md b/docs/linux_debugging.md
index d2baee6..aff0dd77 100644
--- a/docs/linux_debugging.md
+++ b/docs/linux_debugging.md
@@ -273,7 +273,7 @@
 splitting symbols from the object files. In GN, set `use_debug_fission=false` in
 your "gn args".
 
-### Source level debug with -fdebug-prefix-map
+### Source level debug with -fdebug-compilation-dir
 
 When you enable GN config `strip_absolute_paths_from_debug_symbols`, this is
 enabled by default for goma on Linux build, you need to add following command
diff --git a/tools/gdb/gdbinit b/tools/gdb/gdbinit
index 44b3195..039ced9f3 100644
--- a/tools/gdb/gdbinit
+++ b/tools/gdb/gdbinit
@@ -1,5 +1,5 @@
-# This is gdbinit for source level debugging with -fdebug-prefix-map compile
-# option.
+# This is gdbinit for source level debugging with -fdebug-compilation-dir
+# compile option.
 
 python