|
| 1 | +diff --git a/build/config/clang/clang.gni b/build/config/clang/clang.gni |
| 2 | +index 1e662184872b3..4aed699d271b4 100644 |
| 3 | +--- a/build/config/clang/clang.gni |
| 4 | ++++ b/build/config/clang/clang.gni |
| 5 | +@@ -15,4 +15,7 @@ declare_args() { |
| 6 | + default_toolchain != "//build/toolchain/cros:target" |
| 7 | + |
| 8 | + clang_base_path = default_clang_base_path |
| 9 | ++ |
| 10 | ++ # Specifies whether or not bitcode should be embedded in all compiled targets |
| 11 | ++ clang_embed_bitcode = false |
| 12 | + } |
| 13 | +diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn |
| 14 | +index 0272bf80f31fe..87ace0ffd345b 100644 |
| 15 | +--- a/build/config/compiler/BUILD.gn |
| 16 | ++++ b/build/config/compiler/BUILD.gn |
| 17 | +@@ -527,7 +527,7 @@ config("compiler") { |
| 18 | + ldflags += [ "-Wl,-z,keep-text-section-prefix" ] |
| 19 | + } |
| 20 | + |
| 21 | +- if (is_clang && !is_nacl && current_os != "zos") { |
| 22 | ++ if (is_clang && !is_nacl && current_os != "zos" && !clang_embed_bitcode) { |
| 23 | + cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ] |
| 24 | + |
| 25 | + # TODO(hans): Remove this once Clang generates better optimized debug info |
| 26 | +@@ -817,6 +817,9 @@ config("compiler") { |
| 27 | + if (is_official_build) { |
| 28 | + rustflags += [ "-Ccodegen-units=1" ] |
| 29 | + } |
| 30 | ++ if (is_clang && clang_embed_bitcode) { |
| 31 | ++ cflags += [ "-Xclang", "-fembed-bitcode=all" ] |
| 32 | ++ } |
| 33 | + } |
| 34 | + |
| 35 | + # The BUILDCONFIG file sets this config on targets by default, which means when |
| 36 | +@@ -1964,7 +1967,8 @@ if (is_win) { |
| 37 | + "-Wl,-no_function_starts", |
| 38 | + ] |
| 39 | + } |
| 40 | +- } else if (current_os != "aix" && current_os != "zos") { |
| 41 | ++ } else if (current_os != "aix" && current_os != "zos" && |
| 42 | ++ !clang_embed_bitcode) { |
| 43 | + # Non-Mac Posix flags. |
| 44 | + # Aix does not support these. |
| 45 | + |
| 46 | +@@ -2322,7 +2326,7 @@ config("symbols") { |
| 47 | + cflags += [ "-g2" ] |
| 48 | + } |
| 49 | + |
| 50 | +- if (!is_nacl && is_clang && !is_tsan && !is_asan) { |
| 51 | ++ if (!is_nacl && is_clang && !is_tsan && !is_asan && !clang_embed_bitcode) { |
| 52 | + # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has |
| 53 | + # to be manually enabled. |
| 54 | + # |
| 55 | +@@ -2364,7 +2368,7 @@ config("symbols") { |
| 56 | + !(is_android && !use_debug_fission && current_cpu != "x64" && |
| 57 | + current_cpu != "arm64") |
| 58 | + if (_enable_gdb_index) { |
| 59 | +- if (is_clang) { |
| 60 | ++ if (is_clang && !clang_embed_bitcode) { |
| 61 | + # This flag enables the GNU-format pubnames and pubtypes sections, |
| 62 | + # which lld needs in order to generate a correct GDB index. |
| 63 | + # TODO(pcc): Try to make lld understand non-GNU-format pubnames |
| 64 | +@@ -2446,7 +2450,7 @@ config("minimal_symbols") { |
| 65 | + cflags += [ "-g1" ] |
| 66 | + } |
| 67 | + |
| 68 | +- if (!is_nacl && is_clang && !is_tsan && !is_asan) { |
| 69 | ++ if (!is_nacl && is_clang && !is_tsan && !is_asan && !clang_embed_bitcode) { |
| 70 | + # See comment for -gdwarf-aranges in config("symbols"). |
| 71 | + cflags += [ "-gdwarf-aranges" ] |
| 72 | + } |
| 73 | +diff --git a/third_party/dav1d/BUILD.gn b/third_party/dav1d/BUILD.gn |
| 74 | +index bb14440154ec2..71687164a7bbc 100644 |
| 75 | +--- a/third_party/dav1d/BUILD.gn |
| 76 | ++++ b/third_party/dav1d/BUILD.gn |
| 77 | +@@ -4,6 +4,7 @@ |
| 78 | + |
| 79 | + import("dav1d_generated.gni") |
| 80 | + |
| 81 | ++import("//build/config/clang/clang.gni") |
| 82 | + import("//build/config/compiler/compiler.gni") |
| 83 | + import("//build/config/sanitizers/sanitizers.gni") |
| 84 | + import("//third_party/nasm/nasm_assemble.gni") |
| 85 | +@@ -28,7 +29,7 @@ if (is_win) { |
| 86 | + # the stack alignment, so we must use the platform's default alignment in those |
| 87 | + # cases; https://crbug.com/928743. |
| 88 | + if (current_cpu == "x86" || current_cpu == "x64") { |
| 89 | +- if (use_thin_lto || is_win) { |
| 90 | ++ if (use_thin_lto || is_win || clang_embed_bitcode) { |
| 91 | + needs_stack_alignment = false |
| 92 | + # The defaults are stack_alignment=4 for x86 and stack_alignment=16 for x64. |
| 93 | + } else { |
0 commit comments