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 <[email protected]>
---
 classes/bazel.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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
-- 
2.40.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#60027): https://lists.yoctoproject.org/g/yocto/message/60027
Mute This Topic: https://lists.yoctoproject.org/mt/98901626/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to