Index: build/config/gcc/BUILD.gn |
diff --git a/build/config/gcc/BUILD.gn b/build/config/gcc/BUILD.gn |
new file mode 100644 |
index 0000000000000000000000000000000000000000..62eec11904ac93b8cf26f75e76796c0881559dcd |
--- /dev/null |
+++ b/build/config/gcc/BUILD.gn |
@@ -0,0 +1,119 @@ |
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import("//build/config/compiler/compiler.gni") |
+import("//build/config/sanitizers/sanitizers.gni") |
+import("//build/config/sysroot.gni") |
+import("//build/toolchain/toolchain.gni") |
+ |
+# This config causes functions not to be automatically exported from shared |
+# libraries. By default, all symbols are exported but this means there are |
+# lots of exports that slow everything down. In general we explicitly mark |
+# which functiosn we want to export from components. |
+# |
+# Some third_party code assumes all functions are exported so this is separated |
+# into its own config so such libraries can remove this config to make symbols |
+# public again. |
+# |
+# See http://gcc.gnu.org/wiki/Visibility |
+config("symbol_visibility_hidden") { |
+ # Note that -fvisibility-inlines-hidden is set globally in the compiler |
+ # config since that can almost always be applied. |
+ cflags = [ "-fvisibility=hidden" ] |
+} |
+ |
+# This config is usually set when :symbol_visibility_hidden is removed. |
+# It's often a good idea to set visibility explicitly, as there're flags |
+# which would error out otherwise (e.g. -fsanitize=cfi-unrelated-cast) |
+config("symbol_visibility_default") { |
+ cflags = [ "-fvisibility=default" ] |
+} |
+ |
+# The rpath is the dynamic library search path. Setting this config on a link |
+# step will put the directory where the build generates shared libraries into |
+# the rpath. |
+# |
+# It's important that this *not* be used for release builds we push out. |
+# Chrome uses some setuid binaries, and hard links preserve setuid bits. An |
+# unprivileged user could gain root privileges by hardlinking a setuid |
+# executable and then adding in whatever binaries they want to run into the lib |
+# directory. |
+# |
+# Example bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520126 |
+# |
+# This is required for component builds since the build generates many shared |
+# libraries in the build directory that we expect to be automatically loaded. |
+# It will be automatically applied in this case by :executable_ldconfig. |
+# |
+# In non-component builds, certain test binaries may expect to load dynamic |
+# libraries from the current directory. As long as these aren't distributed, |
+# this is OK. For these cases use something like this: |
+# |
+# if (is_linux && !is_component_build) { |
+# configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] |
+# } |
+config("rpath_for_built_shared_libraries") { |
+ if (!is_android) { |
+ # Note: Android doesn't support rpath. |
+ if (shlib_subdir != ".") { |
+ rpath_link = "${shlib_subdir}/" |
+ } else { |
+ rpath_link = "." |
+ } |
+ ldflags = [ |
+ # Want to pass "\$". GN will re-escape as required for ninja. |
+ "-Wl,-rpath=\$ORIGIN/${rpath_link}", |
+ "-Wl,-rpath-link=${rpath_link}", |
+ ] |
+ } |
+} |
+ |
+# Settings for executables. |
+config("executable_ldconfig") { |
+ ldflags = [] |
+ if (is_android) { |
+ ldflags += [ |
+ "-Bdynamic", |
+ "-Wl,-z,nocopyreloc", |
+ ] |
+ } else { |
+ # See the rpath_for... config above for why this is necessary for component |
+ # builds. Sanitizers use a custom libc++ where this is also necessary. |
+ if (is_component_build || using_sanitizer) { |
+ configs = [ ":rpath_for_built_shared_libraries" ] |
+ } |
+ if (current_cpu == "mipsel") { |
+ ldflags += [ "-pie" ] |
+ } |
+ } |
+ |
+ if (!is_android || !use_gold) { |
+ # Find the path containing shared libraries for this toolchain |
+ # relative to the build directory. ${root_out_dir} will be a |
+ # subdirectory of ${root_build_dir} when cross compiling. |
+ _rpath_link = rebase_path(root_out_dir, root_build_dir) |
+ if (shlib_subdir != ".") { |
+ _rpath_link += "/$shlib_subdir" |
+ } |
+ if (is_android) { |
+ _rebased_sysroot = rebase_path(sysroot, root_build_dir) |
+ _rpath_link += ":$_rebased_sysroot/usr/lib" |
+ } |
+ |
+ ldflags += [ |
+ "-Wl,-rpath-link=$_rpath_link", |
+ |
+ # TODO(GYP): Do we need a check on the binutils version here? |
+ # |
+ # Newer binutils don't set DT_RPATH unless you disable "new" dtags |
+ # and the new DT_RUNPATH doesn't work without --no-as-needed flag. |
+ "-Wl,--disable-new-dtags", |
+ ] |
+ } |
+} |
+ |
+config("no_exceptions") { |
+ cflags_cc = [ "-fno-exceptions" ] |
+ cflags_objcc = cflags_cc |
+} |