[meta-tensorflow][PATCH 2/25] bazel-native: 0.21.0 -> 3.1.0


hongxu
 

Rebase patches to 3.1.0:
- 0001-HttpDownloader-save-download-tarball-to-distdir.patch
- 0001-fix-unzip-command-not-found.patch
- 0001-python3.patch

Drop backport patch:
- 0001-Rename-gettid-functions.patch

Tweak options according to [1]
[1] https://docs.bazel.build/versions/master/install-compile-source.html#bootstrap-unix-bootstrap

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
...native_0.21.0.bb => bazel-native_3.1.0.bb} | 7 +-
...der-save-download-tarball-to-distdir.patch | 119 ++++++++++--------
.../files/0001-Rename-gettid-functions.patch | 65 ----------
.../0001-fix-unzip-command-not-found.patch | 20 +--
.../bazel/files/0001-python3.patch | 32 ++---
5 files changed, 95 insertions(+), 148 deletions(-)
rename recipes-devtools/bazel/{bazel-native_0.21.0.bb => bazel-native_3.1.0.bb} (77%)
delete mode 100644 recipes-devtools/bazel/files/0001-Rename-gettid-functions.patch

diff --git a/recipes-devtools/bazel/bazel-native_0.21.0.bb b/recipes-devtools/bazel/bazel-native_3.1.0.bb
similarity index 77%
rename from recipes-devtools/bazel/bazel-native_0.21.0.bb
rename to recipes-devtools/bazel/bazel-native_3.1.0.bb
index f1baa33..f3efde1 100644
--- a/recipes-devtools/bazel/bazel-native_0.21.0.bb
+++ b/recipes-devtools/bazel/bazel-native_3.1.0.bb
@@ -2,12 +2,11 @@ DESCRIPTION = "Bazel build and test tool"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"

-SRC_URI[md5sum] = "8c8240b178a35c0f3c1bc03017550270"
-SRC_URI[sha256sum] = "6ccb831e683179e0cfb351cb11ea297b4db48f9eab987601c038aa0f83037db4"
+SRC_URI[md5sum] = "381ca27503c566ce5e489d1ba07d1d25"
+SRC_URI[sha256sum] = "d7f40d0cac95a06cea6cb5b7f7769085257caebc3ee84269dd9298da760d5615"

SRC_URI = "https://github.com/bazelbuild/bazel/releases/download/${PV}/bazel-${PV}-dist.zip \
file://0001-HttpDownloader-save-download-tarball-to-distdir.patch \
- file://0001-Rename-gettid-functions.patch \
file://0001-fix-unzip-command-not-found.patch \
file://0001-python3.patch \
"
@@ -30,7 +29,7 @@ do_compile () {
export JAVA_HOME="${STAGING_LIBDIR_NATIVE}/jvm/openjdk-8-native"
TMPDIR="${TOPDIR}/bazel" \
VERBOSE=yes \
- EXTRA_BAZEL_ARGS="--distdir=${TS_DL_DIR} --python_path=python3" \
+ EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk --python_path=python3" \
./compile.sh
}

diff --git a/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch b/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch
index 605756a..cdc270d 100644
--- a/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch
+++ b/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch
@@ -1,6 +1,6 @@
-From e31a37bc9cb53de5085e885b190652f994209cf6 Mon Sep 17 00:00:00 2001
+From 7225fc4a62a06b654fe7d04a2446a594888a7b8c Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
-Date: Tue, 23 Apr 2019 05:21:40 -0400
+Date: Tue, 8 Dec 2020 10:58:52 +0800
Subject: [PATCH] HttpDownloader: save download tarball to distdir

It is helpful for collecting tarball url which supports offline build.
@@ -9,62 +9,75 @@ Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
- .../repository/downloader/HttpDownloader.java | 50 ++++++++++++++--------
- 1 file changed, 32 insertions(+), 18 deletions(-)
+ .../downloader/DownloadManager.java | 62 ++++++++++++-------
+ 1 file changed, 38 insertions(+), 24 deletions(-)

-diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java
-index 18d10d2..cf71ac4 100755
---- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java
-+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java
-@@ -204,26 +204,29 @@ public class HttpDownloader {
+diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java
+index a89077e..ccaadb3 100755
+--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java
++++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java
+@@ -152,33 +152,36 @@ public class DownloadManager {
+ } else if (!dir.isDirectory()) {
eventHandler.handle(Event.warn("distdir " + dir + " is not a directory"));
} else {
- boolean match = false;
-- Path candidate = dir.getRelative(destination.getBaseName());
-- try {
-- match = RepositoryCache.getChecksum(KeyType.SHA256, candidate).equals(sha256);
-- } catch (IOException e) {
-- // Not finding anything in a distdir is a normal case, so handle it absolutely
-- // quietly. In fact, it is not uncommon to specify a whole list of dist dirs,
-- // with the asumption that only one will contain an entry.
-- }
-- if (match) {
-- if (isCachingByProvidedSha256) {
-- try {
-- repositoryCache.put(sha256, candidate, KeyType.SHA256);
-- } catch (IOException e) {
-- eventHandler.handle(
-- Event.warn("Failed to copy " + candidate + " to repository cache: " + e));
-+ String[] basenames = {destination.getBaseName(), destination.getBaseName()+"_"+sha256};
-+ for (String basename: basenames) {
-+ Path candidate = dir.getRelative(basename);
-+ try {
-+ match = RepositoryCache.getChecksum(KeyType.SHA256, candidate).equals(sha256);
-+ } catch (IOException e) {
-+ // Not finding anything in a distdir is a normal case, so handle it absolutely
-+ // quietly. In fact, it is not uncommon to specify a whole list of dist dirs,
-+ // with the asumption that only one will contain an entry.
-+ }
-+ if (match) {
-+ if (isCachingByProvidedSha256) {
-+ try {
-+ repositoryCache.put(sha256, candidate, KeyType.SHA256);
-+ } catch (IOException e) {
-+ eventHandler.handle(
-+ Event.warn("Failed to copy " + candidate + " to repository cache: " + e));
-+ }
+- for (String name : candidateFileNames) {
++ for (String candidateFileName : candidateFileNames) {
+ boolean match = false;
+- Path candidate = dir.getRelative(name);
+- try {
+- eventHandler.post(
+- new CacheProgress(
+- mainUrl.toString(), "Checking " + cacheKeyType + " of " + candidate));
+- match = RepositoryCache.getChecksum(cacheKeyType, candidate).equals(cacheKey);
+- } catch (IOException e) {
+- // Not finding anything in a distdir is a normal case, so handle it absolutely
+- // quietly. In fact, it is common to specify a whole list of dist dirs,
+- // with the assumption that only one will contain an entry.
+- } finally {
+- eventHandler.post(new CacheProgress(mainUrl.toString()));
+- }
+- if (match) {
+- if (isCachingByProvidedChecksum) {
+- try {
+- repositoryCache.put(cacheKey, candidate, cacheKeyType, canonicalId);
+- } catch (IOException e) {
+- eventHandler.handle(
+- Event.warn("Failed to copy " + candidate + " to repository cache: " + e));
++ String[] names = {candidateFileName, candidateFileName+"_"+cacheKey};
++ for (String name: names) {
++ Path candidate = dir.getRelative(name);
++ try {
++ eventHandler.post(
++ new CacheProgress(
++ mainUrl.toString(), "Checking " + cacheKeyType + " of " + candidate));
++ match = RepositoryCache.getChecksum(cacheKeyType, candidate).equals(cacheKey);
++ } catch (IOException e) {
++ // Not finding anything in a distdir is a normal case, so handle it absolutely
++ // quietly. In fact, it is common to specify a whole list of dist dirs,
++ // with the assumption that only one will contain an entry.
++ } finally {
++ eventHandler.post(new CacheProgress(mainUrl.toString()));
++ }
++ if (match) {
++ if (isCachingByProvidedChecksum) {
++ try {
++ repositoryCache.put(cacheKey, candidate, cacheKeyType, canonicalId);
++ } catch (IOException e) {
++ eventHandler.handle(
++ Event.warn("Failed to copy " + candidate + " to repository cache: " + e));
++ }
+ }
++ FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory());
++ FileSystemUtils.copyFile(candidate, destination);
++ return destination;
}
-+ FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory());
-+ FileSystemUtils.copyFile(candidate, destination);
-+ return destination;
+- FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory());
+- FileSystemUtils.copyFile(candidate, destination);
+- return destination;
}
-- FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory());
-- FileSystemUtils.copyFile(candidate, destination);
-- return destination;
}
}
- }
-@@ -264,6 +267,17 @@ public class HttpDownloader {
+@@ -200,6 +203,17 @@ public class DownloadManager {
eventHandler.handle(Event.info("SHA256 (" + urls.get(0) + ") = " + newSha256));
}

@@ -73,7 +86,7 @@ index 18d10d2..cf71ac4 100755
+ FileSystemUtils.createDirectoryAndParents(dir);
+
+ if (dir.isDirectory()) {
-+ Path dl_mirror = dir.getRelative(destination.getBaseName()+"_"+sha256);
++ Path dl_mirror = dir.getRelative(destination.getBaseName()+"_"+checksum.get().toString());
+ if (!dl_mirror.exists())
+ FileSystemUtils.copyFile(destination, dl_mirror);
+ }
@@ -83,5 +96,5 @@ index 18d10d2..cf71ac4 100755
}

--
-2.8.1
+2.18.2

diff --git a/recipes-devtools/bazel/files/0001-Rename-gettid-functions.patch b/recipes-devtools/bazel/files/0001-Rename-gettid-functions.patch
deleted file mode 100644
index ca37531..0000000
--- a/recipes-devtools/bazel/files/0001-Rename-gettid-functions.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From a0b885aeb95a7ae9e93aea303a1edde74f71edac Mon Sep 17 00:00:00 2001
-From: Hongxu Jia <hongxu.jia@windriver.com>
-Date: Fri, 3 Apr 2020 10:25:49 +0800
-Subject: [PATCH] Rename gettid() functions.
-
-glibc 2.30 will declare its own gettid; see
-https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92.
-Rename the grpc versions to avoid naming conflicts.
-
-Signed-off-by: Benjamin Peterson <benjamin@dropbox.com>
-Upstream-Status: Backport [https://github.com/grpc/grpc/commit/57586a1ca7f17b1916aed3dea4ff8de872dbf853]
-
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- third_party/grpc/src/core/support/log_linux.c | 4 ++--
- third_party/grpc/src/core/support/log_posix.c | 4 ++--
- 2 files changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/third_party/grpc/src/core/support/log_linux.c b/third_party/grpc/src/core/support/log_linux.c
-index 93a0c1b..367c921 100755
---- a/third_party/grpc/src/core/support/log_linux.c
-+++ b/third_party/grpc/src/core/support/log_linux.c
-@@ -54,7 +54,7 @@
- #include <sys/syscall.h>
- #include <unistd.h>
-
--static long gettid(void) { return syscall(__NR_gettid); }
-+static long sys_gettid(void) { return syscall(__NR_gettid); }
-
- void gpr_log(const char *file, int line, gpr_log_severity severity,
- const char *format, ...) {
-@@ -95,7 +95,7 @@ void gpr_default_log(gpr_log_func_args *args) {
-
- gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]",
- gpr_log_severity_string(args->severity), time_buffer,
-- (int)(now.tv_nsec), gettid(), display_file, args->line);
-+ (int)(now.tv_nsec), sys_gettid(), display_file, args->line);
-
- fprintf(stderr, "%-60s %s\n", prefix, args->message);
- gpr_free(prefix);
-diff --git a/third_party/grpc/src/core/support/log_posix.c b/third_party/grpc/src/core/support/log_posix.c
-index 3ff171f..f0420a7 100755
---- a/third_party/grpc/src/core/support/log_posix.c
-+++ b/third_party/grpc/src/core/support/log_posix.c
-@@ -45,7 +45,7 @@
- #include <time.h>
- #include <pthread.h>
-
--static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
-+static intptr_t sys_gettid(void) { return (intptr_t)pthread_self(); }
-
- void gpr_log(const char *file, int line, gpr_log_severity severity,
- const char *format, ...) {
-@@ -95,7 +95,7 @@ void gpr_default_log(gpr_log_func_args *args) {
-
- fprintf(stderr, "%s%s.%09d %7tu %s:%d] %s\n",
- gpr_log_severity_string(args->severity), time_buffer,
-- (int)(now.tv_nsec), gettid(), display_file, args->line,
-+ (int)(now.tv_nsec), sys_gettid(), display_file, args->line,
- args->message);
- }
-
---
-2.17.1
-
diff --git a/recipes-devtools/bazel/files/0001-fix-unzip-command-not-found.patch b/recipes-devtools/bazel/files/0001-fix-unzip-command-not-found.patch
index 9fc7f03..eccc34a 100644
--- a/recipes-devtools/bazel/files/0001-fix-unzip-command-not-found.patch
+++ b/recipes-devtools/bazel/files/0001-fix-unzip-command-not-found.patch
@@ -1,6 +1,6 @@
-From e00e75dc8bc3c1153633e1ba7cb98a0a58658e86 Mon Sep 17 00:00:00 2001
+From 23e2aff67a03127572641c7286e306c2a20990e2 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
-Date: Sat, 4 Apr 2020 12:48:01 +0800
+Date: Tue, 8 Dec 2020 11:05:13 +0800
Subject: [PATCH] fix unzip: command not found

If host does not provide unzip, build bazel will fail even though
@@ -18,18 +18,18 @@ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
-index fc4aad75..e1686732 100755
+index 16252df..e7cd609 100755
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
-@@ -420,7 +420,7 @@ public class BazelRuleClassProvider {
- // from the local machine. For now, this can be overridden with --action_env=PATH=<value>, so
- // at least there's a workaround.
- if (os != OS.WINDOWS) {
-- return "/bin:/usr/bin";
+@@ -469,7 +469,7 @@ public class BazelRuleClassProvider {
+ // Note that --action_env does not propagate to the host config, so it is not a viable
+ // workaround when a genrule is itself built in the host config (e.g. nested genrules). See
+ // #8536.
+- return "/bin:/usr/bin:/usr/local/bin";
+ return System.getenv("PATH");
}

- // Attempt to compute the MSYS root (the real Windows path of "/") from `sh`.
+ String newPath = "";
--
-2.17.1
+2.18.2

diff --git a/recipes-devtools/bazel/files/0001-python3.patch b/recipes-devtools/bazel/files/0001-python3.patch
index 50eaaf4..93eee2d 100644
--- a/recipes-devtools/bazel/files/0001-python3.patch
+++ b/recipes-devtools/bazel/files/0001-python3.patch
@@ -1,6 +1,6 @@
-From f3dcad42a53e78efdb87adbc98121dc66b53ec5f Mon Sep 17 00:00:00 2001
+From e43263d6163f7ba1622b268e93635bf42493f758 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
-Date: Sun, 5 Apr 2020 23:40:31 +0800
+Date: Tue, 8 Dec 2020 11:09:44 +0800
Subject: [PATCH] set python3 interpreter

Since many distrobution choose python3, and drop python2,
@@ -20,28 +20,28 @@ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
-index 0ff5d15..997cfc9 100755
+index 2c0ae4d..ae39cc9 100755
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java
-@@ -185,7 +185,7 @@ public class BazelPythonSemantics implements PythonSemantics {
- .addOutput(executable)
- .setShellCommand(
- shExecutable,
-- "echo '#!/usr/bin/env python' | cat - "
-+ "echo '#!/usr/bin/env python3' | cat - "
- + zipFile.getExecPathString()
- + " > "
- + executable.getExecPathString())
+@@ -237,7 +237,7 @@ public class BazelPythonSemantics implements PythonSemantics {
+ PathFragment shExecutable = ShToolchain.getPathOrError(ruleContext);
+ // TODO(#8685): Remove this special-case handling as part of making the proper shebang a
+ // property of the Python toolchain configuration.
+- String pythonExecutableName = OS.getCurrent() == OS.OPENBSD ? "python3" : "python";
++ String pythonExecutableName = OS.getCurrent() == OS.OPENBSD ? "python3" : "python3";
+ ruleContext.registerAction(
+ new SpawnAction.Builder()
+ .addInput(zipFile)
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt
-index 129ce90..959e3a5 100755
+index 59c00e8..31d29a4 100755
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3

- import os
- import re
+ from __future__ import absolute_import
+ from __future__ import division
--
-2.17.1
+2.18.2

--
2.21.0

Join yocto@lists.yoctoproject.org to automatically receive all group messages.