{"id":817,"date":"2018-06-13T10:06:07","date_gmt":"2018-06-13T08:06:07","guid":{"rendered":"http:\/\/blogs.igalia.com\/jaragunde\/?p=817"},"modified":"2022-10-03T16:13:00","modified_gmt":"2022-10-03T14:13:00","slug":"chromium-official-release-builds-and-icecc","status":"publish","type":"post","link":"https:\/\/blogs.igalia.com\/jaragunde\/2018\/06\/chromium-official-release-builds-and-icecc\/","title":{"rendered":"Chromium official\/release builds and icecc"},"content":{"rendered":"<p>You may already be using icecc to compile your Chromium, either by following some instructions like the ones <a href=\"https:\/\/blogs.igalia.com\/gyuyoung\/2018\/01\/11\/share-my-experience-to-build-chromium-with-icecc\/\">published by my colleague Gyuyoung<\/a> or using the popular <a href=\"https:\/\/github.com\/lilles\/icecc-chromium\">icecc-chromium<\/a> set of scripts. In those cases, you will probably get in some trouble if you try to generate an official build with that configuration.<\/p>\n<p><a href=\"http:\/\/blogs.igalia.com\/jaragunde\/files\/2018\/06\/French-car-meter-2017042308.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blogs.igalia.com\/jaragunde\/files\/2018\/06\/French-car-meter-2017042308.png\" alt=\"\" width=\"298\" height=\"300\" class=\"aligncenter size-full wp-image-828\" srcset=\"https:\/\/blogs.igalia.com\/jaragunde\/files\/2018\/06\/French-car-meter-2017042308.png 298w, https:\/\/blogs.igalia.com\/jaragunde\/files\/2018\/06\/French-car-meter-2017042308-150x150.png 150w\" sizes=\"auto, (max-width: 298px) 100vw, 298px\" \/><\/a><\/p>\n<p>First, let me refresh what an &#8220;official build&#8221; is called in Chromium. You may know that build optimization in Chromium builds depends on two flags:<\/p>\n<ul>\n<li><strong>is_debug<\/strong><br \/>\nDebug build. Enabling official builds automatically sets is_debug to false.<\/p>\n<\/li>\n<li>\n<p><strong>is_official_build<\/strong><br \/>\nSet to enable the official build level of optimization. This has nothing<br \/>\nto do with branding, but enables an additional level of optimization above<br \/>\nrelease (!is_debug). This might be better expressed as a tri-state<br \/>\n(debug, release, official) but for historical reasons there are two<br \/>\nseparate flags.<\/p>\n<\/li>\n<\/ul>\n<p>The GN documentation is pretty verbose about this. To sum up, to get full binary optimization you should enable <code>is_official_build<\/code> which will also disable <code>is_debug<\/code> in the background. This is what other projects would call a release build.<\/p>\n<p>Back to the main topic, I was running an official build distributed via icecc and stumbled on some compilation problems:<\/p>\n<pre><code>clang: error: no such file or directory: \/usr\/lib\/clang\/7.0.0\/share\/cfi_blacklist.txt\nclang: error: no such file or directory: ..\/..\/tools\/cfi\/blacklist.txt\nclang: error: no such file or directory: \/path\/to\/src\/chrome\/android\/profiles\/afdo.prof\n<\/code><\/pre>\n<p>These didn&#8217;t happen when icecc build was disabled, so I was certain to have found some limitations in the distributed compiler. The icecc-chromium set of scripts was already disabling a number of clang cleanup\/sanitize tools, so I decided to take the same approach. First, I checked the GN args that could be related to these errors and identified two:<\/p>\n<ul>\n<li><strong>is_cfi<\/strong><br \/>\nCurrent value (from the default) = true<br \/>\n  From \/\/build\/config\/sanitizers\/sanitizers.gni:53<\/p>\n<p>Compile with Control Flow Integrity to protect virtual calls and casts.<br \/>\nSee http:\/\/clang.llvm.org\/docs\/ControlFlowIntegrity.html<\/p>\n<p>TODO(pcc): Remove this flag if\/when CFI is enabled in all official builds.<\/p>\n<\/li>\n<li>\n<p><strong>clang_use_default_sample_profile<\/strong><br \/>\nCurrent value (from the default) = true<br \/>\n  From \/\/build\/config\/compiler\/BUILD.gn:117<\/p>\n<p>Some configurations have default sample profiles. If this is true and<br \/>\nclang_sample_profile_path is empty, we&#8217;ll fall back to the default.<\/p>\n<p>We currently only have default profiles for Chromium in-tree, so we disable<br \/>\nthis by default for all downstream projects, since these profiles are likely<br \/>\nnonsensical for said projects.<\/p>\n<\/li>\n<\/ul>\n<p>These two args were enabled, I just disabled them and got rid the compilation flags that were causing trouble: <code>-fprofile-sample-use=\/path\/to\/src\/chrome\/android\/profiles\/afdo.prof -fsanitize=cfi-vcall -fsanitize-blacklist=..\/..\/tools\/cfi\/blacklist.txt<\/code>. I&#8217;ve learned that support for <code>-fsanitize-blacklist<\/code> is <a href=\"https:\/\/github.com\/icecc\/icecream\/commit\/a2f0d7507c2fb87096c74582d05cdfc05c6e3e40\">available<\/a> in upstream icecc, but most distros don&#8217;t package it yet, so it&#8217;s safer to disable that.<\/p>\n<p>To sum up, if you are using icecc and you want to run an official build, you have to add a couple more GN args:<\/p>\n<pre><code>clang_use_default_sample_profile = false\nis_cfi = false\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You may already be using icecc to compile your Chromium, either by following some instructions like the ones published by my colleague Gyuyoung or using the popular icecc-chromium set of scripts. In those cases, you will probably get in some &hellip; <a href=\"https:\/\/blogs.igalia.com\/jaragunde\/2018\/06\/chromium-official-release-builds-and-icecc\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,24,3],"tags":[],"class_list":["post-817","post","type-post","status-publish","format-standard","hentry","category-browsers","category-chromium","category-igalia"],"_links":{"self":[{"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/posts\/817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/comments?post=817"}],"version-history":[{"count":11,"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/posts\/817\/revisions"}],"predecessor-version":[{"id":1126,"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/posts\/817\/revisions\/1126"}],"wp:attachment":[{"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/media?parent=817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/categories?post=817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.igalia.com\/jaragunde\/wp-json\/wp\/v2\/tags?post=817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}