rust icon indicating copy to clipboard operation
rust copied to clipboard

Build from source in macOS (Intel CPU) failed due to shared lib name mismatch.

Open dskkato opened this issue 4 years ago • 0 comments

Issue

Build from source in macOS (Intel CPU) fails due to name mismatch. The panic from tensorflow-sys crate occurred just after the following log message (see full log message in detail):

 tensorflow-sys/build.rs:388: Copying "/Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/bazel-bin/tensorflow/libtensorflow_framework.dylib.2" to "/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-d8b6f8f1bd59a8f8/out/lib-v2.6.0/libtensorflow_framework.so.2"

There seem to be several issues here when I checked the build directory.

$ ls /Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/bazel-bin/tensorflow/
c                         core                           libtensorflow.dylib            stream_executor
cc                        libtensorflow.2.6.0.dylib      libtensorflow_framework.2.6.0.dylib
compiler                  libtensorflow.2.dylib          libtensorflow_framework.2.dylib
  • src may be libtensorflow_framework.2.dylib, not libtensorflow_framework.dylib.2
  • also, target may be libtensorflow_framework.2.dylib, not libtensorflow_framework.so.2

Build log

build log except for that from bazel
% TF_RUST_BUILD_FROM_SRC=true cargo build
   Compiling tensorflow-sys v0.20.0 (/Users/dskkato/workspace/tensorflow/rust/tensorflow-sys)
warning: use of deprecated associated function `zip::read::ZipFile::<'a>::sanitized_name`: by stripping `..`s from the path, the meaning of paths can change.
                `mangled_name` can be used if this behaviour is desirable
   --> tensorflow-sys/build.rs:153:60
    |
153 |         let output_path = extract_to.as_ref().join(zipfile.sanitized_name());
    |                                                            ^^^^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: `tensorflow-sys` (build script) generated 1 warning
error: failed to run custom build command for `tensorflow-sys v0.20.0 (/Users/dskkato/workspace/tensorflow/rust/tensorflow-sys)`

Caused by:
  process didn't exit successfully: `/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-04dcccf1736c33c1/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=TENSORFLOW_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=TENSORFLOW_STATIC
  cargo:rerun-if-env-changed=TENSORFLOW_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  tensorflow-sys/build.rs:303: output = "/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-d8b6f8f1bd59a8f8/out"
  tensorflow-sys/build.rs:305: source = "/Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0"
  tensorflow-sys/build.rs:307: lib_dir = "/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-d8b6f8f1bd59a8f8/out/lib-v2.6.0"
  tensorflow-sys/build.rs:309: Directory "/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-d8b6f8f1bd59a8f8/out/lib-v2.6.0" already exists
  tensorflow-sys/build.rs:316: framework_library_path = "/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-d8b6f8f1bd59a8f8/out/lib-v2.6.0/libtensorflow_framework.so.2"
  tensorflow-sys/build.rs:319: library_path = "/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-d8b6f8f1bd59a8f8/out/lib-v2.6.0/libtensorflow.so.2"
  tensorflow-sys/build.rs:436: Executing "bazel" "version"
  tensorflow-sys/build.rs:438: Command "bazel" "version" finished successfully
  tensorflow-sys/build.rs:335: framework_target_path = "tensorflow/libtensorflow_framework.dylib.2"
  tensorflow-sys/build.rs:337: target_path = "tensorflow/libtensorflow.so"
  tensorflow-sys/build.rs:420: Executing "bazel" "build" "--jobs=16" "--compilation_mode=opt" "--copt=-march=native" "tensorflow:libtensorflow.dylib"
  tensorflow-sys/build.rs:424: Command "bazel" "build" "--jobs=16" "--compilation_mode=opt" "--copt=-march=native" "tensorflow:libtensorflow.dylib" finished successfully
  tensorflow-sys/build.rs:388: Copying "/Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/bazel-bin/tensorflow/libtensorflow_framework.dylib.2" to "/Users/dskkato/workspace/tensorflow/rust/target/debug/build/tensorflow-sys-d8b6f8f1bd59a8f8/out/lib-v2.6.0/libtensorflow_framework.so.2"

  --- stderr
  Starting local Bazel server and connecting to it...
  INFO: Options provided by the client:
    Inherited 'common' options: --isatty=0 --terminal_columns=80
  INFO: Reading rc options for 'build' from /Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/.bazelrc:
    Inherited 'common' options: --experimental_repo_remote_exec
  INFO: Reading rc options for 'build' from /Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/.bazelrc:
    'build' options: --define framework_shared_object=true --java_toolchain=@tf_toolchains//toolchains/java:tf_java_toolchain --host_java_toolchain=@tf_toolchains//toolchains/java:tf_java_toolchain --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --enable_platform_specific_config --define=with_xla_support=true --config=short_logs --config=v2 --define=no_aws_support=true --define=no_hdfs_support=true
  INFO: Reading rc options for 'build' from /Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/.tf_configure.bazelrc:
    'build' options: --action_env PYTHON_BIN_PATH=/Users/dskkato/.pyenv/versions/3.8.9/bin/python3 --action_env PYTHON_LIB_PATH=/Users/dskkato/.pyenv/versions/3.8.9/lib/python3.8/site-packages --python_path=/Users/dskkato/.pyenv/versions/3.8.9/bin/python3
  INFO: Found applicable config definition build:short_logs in file /Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
  INFO: Found applicable config definition build:v2 in file /Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
  INFO: Found applicable config definition build:macos in file /Users/dskkato/workspace/tensorflow/rust/tensorflow-sys/target/source-v2.6.0/.bazelrc: --apple_platform_type=macos --copt=-DGRPC_BAZEL_BUILD --copt=-w --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include --define=PROTOBUF_INCLUDE_PATH=$(PREFIX)/include --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
  Loading:
  Loading: 0 packages loaded
  DEBUG: /private/var/tmp/_bazel_dskkato/71b3dba988ec5cc1446d12e2ab3f2672/external/tf_runtime/third_party/cuda/dependencies.bzl:51:10: The following command will download NVIDIA proprietary software. By using the software you agree to comply with the terms of the license agreement that accompanies the software. If you do not agree to the terms of the license agreement, do not use the software.
  Analyzing: target //tensorflow:libtensorflow.dylib (1 packages loaded, 0 targets configured)
  Analyzing: target //tensorflow:libtensorflow.dylib (134 packages loaded, 1148 targets configured)
  Analyzing: target //tensorflow:libtensorflow.dylib (179 packages loaded, 12433 targets configured)
  Analyzing: target //tensorflow:libtensorflow.dylib (212 packages loaded, 15514 targets configured)
  Analyzing: target //tensorflow:libtensorflow.dylib (212 packages loaded, 15514 targets configured)
  INFO: Analyzed target //tensorflow:libtensorflow.dylib (216 packages loaded, 21203 targets configured).
  INFO: Found 1 target...

  [0 / 1,794] [Prepa] BazelWorkspaceStatusAction stable-status.txt
  [6,972 / 8,113] checking cached actions
  Target //tensorflow:libtensorflow.dylib up-to-date:
    bazel-bin/tensorflow/libtensorflow.dylib
  INFO: Elapsed time: 14.607s, Critical Path: 1.51s
  INFO: 1 process: 1 internal.
  INFO: Build completed successfully, 1 total action
  INFO: Build completed successfully, 1 total action
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or direct

Build environment:

$ rustc --version --verbose
rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-apple-darwin
release: 1.57.0
LLVM version: 13.0.0

dskkato avatar Jan 04 '22 08:01 dskkato