Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: build/config/gcc/BUILD.gn

Issue 1525773002: Only set -rpath=$ORIGIN in component builds by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/BUILD.gn ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
23 # Settings for executables and shared libraries. 62 # Settings for executables and shared libraries.
24 config("executable_ldconfig") { 63 config("executable_ldconfig") {
25 if (is_android) { 64 if (is_android) {
26 ldflags = [ 65 ldflags = [
27 "-Bdynamic", 66 "-Bdynamic",
28 "-Wl,-z,nocopyreloc", 67 "-Wl,-z,nocopyreloc",
29 ] 68 ]
30 } else { 69 } else {
31 # Note: Android doesn't support rpath. 70 if (is_component_build) {
32 rpath_link = "." 71 configs = [ ":rpath_for_built_shared_libraries" ]
33 if (shlib_subdir != ".") {
34 rpath_link = "${shlib_subdir}/"
35 } 72 }
73
36 ldflags = [ 74 ldflags = [
37 # Want to pass "\$". GN will re-escape as required for ninja. 75 # TODO(GYP): Do we need a check on the binutils version here?
38 "-Wl,-rpath=\$ORIGIN/${rpath_link}", 76 #
39 "-Wl,-rpath-link=${rpath_link}",
40
41 # Newer binutils don't set DT_RPATH unless you disable "new" dtags 77 # Newer binutils don't set DT_RPATH unless you disable "new" dtags
42 # and the new DT_RUNPATH doesn't work without --no-as-needed flag. 78 # and the new DT_RUNPATH doesn't work without --no-as-needed flag.
43 "-Wl,--disable-new-dtags", 79 "-Wl,--disable-new-dtags",
44 ] 80 ]
45 } 81 }
46 } 82 }
47 83
48 config("no_exceptions") { 84 config("no_exceptions") {
49 cflags_cc = [ "-fno-exceptions" ] 85 cflags_cc = [ "-fno-exceptions" ]
50 cflags_objcc = cflags_cc 86 cflags_objcc = cflags_cc
51 } 87 }
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698