Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / build / config / compiler / BUILD.gn
index 78ddeea..c492356 100644 (file)
@@ -3,7 +3,6 @@
 # found in the LICENSE file.
 
 import("//build/config/android/config.gni")
-import("//build/config/sysroot.gni")
 if (cpu_arch == "arm") {
   import("//build/config/arm.gni")
 }
@@ -37,17 +36,20 @@ config("compiler") {
       "/GS",  # Enable buffer security checking.
       "/EHsc",  # Assume C functions can't throw exceptions and don't catch
                 # structured exceptions (only C++ ones).
+      "/FS",  # Preserve previous PDB behavior.
     ]
   } else {
     # Common GCC compiler flags setup.
     # --------------------------------
     cflags += [
       "-fno-strict-aliasing",  # See http://crbug.com/32204
-      "-fvisibility=hidden",
     ]
     cflags_cc += [
       "-fno-exceptions",
       "-fno-threadsafe-statics",
+      # Not exporting C++ inline functions can generally be applied anywhere
+      # so we do so here. Normal function visibility is controlled by
+      # //build/config/gcc:symbol_visibility_hidden.
       "-fvisibility-inlines-hidden",
     ]
 
@@ -63,12 +65,7 @@ config("compiler") {
   # ----------------------------------
   if (is_mac || is_ios) {
     # These flags are shared between the C compiler and linker.
-    common_mac_flags = [ "-isysroot", sysroot ]
-    if (is_mac) {
-      common_mac_flags += [ "-mmacosx-version-min=10.6" ]
-    } else {
-      cflags += [ "-mios-simulator-version-min=6.0" ]
-    }
+    common_mac_flags = []
 
     # CPU architecture.
     if (cpu_arch == "x64") {
@@ -77,22 +74,16 @@ config("compiler") {
       common_mac_flags += [ "-arch i386" ]
     }
 
-    cflags += common_mac_flags + [
-      # Without this, the constructors and destructors of a C++ object inside
-      # an Objective C struct won't be called, which is very bad.
-      "-fobjc-call-cxx-cdtors",
-    ]
+    cflags += common_mac_flags
+
+    # Without this, the constructors and destructors of a C++ object inside
+    # an Objective C struct won't be called, which is very bad.
+    cflags_objcc = [ "-fobjc-call-cxx-cdtors", ]
 
     cflags_c += [ "-std=c99" ]
     cflags_cc += [ "-std=gnu++11" ]
 
-    ldflags += common_mac_flags + [
-      "-L.",
-
-      # TODO(brettW) I don't understand these options.
-      "-Wl,-rpath,@loader_path/.",
-      "-Wl,-rpath,@loader_path/../../..",
-    ]
+    ldflags += common_mac_flags
   } else if (is_posix) {
     # Non-Mac Posix compiler flags setup.
     # -----------------------------------
@@ -154,7 +145,8 @@ config("compiler") {
     if (cpu_arch == "x64") {
       # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of
       # address space, and it doesn't support cross-compiling).
-      gold_path = rebase_path("//third_party/gold", ".", root_build_dir)
+      gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin",
+                              root_build_dir)
       ldflags += [
         "-B$gold_path",
 
@@ -170,22 +162,13 @@ config("compiler") {
         # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
         # Only apply this to the target linker, since the host
         # linker might not be gold, but isn't used much anyway.
-        "-Wl,--threads",
-        "-Wl,--thread-count=4",
+        # TODO(raymes): Disable threading because gold is frequently
+        # crashing on the bots: crbug.com/161942.
+        #"-Wl,--threads",
+        #"-Wl,--thread-count=4",
       ]
     }
 
-    if (sysroot != "") {
-      cflags += [ "--sysroot=" + sysroot ]
-      ldflags += [ "--sysroot=" + sysroot ]
-
-      # Need to get some linker flags out of the sysroot.
-      ldflags += [ exec_script("../linux/sysroot_ld_path.py",
-          [rebase_path("../../linux/sysroot_ld_path.sh", ".", root_build_dir),
-           sysroot],
-          "value") ]
-    }
-
     ldflags += [
       "-fPIC",
       "-pthread",
@@ -258,7 +241,6 @@ config("compiler") {
       if (cpu_arch == "arm") {
         cflags += [
           "-target arm-linux-androideabi",
-          "-mllvm -arm-enable-ehabi",
         ]
         ldflags += [ "-target arm-linux-androideabi" ]
       } else if (cpu_arch == "x86") {
@@ -320,8 +302,6 @@ config("runtime_library") {
       "_CRT_RAND_S",
       "_CRT_SECURE_NO_DEPRECATE",
       "_SCL_SECURE_NO_DEPRECATE",
-      "_UNICODE",
-      "UNICODE",
     ]
   }
 
@@ -345,17 +325,6 @@ config("runtime_library") {
       "-nostdlib",
     ]
 
-    libs += [
-      # TODO(brettw) write a version of this, hopefully we can express this
-      # without forking out to GCC just to get the library name. The android
-      # toolchain directory should probably be extracted into a .gni file that
-      # this file and the android toolchain .gn file can share.
-      #   # Manually link the libgcc.a that the cross compiler uses.
-      #   '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
-      "c",
-      "dl",
-      "m"
-    ]
 
     # NOTE: The stlport header include paths below are specified in cflags
     # rather than include_dirs because they need to come after include_dirs.
@@ -420,34 +389,58 @@ config("chromium_code") {
     # TODO(brettw) this should also be enabled on Linux but some files
     # currently fail.
     if (is_mac) {
-      cflags += "-Wextra"
+      cflags += [ "-Wextra" ]
     }
   }
 }
 config("no_chromium_code") {
+  cflags = []
+  cflags_cc = []
+  defines = []
+
   if (is_win) {
-    cflags = [
+    cflags += [
       "/W3",  # Warning level 3.
       "/wd4800",  # Disable warning when forcing value to bool.
     ]
-    defines = [
+    defines += [
       "_CRT_NONSTDC_NO_WARNINGS",
       "_CRT_NONSTDC_NO_DEPRECATE",
     ]
   }
 
+  if (is_linux) {
+    # Don't warn about ignoring the return value from e.g. close(). This is
+    # off by default in some gccs but on by default in others. BSD systems do
+    # not support this option, since they are usually using gcc 4.2.1, which
+    # does not have this flag yet.
+    cflags += [ "-Wno-unused-result" ]
+  }
+
+  if (is_linux || is_android) {
+    cflags += [
+      # Don't warn about printf format problems. This is off by default in gcc
+      # but on in Ubuntu's gcc(!).
+      "-Wno-format",
+    ]
+    cflags_cc += [
+      # Don't warn about hash_map in third-party code.
+      "-Wno-deprecated",
+    ]
+  }
+
   if (is_android_webview_build) {
     # There is a class of warning which:
     #  1) Android always enables and also treats as errors
     #  2) Chromium ignores in third party code
     # So we re-enable those warnings when building Android.
-    cflags = [
+    cflags += [
       "-Wno-address",
       "-Wno-format-security",
       "-Wno-return-type",
       "-Wno-sequence-point",
     ]
-    cflags_cc = [ "-Wno-non-virtual-dtor" ]
+    cflags_cc += [ "-Wno-non-virtual-dtor" ]
   }
 }
 
@@ -516,7 +509,6 @@ config("default_warnings") {
       # Disables.
       "-Wno-missing-field-initializers",  # "struct foo f = {0};"
       "-Wno-unused-parameter",  # Unused function parameters.
-      "-Wno-write-strings",
     ]
 
     if (is_mac) {
@@ -525,12 +517,8 @@ config("default_warnings") {
       ]
     }
 
-    # TODO(brettw) Ones below here should be clang-only when we have a flag
-    # for it.
     if (is_clang) {
       cflags += [
-        "-Wheader-hygiene",
-
         # This warns on using ints as initializers for floats in
         # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|),
         # which happens in several places in chrome code. Not sure if
@@ -553,9 +541,6 @@ config("default_warnings") {
 
         # Clang spots more unused functions.
         "-Wno-unused-function",
-
-        # Warns when a const char[] is converted to bool.
-        "-Wstring-conversion",
       ]
     }