[M69 Dev][Public][Rom Size][Build Speed] Support clang build for chromium-efl 69/195169/5
authorChandan Padhi <c.padhi@samsung.com>
Tue, 11 Dec 2018 07:01:37 +0000 (23:01 -0800)
committerBot Blink <blinkbot@samsung.com>
Fri, 14 Dec 2018 08:47:41 +0000 (08:47 +0000)
This patch enables support for use of clang compiler and lld linker
to reduce binary size and to improve build speed for public profile
and desktop.

Note that platform llvm v3.8 does NOT support thin lto option and
there's no gain for binary size optimization. So, this utilizes
upgraded home-built llvm v7.0.

Clang is used as default for standard profile and desktop builds.
In case of standard profile, clang build is currently supported
for arm(armv7l) achitecture target only.

Below commands can be used to build with gcc.
$./tizen_src/build/build_standard_armv7l.sh --gcc
$./tizen_src/build/build_desktop.sh --gcc

We have not decided yet on default use of clang for product tv.
Below command can be used to build with clang.
$./tizen_src/build/build_tv.sh --clang

Binary Size of libchromium-ewk.so:

Note that product tv obs does NOT allow to strip section .symtab
and .strtab but public obs allows to strip those sections by default.
That's why released product tv binary size(91 MB) is much larger than
public target binary size(41 MB).

1) Product TV
w/o clang: 104.6 MB
with clang: 91 MB

2) Public Target
w/o clang: 47.6 MB
with clang: 41.7 MB

Also, build speed has been improved by about 10% and no regression has
been found, comparing to gcc built-chromium-efl.

Change-Id: I3318fbb69b441769c3905431e665fbd4ac3aa4c9
Signed-off-by: Chandan Padhi <c.padhi@samsung.com>
17 files changed:
build/config/clang/clang.gni
build/config/compiler/BUILD.gn
device/fido/BUILD.gn
device/fido/fido_discovery.cc
native_client/src/trusted/service_runtime/linux/BUILD.gn
packaging/chromium-efl.spec
tizen_src/build/BUILD.gn
tizen_src/build/common.sh
tizen_src/build/config/compiler/BUILD.gn
tizen_src/build/config/tizen/BUILD.gn
tizen_src/build/config/tizen_features.gni
tizen_src/build/gn_chromiumefl.sh
tizen_src/build/toolchain/tizen/BUILD.gn
tizen_src/ewk/efl_integration/BUILD.gn
tizen_src/ewk/efl_webview_app/BUILD.gn
tizen_src/ewk/efl_webview_app/mini_browser.c
tizen_src/ewk/ubrowser/BUILD.gn

index 2c2d76f..42b3fa0 100644 (file)
@@ -9,7 +9,8 @@ default_clang_base_path = "//third_party/llvm-build/Release+Asserts"
 declare_args() {
   # Indicates if the build should use the Chrome-specific plugins for enforcing
   # coding guidelines, etc. Only used when compiling with Clang.
-  clang_use_chrome_plugins = is_clang && !is_nacl && !use_xcode_clang
+  clang_use_chrome_plugins =
+      is_clang && !is_tizen && !is_nacl && !use_xcode_clang
 
   clang_base_path = default_clang_base_path
 }
index 734fdd9..0e40ce8 100644 (file)
@@ -223,6 +223,8 @@ config("compiler") {
     configs += [ "//build/config/fuchsia:compiler" ]
   } else if (current_os == "aix") {
     configs += [ "//build/config/aix:compiler" ]
+  } else if (is_tizen) {
+    configs += [ "//tizen_src/build/config/tizen:compiler" ]
   }
 
   configs += [
@@ -448,7 +450,7 @@ config("compiler") {
     ldflags += [ "-fuse-ld=bfd" ]
   }
 
-  if (is_tizen) {
+  if (is_tizen && !is_clang) {
     ldflags += [ "-fuse-ld=gold" ]
   }
 
@@ -494,8 +496,8 @@ config("compiler") {
     }
   }
 
-  if (is_clang && !is_nacl && current_toolchain == host_toolchain &&
-      target_os != "chromeos") {
+  if (is_clang && !is_nacl && !is_tizen &&
+      current_toolchain == host_toolchain && target_os != "chromeos") {
     cflags += [
       # TODO(hans): Remove this once Clang generates better optimized debug info
       # by default. https://crbug.com/765793
@@ -635,13 +637,13 @@ config("compiler") {
 
     # Disable optimization for now because they increase binary size by too
     # much.
-    if (use_lld && (is_android || (is_linux && !is_chromeos))) {
+    if (use_lld && (is_android || is_tizen || (is_linux && !is_chromeos))) {
       ldflags += [ "-Wl,--lto-O0" ]
     }
 
     # TODO(pcc): Re-enable this flag on Android. This will require libc++ to be
     # built with ThinLTO (see https://crbug.com/767901) as well as the GVR shim.
-    if (!is_android) {
+    if (!is_android && !is_tizen) {
       cflags += [ "-fwhole-program-vtables" ]
       if (!is_win) {
         ldflags += [ "-fwhole-program-vtables" ]
@@ -735,7 +737,7 @@ config("compiler_cpu_abi") {
         ]
       }
     } else if (current_cpu == "arm") {
-      if (is_clang && !is_android && !is_nacl) {
+      if (is_clang && !is_android && !is_nacl && !is_tizen) {
         cflags += [ "--target=arm-linux-gnueabihf" ]
         ldflags += [ "--target=arm-linux-gnueabihf" ]
       }
@@ -1450,7 +1452,7 @@ config("default_warnings") {
 
     # use_xcode_clang only refers to the iOS toolchain, host binaries use
     # chromium's clang always.
-    if (!is_nacl) {
+    if (!is_nacl && !is_tizen) {
       cflags += [
         # TODO(thakis): https://crbug.com/604888
         "-Wno-undefined-var-template",
@@ -2050,7 +2052,7 @@ config("optimize_tizen") {
   if (is_tizen) {
     # Let compiler use lto from platform configuration.
     common_optimize_on_cflags += [ "-O$lto_level" ]
-    if (lto_level == "s") {
+    if (lto_level == "s" || lto_level == "z") {
       common_optimize_on_ldflags += [ "-Wl,-O1" ]
     } else {
       common_optimize_on_ldflags += [ "-Wl,-O$lto_level" ]
index 369ac7d..dd9df06 100644 (file)
@@ -139,7 +139,7 @@ component("fido") {
   libs = []  # Extended for mac.
 
   # HID is not supported on Android.
-  if (!is_android) {
+  if (!is_android && !is_tizen) {
     sources += [
       "fido_hid_device.cc",
       "fido_hid_device.h",
index 98d4f67..6011a4e 100644 (file)
@@ -12,7 +12,7 @@
 #include "device/fido/fido_device.h"
 
 // HID is not supported on Android.
-#if !defined(OS_ANDROID)
+#if !defined(OS_ANDROID) && !defined(OS_TIZEN)
 #include "device/fido/fido_hid_discovery.h"
 #endif  // !defined(OS_ANDROID)
 
@@ -25,7 +25,7 @@ std::unique_ptr<FidoDiscovery> CreateFidoDiscoveryImpl(
     service_manager::Connector* connector) {
   switch (transport) {
     case FidoTransportProtocol::kUsbHumanInterfaceDevice:
-#if !defined(OS_ANDROID)
+#if !defined(OS_ANDROID) && !defined(OS_TIZEN)
       DCHECK(connector);
       return std::make_unique<FidoHidDiscovery>(connector);
 #else
index 634894e..906fbd2 100644 (file)
@@ -68,6 +68,10 @@ if (current_toolchain == bootstrap_toolchain) {
       "//build/config/compiler:default_symbols",
     ]
 
+    if (is_tizen) {
+      configs += [ "//tizen_src/build/config/tizen:compiler" ]
+    }
+
     include_dirs = [ "//" ]
 
     cflags = [
index b71af7a..29e07bd 100644 (file)
@@ -129,6 +129,29 @@ BuildRequires: pkgconfig(vd-win-util)
 BuildRequires: binutils-gold
 %endif
 
+%ifarch armv7l
+%define ARCHITECTURE armv7l
+%endif
+%ifarch aarch64
+%define ARCHITECTURE aarch64
+%endif
+%ifarch i586 i686
+%define ARCHITECTURE ix86
+%endif
+%ifarch x86_64
+%define ARCHITECTURE x86_64
+%endif
+
+%if ("%{?tizen_profile_name}" == "tv" && "%{?_clang}" == "1") || ("%{?tizen_profile_name}" != "tv" && "%{?_gcc}" != "1" && "%{ARCHITECTURE}" == "armv7l")
+%define __use_clang 1
+%else
+%define __use_clang 0
+%endif
+
+%if %{__use_clang} == 1
+BuildRequires: libatomic
+%endif
+
 %description
 Browser Engine based on Chromium EFL (Shared Library)
 
@@ -207,19 +230,6 @@ Chromium EFL unit test utilities
   CXXFLAGS="$(echo $CXXFLAGS | sed -E 's/-g[0-9] /-g0 /g')"
 %endif
 
-%ifarch armv7l
-%define ARCHITECTURE armv7l
-%endif
-%ifarch aarch64
-%define ARCHITECTURE aarch64
-%endif
-%ifarch i586 i686
-%define ARCHITECTURE ix86
-%endif
-%ifarch x86_64
-%define ARCHITECTURE x86_64
-%endif
-
 # The "_repository" flag was changed to "_vd_cfg_target_repository" in tizen 4.0 product tv.
 %if "%{?tizen_profile_name}" == "tv"
 %define repo_name %{_vd_cfg_target_repository}
@@ -265,6 +275,11 @@ fi
 %if 0%{?component_build}
  "component=\"shared_library\"" \
 %endif
+%if %{__use_clang} == 1
+  "is_clang=true" \
+%else
+  "is_clang=false" \
+%endif
 %endif  # _skip_gn
 
 ninja %{_smp_mflags} -C "%{OUTPUT_FOLDER}" \
index 4fffe95..2b26bb3 100644 (file)
@@ -78,9 +78,7 @@ tizen_pkg_config("libecore-wayland") {
 
 config("ecore-wayland-public") {
   if (is_tizen && use_wayland) {
-    if (tizen_version >= 50) {
-      cflags = [ "-ecore-wl2" ]
-    } else {
+    if (tizen_version < 50) {
       cflags = [ "-ecore-wayland" ]
     }
   }
index 044d758..545a885 100755 (executable)
@@ -66,7 +66,7 @@ EOF
 function parseHostBuildScriptParams() {
 
   export USE_CCACHE=0
-  export USE_CLANG=0
+  export USE_CLANG=1
   export FORCE_JHBUILD=0
   export SKIP_NINJA=0
   export BUILD_EWK_UNITTESTS=0
@@ -90,8 +90,8 @@ function parseHostBuildScriptParams() {
         export USE_CCACHE=1
         source $TOPDIR/tizen_src/build/ccache_env.sh ${platform}
         ;;
-      --clang)
-        export USE_CLANG=1
+      --gcc)
+        export USE_CLANG=0
         ;;
       --no-content-shell)
         export BUILD_CONTENT_SHELL=0
@@ -230,6 +230,16 @@ function setupAndExecuteTargetBuild() {
     --mirror)
         MIRROR=1
     ;;
+    --gcc)
+        ARGS[$count]=--define
+        count=$(( $count + 1 ))
+        ARGS[$count]="_gcc 1"
+    ;;
+    --clang)
+        ARGS[$count]=--define
+        count=$(( $count + 1 ))
+        ARGS[$count]="_clang 1"
+    ;;
     --standard*)
         if [ "$DEFAULT_TIZEN_VERSION" == "latest" ]; then
           echo $1
index 2892de6..5b420e5 100644 (file)
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build/config/features.gni")
+import("//tizen_src/build/config/tizen_features.gni")
 
 declare_args() {
   if (is_tizen) {
@@ -121,11 +122,17 @@ config("tizen_default_include_dirs") {
     include_dirs += [
       "$deps_include_path/appfw",
       "$deps_include_path/system",
-
       "$deps_lib_path/dbus-1.0/include",
       "$deps_lib_path/gstreamer-1.0/include",
       "$deps_lib_path/gstreamer-1.0/include/gst",
       "//third_party/perfetto/include",
     ]
+    if (is_clang) {
+      include_dirs += [
+        "$tizen_clang_base_path/lib/clang/7.0.0/include",
+        "$deps_lib_path/gcc/armv7l-tizen-linux-gnueabi/6.2.1/include/c++",
+        "$deps_lib_path/gcc/armv7l-tizen-linux-gnueabi/6.2.1/include/c++/armv7l-tizen-linux-gnueabi",
+      ]
+    }
   }
 }
index 996c270..18223ec 100644 (file)
@@ -21,7 +21,7 @@ config("compiler") {
     # Clang doesn't support these flags.
     cflags += [ "-finline-limit=64" ]
   }
-  if (is_clang) {
+  if (is_clang && is_android) {
     rebased_android_toolchain_root =
         rebase_path(android_toolchain_root, root_build_dir)
     assert(rebased_android_toolchain_root != "")  # Mark as used.
@@ -35,8 +35,9 @@ config("compiler") {
   }
 
   # Use gold for Android for most CPU architectures.
-  if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") {
-    if (is_clang) {
+  if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm" ||
+      current_cpu == "arm64") {
+    if (is_clang && is_android) {
       # Let clang find the ld.gold in the NDK.
       ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ]
     }
@@ -48,7 +49,7 @@ config("compiler") {
     }
   }
 
-  if (current_cpu == "mipsel" && is_clang) {
+  if (current_cpu == "mipsel" && is_clang && is_android) {
     # Let clang find the ld.bfd in the NDK.
     ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ]
   }
@@ -70,7 +71,7 @@ config("compiler") {
 
   if (is_clang) {
     if (current_cpu == "arm") {
-      abi_target = "arm-linux-androideabi"
+      abi_target = "armv7l-tizen-linux-gnueabi"
     } else if (current_cpu == "x86") {
       abi_target = "i686-linux-androideabi"
     } else if (current_cpu == "arm64") {
index c861c9b..07aa92d 100644 (file)
@@ -23,8 +23,7 @@ declare_args() {
   tizen_multimedia_support = false
   werror = false
 
-  # declared from BUILDCONFIG.gn
-  #is_clang = false
+  tizen_clang_base_path = "//tizen_src/buildtools/llvm"
 
   tizen_product_tv = false
 
index 3fb61ba..2934403 100755 (executable)
@@ -41,6 +41,8 @@ while [[ $# > 0 ]]; do
     tizen_product_tv=true)
       tizen_product_tv=true
       ;;
+    is_clang=true)
+      is_clang=true
     #use_wayland=true)
     #  use_wayland=true
     #  ;;
@@ -95,12 +97,12 @@ SYSTEM_DEPS="--system-libraries
             "
 
 add_desktop_flags() {
-  clang="true"
-  if [ "$USECLANG" == "0" ]; then
-    clang="false"
+  local is_clang=false
+  if [ $USE_CLANG == 1 ]; then
+    is_clang=true
   fi
   ADDITIONAL_GN_PARAMETERS+="is_tizen=false
-                             is_clang=${clang}
+                             is_clang=${is_clang}
                              werror=false
                              use_sysroot=false
                              use_wayland=false
@@ -118,7 +120,6 @@ add_tizen_flags() {
   ADDITIONAL_GN_PARAMETERS+="is_tizen=true
                              python_ver=\"$(getPythonVersion)\"
                              enable_basic_printing=true
-                             is_clang=false
                              is_official_build=true
                              linux_use_bundled_binutils=false
                              enable_nacl=false
@@ -127,8 +128,6 @@ add_tizen_flags() {
                              current_cpu=\"${host_arch}\"
                              host_cpu=\"${host_arch}\"
                              target_cpu=\"${host_arch}\"
-                             host_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_$host_arch\"
-                             v8_snapshot_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_$host_arch\"
                             "
 
   # FIXME : Note that the v8_snapshot_toolchain has been set to wrong
@@ -140,6 +139,17 @@ add_tizen_flags() {
                               "
   fi
 
+  if [ $is_clang == true ]; then
+    ADDITIONAL_GN_PARAMETERS+="host_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_clang_$host_arch\"
+                               v8_snapshot_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_clang_$host_arch\"
+                               use_thin_lto=true
+                              "
+  else
+    ADDITIONAL_GN_PARAMETERS+="host_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_$host_arch\"
+                               v8_snapshot_toolchain=\"//tizen_src/build/toolchain/tizen:tizen_$host_arch\"
+                              "
+  fi
+
   # [M49_2623] Temporary disabling the flag.
   #            FIXME: http://165.213.149.170/jira/browse/TWF-610
   ADDITIONAL_GN_PARAMETERS+="tizen_multimedia_support=false
@@ -164,13 +174,13 @@ add_gbs_flags() {
   # and Os is applied to the others.
   local lto_level="s"
 
-  if [[ $lto_level =~ ^[0-9s]$ ]]; then
-    ADDITIONAL_GN_PARAMETERS+="lto_level=\"$lto_level\"
-                              "
-  else
-    ADDITIONAL_GN_PARAMETERS+="lto_level=\"s\"
-                              "
+  if [ $is_clang == true ]; then
+   lto_level="z"
   fi
+
+  ADDITIONAL_GN_PARAMETERS+="lto_level=\"$lto_level\"
+                            "
+
   # TODO(youngsoo):
   # Due to large file size issue of libchromium-ewk.so,
   # The symbol level is set to 1 by default.
index a24d6d5..f43235f 100644 (file)
@@ -4,6 +4,7 @@
 
 import("//build/config/clang/clang.gni")
 import("//build/toolchain/gcc_toolchain.gni")
+import("//tizen_src/build/config/tizen_features.gni")
 
 template("tizen_gcc_toolchain") {
   gcc_toolchain(target_name) {
@@ -19,7 +20,7 @@ template("tizen_gcc_toolchain") {
     }
 
     if (toolchain_uses_clang) {
-      _prefix = rebase_path("$clang_base_path/bin", root_build_dir)
+      _prefix = rebase_path("$tizen_clang_base_path/bin", root_build_dir)
       cc = "$_prefix/clang"
       cxx = "$_prefix/clang++"
       ar = "$_prefix/llvm-ar"
index f4d43c5..e35777e 100644 (file)
@@ -53,7 +53,6 @@ shared_library("chromium-ewk") {
   public_configs += [ "//tizen_src/build:feedback-public" ]
   configs += [ "//tizen_src/build:efl-extension" ]
   configs += [ "//tizen_src/build:libefl-extension" ]
-  public_configs += [ "//tizen_src/build:efl-extension-public" ]
   configs += [ "//tizen_src/build:ui-gadget" ]
   configs += [ "//tizen_src/build:libui-gadget" ]
   public_configs += [ "//tizen_src/build:ui-gadget-public" ]
@@ -172,6 +171,10 @@ shared_library("chromium-ewk") {
     deps += [ "//ui/ozone" ]
   }
 
+  if (is_clang) {
+    libs = [ "atomic" ]
+  }
+
   sources += [
     "autofill_popup_view_efl.cc",
     "autofill_popup_view_efl.h",
@@ -396,7 +399,6 @@ shared_library("chromium-ewk") {
     "private/ewk_wrt_private.h",
     "private/webview_delegate_ewk.cc",
     "private/webview_delegate_ewk.h",
-
     "public/EWebKit.h",
     "public/EWebKit_internal.h",
     "public/EWebKit_product.h",
@@ -509,7 +511,6 @@ shared_library("chromium-ewk") {
     "public/ewk_web_application_icon_data_internal.h",
     "public/ewk_window_features.cc",
     "public/ewk_window_features_internal.h",
-
     "renderer/content_renderer_client_efl.cc",
     "renderer/content_renderer_client_efl.h",
     "renderer/editorclient_agent.cc",
index 2af3acb..728706f 100644 (file)
@@ -103,7 +103,6 @@ executable("mini_browser") {
     public_configs += [ "//tizen_src/build:ecore-evas-public" ]
     configs += [ "//tizen_src/build:efl-extension" ]
     configs += [ "//tizen_src/build:libefl-extension" ]
-    public_configs += [ "//tizen_src/build:efl-extension-public" ]
     configs += [ "//tizen_src/build:elementary" ]
     configs += [ "//tizen_src/build:libelementary" ]
     public_configs += [ "//tizen_src/build:elementary-public" ]
index 36c3ce5..63d2b47 100644 (file)
@@ -621,9 +621,7 @@ Evas_Object* _create_url_bar(Evas_Object *parent, int width, const char *start_u
   if (imf_context) {
     ecore_imf_context_prediction_allow_set(imf_context, EINA_FALSE);
     ecore_imf_context_input_panel_event_callback_add (
-        imf_context, ECORE_IMF_INPUT_PANEL_STATE_SHOW, _imf_panel_state_cb, data);
-    ecore_imf_context_input_panel_event_callback_add (
-        imf_context, ECORE_IMF_INPUT_PANEL_STATE_HIDE, _imf_panel_state_cb, data);
+        imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _imf_panel_state_cb, data);
   }
   evas_object_show(data->url_entry);
 
index 488e1b4..9ef4193 100644 (file)
@@ -34,7 +34,6 @@ executable("ubrowser") {
   ]
   configs += [ "//tizen_src/build:efl-extension" ]
   configs += [ "//tizen_src/build:libefl-extension" ]
-  public_configs += [ "//tizen_src/build:efl-extension-public" ]
   defines = [
     # Uncomment once uBrowser replaces mini_browser and it's xml
     # manifest is shipped in the rpm package