py-tensorflow: fix linking with ubuntu's gcc (#45437)

gcc on ubuntu has fix-cortex-a53-843419 set by default - this causes linking
issues (symbol relocation errors) for tf, even when compiling for different
cpus.
This commit is contained in:
Andrew W Elble 2024-09-25 09:19:58 -04:00 committed by GitHub
parent a342da5642
commit fd087107ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -452,6 +452,22 @@ class PyTensorflow(Package, CudaPackage, ROCmPackage, PythonExtension):
)
phases = ["configure", "build", "install"]
def flag_handler(self, name, flags):
spec = self.spec
# ubuntu gcc has this workaround turned on by default in aarch64
# and it causes issues with symbol relocation during link
# note, archspec doesn't currently ever report cortex_a53!
if (
name == "ldflags"
and spec.target.family == "aarch64"
and "ubuntu" in spec.os
and spec.compiler.name == "gcc"
and "cortex_a53" not in spec.target.name
):
flags.append("-mno-fix-cortex-a53-843419")
return (flags, None, None)
# https://www.tensorflow.org/install/source
def setup_build_environment(self, env):
spec = self.spec