OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/toolchain/toolchain.gni") | 5 import("//build/toolchain/toolchain.gni") |
6 | 6 |
7 # This config causes functions not to be automatically exported from shared | 7 # This config causes functions not to be automatically exported from shared |
8 # libraries. By default, all symbols are exported but this means there are | 8 # libraries. By default, all symbols are exported but this means there are |
9 # lots of exports that slow everything down. In general we explicitly mark | 9 # lots of exports that slow everything down. In general we explicitly mark |
10 # which functiosn we want to export from components. | 10 # which functiosn we want to export from components. |
11 # | 11 # |
12 # Some third_party code assumes all functions are exported so this is separated | 12 # Some third_party code assumes all functions are exported so this is separated |
13 # into its own config so such libraries can remove this config to make symbols | 13 # into its own config so such libraries can remove this config to make symbols |
14 # public again. | 14 # public again. |
15 # | 15 # |
16 # See http://gcc.gnu.org/wiki/Visibility | 16 # See http://gcc.gnu.org/wiki/Visibility |
17 config("symbol_visibility_hidden") { | 17 config("symbol_visibility_hidden") { |
18 # Note that -fvisibility-inlines-hidden is set globally in the compiler | 18 # Note that -fvisibility-inlines-hidden is set globally in the compiler |
19 # config since that can almost always be applied. | 19 # config since that can almost always be applied. |
20 cflags = [ "-fvisibility=hidden" ] | 20 cflags = [ "-fvisibility=hidden" ] |
21 } | 21 } |
22 | 22 |
23 # The rpath is the dynamic library search path. Setting this config on a link | |
24 # step will put the directory where the build generates shared libraries into | |
25 # the rpath. | |
26 # | |
27 # It's important that this *not* be used for release builds we push out. | |
28 # Chrome uses some setuid binaries, and hard links preserve setuid bits. An | |
29 # unprivileged user could gain root privileges by hardlinking a setuid | |
30 # executable and then adding in whatever binaries they want to run into the lib | |
31 # directory. | |
32 # | |
33 # Example bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520126 | |
34 # | |
35 # This is required for component builds since the build generates many shared | |
36 # libraries in the build directory that we expect to be automatically loaded. | |
37 # It will be automatically applied in this case by :executable_ldconfig. | |
38 # | |
39 # In non-component builds, certain test binaries may expect to load dynamic | |
40 # libraries from the current directory. As long as these aren't distributed, | |
41 # this is OK. For these cases use something like this: | |
42 # | |
43 # if (is_linux && !is_component_build) { | |
44 # configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] | |
45 # } | |
46 config("rpath_for_built_shared_libraries") { | |
47 if (!is_android) { | |
48 # Note: Android doesn't support rpath. | |
49 if (shlib_subdir != ".") { | |
50 rpath_link = "${shlib_subdir}/" | |
51 } else { | |
52 rpath_link = "." | |
53 } | |
54 ldflags = [ | |
55 # Want to pass "\$". GN will re-escape as required for ninja. | |
56 "-Wl,-rpath=\$ORIGIN/${rpath_link}", | |
57 "-Wl,-rpath-link=${rpath_link}", | |
58 ] | |
59 } | |
60 } | |
61 | |
62 # Settings for executables and shared libraries. | 23 # Settings for executables and shared libraries. |
63 config("executable_ldconfig") { | 24 config("executable_ldconfig") { |
64 if (is_android) { | 25 if (is_android) { |
65 ldflags = [ | 26 ldflags = [ |
66 "-Bdynamic", | 27 "-Bdynamic", |
67 "-Wl,-z,nocopyreloc", | 28 "-Wl,-z,nocopyreloc", |
68 ] | 29 ] |
69 } else { | 30 } else { |
70 if (is_component_build) { | 31 # Note: Android doesn't support rpath. |
71 configs = [ ":rpath_for_built_shared_libraries" ] | 32 rpath_link = "." |
| 33 if (shlib_subdir != ".") { |
| 34 rpath_link = "${shlib_subdir}/" |
72 } | 35 } |
| 36 ldflags = [ |
| 37 # Want to pass "\$". GN will re-escape as required for ninja. |
| 38 "-Wl,-rpath=\$ORIGIN/${rpath_link}", |
| 39 "-Wl,-rpath-link=${rpath_link}", |
73 | 40 |
74 ldflags = [ | |
75 # TODO(GYP): Do we need a check on the binutils version here? | |
76 # | |
77 # Newer binutils don't set DT_RPATH unless you disable "new" dtags | 41 # Newer binutils don't set DT_RPATH unless you disable "new" dtags |
78 # and the new DT_RUNPATH doesn't work without --no-as-needed flag. | 42 # and the new DT_RUNPATH doesn't work without --no-as-needed flag. |
79 "-Wl,--disable-new-dtags", | 43 "-Wl,--disable-new-dtags", |
80 ] | 44 ] |
81 } | 45 } |
82 } | 46 } |
83 | 47 |
84 config("no_exceptions") { | 48 config("no_exceptions") { |
85 cflags_cc = [ "-fno-exceptions" ] | 49 cflags_cc = [ "-fno-exceptions" ] |
86 cflags_objcc = cflags_cc | 50 cflags_objcc = cflags_cc |
87 } | 51 } |
OLD | NEW |