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

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

Issue 2288953002: [Chromecast] Only include all libstdc++/libgcc symbols in executable as needed (Closed)
Patch Set: Refactored conditional Created 4 years, 3 months 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 | « no previous file | chromecast/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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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/config/chromecast_build.gni") 5 import("//build/config/chromecast_build.gni")
6 6
7 assert(is_chromecast) 7 assert(is_chromecast)
8 8
9 is_arm_chromecast_device = current_cpu == "arm" && !is_android
10
9 config("static_config") { 11 config("static_config") {
10 ldflags = [ 12 ldflags = [
11 # We want to statically link libstdc++/libgcc. 13 # We want to statically link libstdc++/libgcc.
12 "-static-libstdc++", 14 "-static-libstdc++",
13 "-static-libgcc", 15 "-static-libgcc",
14 16
15 # Don't allow visible symbols from libraries that contain 17 # Don't allow visible symbols from libraries that contain
16 # assembly code with symbols that aren't hidden properly. 18 # assembly code with symbols that aren't hidden properly.
17 # http://b/26390825 19 # http://b/26390825
18 "-Wl,--exclude-libs=libffmpeg.a", 20 "-Wl,--exclude-libs=libffmpeg.a",
19 ] 21 ]
20 } 22 }
21 23
22 config("ldconfig") { 24 config("ldconfig") {
23 visibility = [ ":*" ] 25 visibility = [ ":*" ]
24 26
25 # Chromecast executables depend on several shared libraries in 27 # Chromecast executables depend on several shared libraries in
26 # /oem_cast_shlib, $ORIGIN, and $ORIGIN/lib. Add these rpaths to each binary. 28 # /oem_cast_shlib, $ORIGIN, and $ORIGIN/lib. Add these rpaths to each binary.
27 # This is explicitly disabled in Chrome for security reasons (see comments in 29 # This is explicitly disabled in Chrome for security reasons (see comments in
28 # //build/config/gcc/BUILD.gn), but necessary on Chromecast so that OEM's may 30 # //build/config/gcc/BUILD.gn), but necessary on Chromecast so that OEM's may
29 # override the default libraries shipped in the Cast receiver package. 31 # override the default libraries shipped in the Cast receiver package.
30 ldflags = [ 32 ldflags = [
31 "-Wl,-rpath=/oem_cast_shlib", 33 "-Wl,-rpath=/oem_cast_shlib",
32 "-Wl,-rpath=\$ORIGIN/lib", 34 "-Wl,-rpath=\$ORIGIN/lib",
33 "-Wl,-rpath=\$ORIGIN", 35 "-Wl,-rpath=\$ORIGIN",
34 ] 36 ]
35 } 37 }
36 38
37 config("executable_config") { 39 # Whole archiving libgcc.a and libstdc++ is needed if dynamic shared libs are
38 configs = [ ":ldconfig" ] 40 # used, see b/25566835.
39 41 config("executable_whole_archive_config") {
40 if (current_cpu == "arm") { 42 if (is_arm_chromecast_device) {
41 ldflags = [ 43 ldflags = [
42 # Export stdlibc++ and libgcc symbols to force shlibs to refer to these 44 # Export stdlibc++ and libgcc symbols to force shlibs to refer to these
43 # symbols from the executable. 45 # symbols from the executable.
44 "-Wl,--export-dynamic", 46 "-Wl,--export-dynamic",
45 47
46 "-lm", # stdlibc++ requires math.h 48 "-lm", # stdlibc++ requires math.h
47 49
48 # In case we redefined stdlibc++ symbols (e.g. tc_malloc) 50 # In case we redefined stdlibc++ symbols (e.g. tc_malloc).
49 "-Wl,--allow-multiple-definition", 51 "-Wl,--allow-multiple-definition",
50 52
53 # Adding all symbols from libgcc and libstdc++.
51 "-Wl,--whole-archive", 54 "-Wl,--whole-archive",
52 "-l:libstdc++.a", 55 "-l:libstdc++.a",
53 "-l:libgcc.a", 56 "-l:libgcc.a",
54 "-Wl,--no-whole-archive", 57 "-Wl,--no-whole-archive",
55 ] 58 ]
59 }
60 }
56 61
57 # Despite including libstdc++/libgcc archives, we still need to specify 62 # Statically linking against libstdc++/libgcc should happen for arm chromecast
58 # static linking for them in order to prevent the executable from having a 63 # devices, and is not needed for Android builds.
59 # dynamic dependency on them. 64 config("executable_config") {
65 configs = [ ":ldconfig" ]
66
67 if (is_arm_chromecast_device) {
68 # Statically link libstdc++ and libgcc to avoid having a dynamic dependency
69 # on them.
60 configs += [ ":static_config" ] 70 configs += [ ":static_config" ]
61 } 71 }
62 } 72 }
63 73
64 config("shared_library_config") { 74 config("shared_library_config") {
65 configs = [ ":ldconfig" ] 75 configs = [ ":ldconfig" ]
66 if (current_cpu == "arm") { 76 if (is_arm_chromecast_device) {
67 configs += [ ":static_config" ] 77 configs += [ ":static_config" ]
68 } 78 }
69 } 79 }
OLDNEW
« no previous file with comments | « no previous file | chromecast/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698