Thanks, that should work.
If we continue this approach, there are still two questions, how do we
allow the user to choose whether to enable address sanitizer or not? I
guess we can define the CROSSTOOL setting in another directory and use
--crosstool_top to select it, or since crosstool toolchain is selected
by the combination or cpu, compiler and glibc, we can probably give
the particular toolchain a special compiler name so that it can be
also chosen by using --compiler gcc_address_sanitizer, etc. It doesn't
seem to be perfect but it should work.
Then it comes to another problem, how to we manage toolchain settings
inside CROSSTOOL file. At the moment it seems like a lot copy pasting
is inevtiable because we can't inherit another toolchain stetting, so
that if I have a toolchain definition to use clang for normal build,
and I want to introduce another toolchain definition for address
sanitizer, I need to copy the most of clang normal build toolchain and
add a few settings just to turn on address sanitizer, which is
sub-optimimal.