|
3 | 3 | # found in the LICENSE file.
|
4 | 4 |
|
5 | 5 | import("//build/config/profiler.gni")
|
| 6 | +import("//build/toolchain/rbe.gni") |
6 | 7 |
|
7 | 8 | # This config causes functions not to be automatically exported from shared
|
8 | 9 | # libraries. By default, all symbols are exported but this means there are
|
@@ -49,3 +50,46 @@ config("no_exceptions") {
|
49 | 50 | cflags_cc = no_exceptions_flags
|
50 | 51 | cflags_objcc = no_exceptions_flags
|
51 | 52 | }
|
| 53 | + |
| 54 | +config("relative_paths") { |
| 55 | + # Make builds independent of absolute file path. The file names |
| 56 | + # embedded in debugging information will be expressed as relative to |
| 57 | + # the build directory, e.g. "../.." for an "out/subdir" under //. |
| 58 | + # This is consistent with the file names in __FILE__ expansions |
| 59 | + # (e.g. in assertion messages), which the compiler doesn't provide a |
| 60 | + # way to remap. That way source file names in logging and |
| 61 | + # symbolization can all be treated the same way. This won't go well |
| 62 | + # if root_build_dir is not a subdirectory //, but there isn't a better |
| 63 | + # option to keep all source file name references uniformly relative to |
| 64 | + # a single root. |
| 65 | + cflags = [] |
| 66 | + cflags_objcc = [] |
| 67 | + absolute_path = rebase_path("//") |
| 68 | + relative_path = "" |
| 69 | + if (use_rbe) { |
| 70 | + # objc builds are always local even when rbe is enabled. |
| 71 | + cflags_objcc += [ |
| 72 | + # This makes sure that the DW_AT_comp_dir string (the current |
| 73 | + # directory while running the compiler, which is the basis for all |
| 74 | + # relative source file names in the DWARF info) is represented as |
| 75 | + # relative to //. |
| 76 | + "-fdebug-prefix-map=$absolute_path=$relative_path", |
| 77 | + ] |
| 78 | + } else { |
| 79 | + cflags += [ |
| 80 | + "-fdebug-prefix-map=$absolute_path=$relative_path", |
| 81 | + ] |
| 82 | + } |
| 83 | + cflags += [ |
| 84 | + # This makes sure that include directories in the toolchain are |
| 85 | + # represented as relative to the build directory (because that's how |
| 86 | + # we invoke the compiler), rather than absolute. This can affect |
| 87 | + # __FILE__ expansions (e.g. assertions in system headers). We |
| 88 | + # normally run a compiler that's someplace within the source tree |
| 89 | + # (//buildtools/...), so its absolute installation path will have a |
| 90 | + # prefix matching absolute_path and hence be mapped to relative_path |
| 91 | + # in the debugging information, so this should actually be |
| 92 | + # superfluous for purposes of the debugging information. |
| 93 | + "-no-canonical-prefixes", |
| 94 | + ] |
| 95 | +} |
0 commit comments