如何强制Bazel将库路径设置为所需路径?

3

假设我们有一个特定的GCC版本,并且想要使用它来构建tensorflow。

我们需要导出必要的内容:

export CC=/opt/gcc-4.9.3/bin/gcc
export CXX=/opt/gcc-4.9.3/bin/g++
export LIBRARY_PATH=/opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64/:$LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64/:$LD_LIBRARY_PATH
bazel build //tensorflow:libtensorflow.so --action_env=LIBRARY_PATH --action_env=LD_LIBRARY_PATH 

我们使用Bazel运行。
 bazel build //tensorflow:libtensorflow.so --action_env=LIBRARY_PATH --action_env=LD_LIBRARY_PATH --verbose_failures
WARNING: Output base '/home/xxx/.cache/bazel/_bazel_xxx/19df47f8ddcc70ebf80eed36c3acb5a1' is on NFS. This may lead to surprising failures and undetermined behavior.
WARNING: /home/xxx/tensorflow/tensorflow/core/BUILD:1787:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/nsync/public' resolves to 'external/nsync/public' not below the relative path of its package 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error might have been caused by the macro implementation in /home/xxx/tensorflow/tensorflow/tensorflow.bzl:1048:30.
INFO: Found 1 target...
ERROR: /home/xxx/.cache/bazel/_bazel_xxx/19df47f8ddcc70ebf80eed36c3acb5a1/external/nasm/BUILD.bazel:8:1: Linking of rule '@nasm//:nasm' failed (Exit 1): crosstool_wrapper_driver_is_not_gcc failed: error executing command
  (cd /home/xxx/.cache/bazel/_bazel_xxx/19df47f8ddcc70ebf80eed36c3acb5a1/execroot/org_tensorflow && \
  exec env - \
    LD_LIBRARY_PATH=:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64 \
    PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin:/var/cfengine/bin:/usr/local/cuda/bin:/home/xxx/.local/bin:/home/xxx/bin \
    PWD=/proc/self/cwd \
  external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -o bazel-out/host/bin/external/nasm/nasm -Wl,-no-as-needed -B/usr/bin/ -pie -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,--gc-sections -Wl,-S -Wl,@bazel-out/host/bin/external/nasm/nasm-2.params).
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
Target //tensorflow:libtensorflow.so failed to build
INFO: Elapsed time: 17.445s, Critical Path: 0.72s

然而它无法检测到我们导出的 -lgcc_s,尽管它存在于我们的 LIBRARY_PATHLD_LIBRARY_PATH 中。那么如何强制将我们的 LIBRARY_PATH 应用于我们的库所依赖的库?

1个回答

1

像这样做 --linkopt=-L/opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64/ 应该可以。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接