Skip to content

Commit 7381222

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[build] Don't create a second copy of executables compiled with -fPIC.
build.py -mrelease runtime 4169 -> 2711 build steps Change-Id: I679b2d7b34fd598deffc66e3bf10c48b02e9d764 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398944 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 6338283 commit 7381222

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

build/config/BUILDCONFIG.gn

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -474,24 +474,45 @@ foreach(_target_type,
474474
"executable",
475475
"loadable_module",
476476
]) {
477-
template(_target_type) {
478-
target(_target_type, target_name) {
479-
forward_variables_from(invoker, "*", [ "no_default_deps" ])
480-
if (!defined(deps)) {
481-
deps = []
482-
}
483-
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
484-
if (use_flutter_cxx) {
485-
deps += [ "//third_party/libcxx" ]
477+
if (!is_shared_library) {
478+
template(_target_type) {
479+
target(_target_type, target_name) {
480+
forward_variables_from(invoker, "*", [ "no_default_deps" ])
481+
if (!defined(deps)) {
482+
deps = []
486483
}
487-
if (is_fuchsia) {
488-
deps += [
489-
"//build/fuchsia/config/clang:c++-runtime-deps",
490-
"//third_party/fuchsia/gn-sdk/src/config:runtime_library_group",
491-
]
484+
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
485+
if (use_flutter_cxx) {
486+
deps += [ "//third_party/libcxx" ]
487+
}
488+
if (is_fuchsia) {
489+
deps += [
490+
"//build/fuchsia/config/clang:c++-runtime-deps",
491+
"//third_party/fuchsia/gn-sdk/src/config:runtime_library_group",
492+
]
493+
}
492494
}
493495
}
494496
}
497+
} else {
498+
# Forward to the main toolchain so that
499+
# shared_libary("foo") {
500+
# deps = [ ":bar" ]
501+
# }
502+
# executable("bar") {}
503+
# doesn't create an extra copy of bar.
504+
template(_target_type) {
505+
group(target_name) {
506+
forward_variables_from(invoker,
507+
[
508+
"testonly",
509+
"visibility",
510+
])
511+
not_needed(invoker, "*")
512+
main_toolchain = string_replace(current_toolchain, "_shared", "")
513+
public_deps = [ ":$target_name($main_toolchain)" ]
514+
}
515+
}
495516
}
496517
}
497518

0 commit comments

Comments
 (0)