Add exe_and_shlib_deps to executable and shared_library configs
Currently, all executables and shared libraries are expected to add the
exe_and_shlib_deps dependency manually. However, it is easy to forget to do
this. In such cases, the build will likely fail at the link step due to missing
libc++ symbols. It may not be obvious how to fix this issue.
This CL adds exe_and_shlib_deps as an implicit dependency to executable and
shared_library targets so that developers don't have to manually add it.
BUG=845700
R=dpranke
TBR=torne
Change-Id: I30edcf0bcd6559b1aaa211a42863b04bc57d4d99
Reviewed-on: https://chromium-review.googlesource.com/1069720
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561729}
diff --git a/DEPS b/DEPS
index 20451e3..72d922b 100644
--- a/DEPS
+++ b/DEPS
@@ -112,7 +112,7 @@
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling build tools
# and whatever else without interference from each other.
- 'buildtools_revision': '94288c26d2ffe3aec9848c147839afee597acefd',
+ 'buildtools_revision': '893eb86b02b2571894e328f05551112b96df1cce',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling SwiftShader
# and whatever else without interference from each other.
diff --git a/android_webview/test/BUILD.gn b/android_webview/test/BUILD.gn
index fb70948..7936993 100644
--- a/android_webview/test/BUILD.gn
+++ b/android_webview/test/BUILD.gn
@@ -105,6 +105,7 @@
}
shared_library("libstandalonelibwebviewchromium") {
+ testonly = true
sources = [
"../lib/webview_entry_point.cc",
]
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index a0b62e5..93a97ff2 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -634,6 +634,28 @@
}
}
+# Sets default dependencies for executable and shared_library targets.
+#
+# Variables
+# no_default_deps: If true, no standard dependencies will be added.
+foreach(target_type,
+ [
+ "executable",
+ "shared_library",
+ ]) {
+ template(target_type) {
+ target(target_type, target_name) {
+ forward_variables_from(invoker, "*", [ "no_default_deps" ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
+ deps += [ "//build/config:exe_and_shlib_deps" ]
+ }
+ }
+ }
+}
+
# ==============================================================================
# COMPONENT SETUP
# ==============================================================================
@@ -673,13 +695,6 @@
# See http://crbug.com/594610
forward_variables_from(invoker, [ "visibility" ])
forward_variables_from(invoker, "*", [ "visibility" ])
-
- # All shared libraries must have the sanitizer deps to properly link in
- # asan mode (this target will be empty in other cases).
- if (!defined(deps)) {
- deps = []
- }
- deps += [ "//build/config:exe_and_shlib_deps" ]
}
}
diff --git a/chrome/test/data/nacl/BUILD.gn b/chrome/test/data/nacl/BUILD.gn
index dcce8a7..2c14fa3 100644
--- a/chrome/test/data/nacl/BUILD.gn
+++ b/chrome/test/data/nacl/BUILD.gn
@@ -581,6 +581,8 @@
"nonsfi/libc_free.c",
]
+ no_default_deps = true
+
# Here, we would like to link a relocatable, libc-free executable.
# -shared/-fPIC make this binary relocatable. -nostdlib ensures
# this is libc-free.
diff --git a/tools/gn/BUILD.gn b/tools/gn/BUILD.gn
index 31e24936..1e171fa 100644
--- a/tools/gn/BUILD.gn
+++ b/tools/gn/BUILD.gn
@@ -6,8 +6,6 @@
import("//testing/test.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
-defines = [ "GN_BUILD" ]
-
jumbo_static_library("gn_lib") {
configs += [ "//build/config:precompiled_headers" ]
@@ -263,6 +261,7 @@
# of GN over the large Chrome build, you will want to set the arg:
# enable_iterator_debugging = false
executable("gn") {
+ defines = [ "GN_BUILD" ]
sources = [
"gn_main.cc",
]