Fix LLVM target detection when cross-compiling. #57182
Merged
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.
Conditions like @bazel_tools//src/conditions:linux_aarch64 do not
appear to be triggered correctly when cross-compiling on Linux. I'm
guessing this is because TensorFlow does not yet use Bazel platforms and
instead uses the older --cpu and --crosstool_top features.
This means that we fall through to the default condition and end up
building an x86-targeting LLVM even though we intended to target, say,
aarch64. The symptom this causes is errors like:
'neoverse-n1' is not a recognized processor for this target (ignoring
processor)
'+neon' is not a recognized feature for this target (ignoring feature)
'+fp-armv8' is not a recognized feature for this target (ignoring
feature)
'+crypto' is not a recognized feature for this target (ignoring feature)
'+lse' is not a recognized feature for this target (ignoring feature)
'+crc' is not a recognized feature for this target (ignoring feature)
from XLA:CPU compilation.
Take the same approach that has previously been used for Darwin ARM64
builds and add a new config_setting() for LLVM architecture detection
that mirrors the definitions in //tensorflow/BUILD.
Change tested both under x86->aarch64 cross compilation and aarch64
self-hosted compilation.