Add patch to fix bazel build on power9 (#20512)

* fix bazel on power9

* small fix in tensorflow package

* removed import not needed anymore
This commit is contained in:
Harsh Bhatia 2020-12-22 14:50:03 -08:00 committed by GitHub
parent 5f2a821183
commit a93f6ca619
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 0 deletions

View file

@ -0,0 +1,61 @@
From 9c9d27561780bc56d9f0867e325c7421a94ee1cb Mon Sep 17 00:00:00 2001
From: Harsh Bhatia <bhatia4@llnl.gov>
Date: Tue, 15 Dec 2020 15:56:10 -0800
Subject: [PATCH] https://github.com/bazelbuild/bazel/commit/ab62a6e097590dac5ec946ad7a796ea0e8593ae0
---
src/conditions/BUILD | 6 ++++++
third_party/BUILD | 8 ++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/conditions/BUILD b/src/conditions/BUILD
index 2b28e28057..faa41a439d 100644
--- a/src/conditions/BUILD
+++ b/src/conditions/BUILD
@@ -10,6 +10,12 @@ filegroup(
visibility = ["//src:__pkg__"],
)
+config_setting(
+ name = "linux_ppc",
+ values = {"cpu": "ppc"},
+ visibility = ["//visibility:public"],
+)
+
config_setting(
name = "linux_x86_64",
values = {"cpu": "k8"},
diff --git a/third_party/BUILD b/third_party/BUILD
index 159006d741..4fcae54c00 100644
--- a/third_party/BUILD
+++ b/third_party/BUILD
@@ -523,12 +523,13 @@ UNNECESSARY_DYNAMIC_LIBRARIES = select({
"//src/conditions:darwin": "*.so *.dll",
"//src/conditions:darwin_x86_64": "*.so *.dll",
"//src/conditions:linux_x86_64": "*.jnilib *.dll",
+ "//src/conditions:linux_ppc": "*.so *.jnilib *.dll",
# The .so file is an x86 one, so we can just remove it if the CPU is not x86
"//src/conditions:arm": "*.so *.jnilib *.dll",
"//src/conditions:linux_aarch64": "*.so *.jnilib *.dll",
# Play it safe -- better have a big binary than a slow binary
# zip -d does require an argument. Supply something bogus.
- "//conditions:default": "*.bogusextension",
+ "//conditions:default": "",
})
# Remove native libraries that are for a platform different from the one we are
@@ -537,7 +538,10 @@ genrule(
name = "filter_netty_dynamic_libs",
srcs = ["netty_tcnative/netty-tcnative-boringssl-static-2.0.24.Final.jar"],
outs = ["netty_tcnative/netty-tcnative-filtered.jar"],
- cmd = "cp $< $@ && zip -qd $@ " + UNNECESSARY_DYNAMIC_LIBRARIES,
+ cmd = "cp $< $@ && " +
+ # End successfully if there is nothing to be deleted from the archive
+ "if [ -n '" + UNNECESSARY_DYNAMIC_LIBRARIES + "' ]; then " +
+ "zip -qd $@ " + UNNECESSARY_DYNAMIC_LIBRARIES + "; fi",
)
java_import(
--
2.21.0 (Apple Git-122.2)

View file

@ -108,6 +108,11 @@ class Bazel(Package):
depends_on('python', type=('build', 'run')) depends_on('python', type=('build', 'run'))
depends_on('zip', when='platform=linux', type=('build', 'run')) depends_on('zip', when='platform=linux', type=('build', 'run'))
# make work on power9 (2x commits)
# https://github.com/bazelbuild/bazel/commit/5cff4f1edf8b95bf0612791632255852332f72b5
# https://github.com/bazelbuild/bazel/commit/ab62a6e097590dac5ec946ad7a796ea0e8593ae0
patch('linux_ppc-0.29.1.patch', when='@0.29.1')
# Pass Spack environment variables to the build # Pass Spack environment variables to the build
patch('bazelruleclassprovider-0.25.patch', when='@0.25:') patch('bazelruleclassprovider-0.25.patch', when='@0.25:')
patch('bazelruleclassprovider-0.14.patch', when='@0.14:0.24') patch('bazelruleclassprovider-0.14.patch', when='@0.14:0.24')
@ -163,6 +168,11 @@ def url_for_version(self, version):
return url.format(version) return url.format(version)
def setup_build_environment(self, env): def setup_build_environment(self, env):
# fix the broken linking (on power9)
# https://github.com/bazelbuild/bazel/issues/10327
env.set('BAZEL_LINKOPTS', '')
env.set('BAZEL_LINKLIBS', '-lstdc++')
env.set('EXTRA_BAZEL_ARGS', env.set('EXTRA_BAZEL_ARGS',
# Spack's logs don't handle colored output well # Spack's logs don't handle colored output well
'--color=no --host_javabase=@local_jdk//:jdk' '--color=no --host_javabase=@local_jdk//:jdk'