[native] Change name of static libraries in some cases #9135
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The native runtime is subdivided into a collection of static libraries,
linked into the target shared library based on a set of conditions.
Some static libraries are "private" and aren't copied to packages, but
some are "public" in that they can be shipped in our nugets (when
dynamic runtime linking at app build time is implemented). At the same
time, we have several build configurations which differ in their build
and link configurations, and especially in whether or not they link
against the shared C++ standard library or not. In particular, the ASAN
and UBSAN builds require enabling of exceptions, RTTI and linking
against the shared C++ library.
Static component libraries will be built with the same set of
compilation and linking flags, and without modifying their output names
in some way, they may result in linking errors similar to:
This kind of errors may not show during the very first build of the
repository, but it will show on any subsequent build since the static
component library name used by all the configurations is the same,
but the compilation and linking flags are different. If, e.g., UBSAN
build follows the standard build, it will replace the previously built
library with its own version but different linking requirements.
Subsequent build of non-UBSAN version of library will try to use the
static component library built with UBSAN flags, resulting in the
linking error above.
In order to avoid this kind of confusion but also minimize the number of
branches in CMake script files, this commit simply makes sure that all
the relevant static component libraries use an optional suffix when
generating their output. By default the suffix is empty, resulting in
e.g.
libruntime-base.a
, but with UBSAN enabled, it will producelibruntime-base-ubsan.a
thus making sure the builds don't step on eachother's toes.