Skip to content

uftrace for chromium

Honggyu Kim edited this page Aug 10, 2019 · 21 revisions

1. Download depot_tools

Chromium uses a package of scripts called depot_tools to manage checkouts and code reviews.
The depot_tools package includes gclient, gcl, git-cl, repo, and others. Chromium uses a package of scripts called depot_tools to manage checkouts and code reviews.

# download depot_tools
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

# environment setup for depot_tools
$ export PATH=`pwd`/depot_tools:$PATH

2. Download chromium

First, create a directory chromium.

$ mkdir chromium && cd chromium

Then, create a .gclient file as follows:

$ cat .gclient
solutions = [
  {
    "url": "https://chromium.googlesource.com/chromium/src.git",
    "managed": False,
    "name": "src",
    "custom_deps": {},
  },
]

Do (shallow) git clone for chromium source code.

$ git clone --depth=1 https://chromium.googlesource.com/chromium/src.git -b 73.0.3676.0
$ cd src

Then, download third party modules.

$ gclient sync -j 8

3. Add -pg option with a build flag

$ git diff
diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni
index befd9d78b3fc..4ce4b6f60935 100644
--- a/build/config/compiler/compiler.gni
+++ b/build/config/compiler/compiler.gni
@@ -79,6 +79,9 @@ declare_args() {
   # is_component_build=false. Very large debug symbols can have unwanted side
   # effects so this is enforced by default for chromium.
   forbid_non_component_debug_builds = build_with_chromium
+
+  # Enables -g -pg -fno-omit-frame-pointer for uftrace
+  use_uftrace = false
 }
 
 assert(!is_cfi || use_thin_lto, "CFI requires ThinLTO")
$ cd third_party/ffmpeg
$ git diff
diff --git a/BUILD.gn b/BUILD.gn
index 85a5338e55..e54bb56bec 100755
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -8,6 +8,7 @@ import("ffmpeg_options.gni")
 import("//build/buildflag_header.gni")
 import("//build/config/compiler/compiler.gni")
 import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/compiler/compiler.gni")

 # Path to platform configuration files.
 platform_config_root =
@@ -295,6 +296,10 @@ target(link_target_type, "ffmpeg_internal") {
       ]
     }

+    if (use_uftrace) {
+      cflags -= [ "-fomit-frame-pointer" ]
+    }
+
     if (!is_clang) {
       # gcc doesn't have flags for specific warnings, so disable them
       # all.
$ cd third_party/swiftshader
$ git diff
diff --git a/BUILD.gn b/BUILD.gn
index 56c78ce9c..54933c0a5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -76,6 +76,10 @@ config("swiftshader_config") {
         "-Os",
       ]
 
+      if (use_uftrace) {
+        cflags -= [ "-fomit-frame-pointer" ]
+      }
+
       defines += [
         "ANGLE_DISABLE_TRACE",
         "NDEBUG",

4. Build for chrome

$ gn gen out/Release.pg.g "--args=enable_nacl=false is_component_build=false is_debug=false use_jumbo_build=true symbol_level=2 use_uftrace=true"

$ ninja -C out/Release.pg.g chrome
Clone this wiki locally