As discussed in https://groups.google.com/a/chromium.org/d/msg/gn-dev/bbOBxxheLgc/NTkliYHAFAAJ, linking a complete static library on Mac using libtool may cause issue as only the base name is used when packing the object file in the library (e.g. obj/net/net/url_util.o and obj/url/url/url_util.o have the same short name url_util.o).
Ensuring that there are no object files with the same short name is difficult (as some of the file may come from third_party project). The other usual recommendation is to avoid large static library.
I propose instead that the link tool for "static_library" pattern is passed an extra argument "complete" that is set to 1 or 0 depending on whether "complete_static_lib" is true or not.
Then each tool can decide how to deal with linking complete static libraries. According to the thread mentioned, "ar" on Linux supports identical base names, so it ignore the flag. On Mac, libtool warns, so the input file name are mangled while linking them by using a wrapper around libtool.
So, the following target:
static_library("stlib") {
sources = [
"//foo/source.c"
]
complete_static_lib = true
}
would correspond to the following ninja code:
build obj/foo/libstdlib.a: alink obj/foo/source.o
complete = 1
arflags =
output_extension =
output_dir =
Comment 1 by sdefresne@chromium.org
, Jul 26 2016