BUILD.gn 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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
  3. # found in the LICENSE file.
  4. import("//build/config/chromecast_build.gni")
  5. assert(is_castos || is_cast_android)
  6. config("static_config") {
  7. if (!is_clang) {
  8. ldflags = [
  9. # Don't allow visible symbols from libraries that contain
  10. # assembly code with symbols that aren't hidden properly.
  11. # http://b/26390825
  12. "-Wl,--exclude-libs=libffmpeg.a",
  13. ]
  14. if (!is_android) {
  15. ldflags += [
  16. # We want to statically link libstdc++/libgcc on Linux.
  17. # (On Android, libstdc++ and libgcc aren't used.)
  18. "-static-libstdc++",
  19. "-static-libgcc",
  20. ]
  21. }
  22. }
  23. }
  24. config("ldconfig") {
  25. visibility = [ ":*" ]
  26. configs = []
  27. # Chromecast executables depend on several shared libraries in
  28. # /oem_cast_shlib, $ORIGIN, and $ORIGIN/lib. Add these rpaths to each binary.
  29. # This is explicitly disabled in Chrome for security reasons (see comments in
  30. # //build/config/gcc/BUILD.gn), but necessary on Chromecast so that OEM's may
  31. # override the default libraries shipped in the Cast receiver package.
  32. if (target_rpath == "") {
  33. ldflags = [
  34. "-Wl,-rpath=/oem_cast_shlib",
  35. "-Wl,-rpath=\$ORIGIN/lib",
  36. "-Wl,-rpath=\$ORIGIN",
  37. ]
  38. } else {
  39. ldflags = [ "-Wl,-rpath=${target_rpath}" ]
  40. }
  41. # Binaries which don't live in the same directory as Chrome component
  42. # libraries may still depend on them. Explicitly add the component library
  43. # directory to the rpath for the component build.
  44. if (is_component_build) {
  45. ldflags += [ "-Wl,-rpath=/system/chrome" ]
  46. }
  47. }
  48. config("executable_config") {
  49. configs = [ ":ldconfig" ]
  50. if (!is_clang && current_cpu == "arm") {
  51. ldflags = [
  52. # Export stdlibc++ and libgcc symbols to force shlibs to refer to these
  53. # symbols from the executable.
  54. "-Wl,--export-dynamic",
  55. "-lm", # stdlibc++ requires math.h
  56. # In case we redefined stdlibc++ symbols (e.g. tc_malloc)
  57. "-Wl,--allow-multiple-definition",
  58. "-Wl,--whole-archive",
  59. "-l:libstdc++.a",
  60. "-l:libgcc.a",
  61. "-Wl,--no-whole-archive",
  62. ]
  63. # Despite including libstdc++/libgcc archives, we still need to specify
  64. # static linking for them in order to prevent the executable from having a
  65. # dynamic dependency on them.
  66. configs += [ ":static_config" ]
  67. }
  68. }
  69. # Shared libaries should not have RPATH or RUNPATH set. This allows the
  70. # shared libs to inherit RPATH from the parent executable that is loading
  71. # the shared library. (See internal b/37514052 for more details.)
  72. config("shared_library_config") {
  73. if (current_cpu == "arm") {
  74. configs = [ ":static_config" ]
  75. }
  76. }