diff mbox series

[meta-tensorflow] bazel.bbclass: Fix build with bazel from sstate-cache

Message ID 20230515115507.9216-1-tomasz.dziendzielski@gmail.com
State New
Headers show
Series [meta-tensorflow] bazel.bbclass: Fix build with bazel from sstate-cache | expand

Commit Message

Tomasz Dziendzielski May 15, 2023, 11:55 a.m. UTC
Random errors can occur when bazel is taken from sstate-cache and the
dynamic loader is no longer available. Setting DYNAMIC_LOADER and
letting populate_sysroot_setscene modify the UNINATIVE_LOADER is not
enough. That way we just modify the loader of bazel binary, but bazel is
also a self-extracting zip file with built-in binaries that need
dynamic loader modification to work.

Eample error, as you can see it's quite misleading:
| An error occurred during the fetch of repository 'local_config_cuda'
| Cuda Configuration Error: Invalid cpu_value
| Skipping 'tensorflow/lite/tools/benchmark:benchmark_model': no such package '@local_config_cuda//cuda

To fix this in do_configure execute bazel version to unpack
output_user_root and run patchelf-uninative on the ELF executables. Then
change modification time to some future date so that bazel does not see
the modification.

Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
---
 classes/bazel.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Tomasz Dziendzielski July 11, 2023, 8:55 a.m. UTC | #1
Hi Hongxu,
I can see you disabled the uninative back in the bazel-native recipe. Can
you please provide steps to reproduce the "bazel/bazel.real: Input/output
error" so we could investigate why it happens? Disabling uninative will
cause the failure if bazel is taken from sstate-cache.

Best regards,
Tomasz Dziendzielski
Jia, Hongxu July 12, 2023, 2:54 a.m. UTC | #2
On 7/11/23 16:55, Tomasz Dziendzielski wrote:
> **
> *CAUTION: This email comes from a non Wind River email account!*
> Do not click links or open attachments unless you recognize the sender 
> and know the content is safe.
> Hi Hongxu,
> I can see you disabled the uninative back in the bazel-native recipe. 
> Can you please provide steps to reproduce the "bazel/bazel.real: 
> Input/output error" so we could investigate why it happens? Disabling 
> uninative will cause the failure if bazel is taken from sstate-cache.
>
It is not reproducible always, but be reproducible on specific build 
host, it seems gcc tool chain or libc related I guess

//Hongxu


> Best regards,
> Tomasz Dziendzielski
diff mbox series

Patch

diff --git a/classes/bazel.bbclass b/classes/bazel.bbclass
index be436ec..316dc3d 100644
--- a/classes/bazel.bbclass
+++ b/classes/bazel.bbclass
@@ -129,6 +129,18 @@  build --linkopt=-Wl,-latomic
 EOF
 
     sed -i "s:${WORKDIR}:${BAZEL_OUTPUTBASE_DIR}/external/yocto_compiler:g" ${S}/bazelrc
+
+    # Unzip bazel packages
+    ${BAZEL} ${BAZEL_STARTUP_OPTIONS} version
+
+    for binary in build-runfiles daemonize linux-sandbox process-wrapper; do
+        # Modify interpreter for bazel built-in binaries
+        patchelf-uninative --set-interpreter "${UNINATIVE_LOADER}" ${BAZEL_DIR}/user_root/install/*/$binary
+
+        # Set modification time somewhere in the future to avoid "corrupt installation: file PATH is missing or modified"
+        # in this case modification is required for successful build
+        touch -m -t 203712120101 ${BAZEL_DIR}/user_root/install/*/$binary
+    done
 }
 
 EXPORT_FUNCTIONS do_configure