2017-09-28 61 views
0

我正在嘗試與bazel交叉編譯。但未能在platform.h致命錯誤'mutex'文件中找不到。我可以用bazel沒有交叉編譯設置,我可以在主機中執行二進制文件。bazel建立aot與cross工具在platform.h中失敗致命錯誤'mutex'文件未找到

我的環境是低於

  • X86-64 ubuntu14.04
  • 目標ARM-Linux的gnueabihf
  • tensorflow:馬斯特cd5f3b67fca88217776522182481b0c128db5af9主管
  • 巴澤勒:0.5.4由易安裝 - 安裝

我的測試代碼如下。

#define EIGEN_USE_THREADS 
#define EIGEN_USE_CUSTOM_THREAD_POOL 

#include <iostream> 
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" 
#include "tensorflow/compiler/aot/tests/test_graph_tfmatmul.h" // generated 

int main(int argc, char** argv) { 
    Eigen::ThreadPool tp(2); // Size the thread pool as appropriate. 
    Eigen::ThreadPoolDevice device(&tp, tp.NumThreads()); 

    foo::bar::MatMulComp matmul; 
    matmul.set_thread_pool(&device); 

    // Set up args and run the computation. 
    const float args[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; 
    std::copy(args + 0, args + 6, matmul.arg0_data()); 
    std::copy(args + 6, args + 12, matmul.arg1_data()); 
    matmul.Run(); 

    // Check result 
    if (matmul.result0(0, 0) == 58) { 
    std::cout << "Success" << std::endl; 
    } else { 
    std::cout << "Failed. Expected value 58 at 0,0. Got:" 
       << matmul.result0(0, 0) << std::endl; 
    } 

    return 0; 
} 

我修改了一些要編譯的文件。

  1. 附加交叉編譯設置到工作區文件

    new_local_repository( name = "linaroLinuxGcc49Repo", build_file = "compilers/linaro_linux_gcc_4.9.BUILD", path = "compilers/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf",)

  2. 添加構建/ tensorflow /編譯器/ AOT /測試設定/ BUILD

    cc_binary( name = "my_binary", srcs = [ "my_code.cc", # include test_graph_tfmatmul.h to access the generated header ], deps = [ ":test_graph_tfmatmul", # link in the generated object file "//third_party/eigen3", ], linkopts = [ "-lpthread", ])

下面是構建我做的命令。

bazel build --copt=-Wno-c++11-narrowing --cxxopt='-std=c++11' //tensorflow/compiler/aot/tests:my_binary [email protected]_tools//tools/cpp:toolchain --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --verbose_failures

最後我得到下面的錯誤。

(root) [email protected]:repo [master]$ bazel build --copt=-Wno-c++11-narrowing --cxxopt='-std=c++11' //tensorflow/compiler/aot/tests:my_binary [email protected]_tools//tools/cpp:toolchain --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --verbose_failures WARNING: /home/user-name/tensorflow/repo/tensorflow/core/BUILD:1772: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/user-name/tensorflow/repo/tensorflow/tensorflow.bzl:1029:30 WARNING: /home/user-name/tensorflow/repo/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately. WARNING: /home/user-name/tensorflow/repo/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately. INFO: Analysed target //tensorflow/compiler/aot/tests:my_binary (0 packages loaded). INFO: Found 1 target... ERROR: /home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/external/nsync/BUILD:397:1: C++ compilation of rule '@nsync//:nsync_cpp' failed (Exit 1): clang failed: error executing command (cd /home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/execroot/org_tensorflow && \ exec env - \ PWD=/proc/self/cwd \ PYTHON_BIN_PATH=/home/user-name/.pyenv/versions/anaconda3-4.4.0/bin/python \ PYTHON_LIB_PATH=/home/user-name/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages \ TF_NEED_CUDA=0 \ TF_NEED_OPENCL=0 \ tools/arm_compiler/linaro_linux_gcc/clang_bin/clang -target armv7a-arm-linux-gnueabif '--sysroot=external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc' '-mfloat-abi=hard' -nostdinc -isystem /usr/lib/clang/3.6/include -isystem external/linaroLinuxGcc49Repo/lib/gcc/arm-linux-gnueabihf/4.9.4/include -isystem external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/usr/include -isystem external/linaroLinuxGcc49Repo/lib/gcc/arm-linux-gnueabihf/4.9.4/include-fixed -isystem external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/usr/include -isystem external/linaroLinuxGcc49Repo/include/c++/4.9.4 -U_FORTIFY_SOURCE -fstack-protector -fPIE '-fdiagnostics-color=always' -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections -Wno-c++11-narrowing -MD -MF bazel-out/clang_linux_armhf-py3-opt/bin/external/nsync/_objs/nsync_cpp/external/nsync/internal/sem_wait.d -iquote external/nsync -iquote bazel-out/clang_linux_armhf-py3-opt/genfiles/external/nsync -iquote external/bazel_tools -iquote bazel-out/clang_linux_armhf-py3-opt/genfiles/external/bazel_tools -isystem external/nsync/public -isystem bazel-out/clang_linux_armhf-py3-opt/genfiles/external/nsync/public -isystem external/bazel_tools/tools/cpp/gcc3 -x c++ '-std=c++11' -DNSYNC_ATOMIC_CPP11 -DNSYNC_USE_CPP11_TIMEPOINT -I./external/nsync//platform/c++11 -I./external/nsync//platform/gcc -I./external/nsync//platform/arm -I./external/nsync//public -I./external/nsync//internal -I./external/nsync//platform/posix '-D_POSIX_C_SOURCE=200809L' -pthread -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/nsync/internal/sem_wait.c -o bazel-out/clang_linux_armhf-py3-opt/bin/external/nsync/_objs/nsync_cpp/external/nsync/internal/sem_wait.o) warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option] warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option] In file included from external/nsync/internal/sem_wait.c:16: ./external/nsync//platform/c++11/platform.h:29:10: fatal error: 'mutex' file not found #include ^2 warnings and 1 error generated. Target //tensorflow/compiler/aot/tests:my_binary failed to build INFO: Elapsed time: 0.917s, Critical Path: 0.15s FAILED: Build did NOT complete successfully

錯誤occures在 「規則的C++彙編 '@nsync //:nsync_cpp' 失敗(退出1):」。

的Befause 「./external/nsync//platform/c++11/platform.h:29:10:致命錯誤:未找到 '互斥' 文件 的#include 」

文件互斥存在於./compilers/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/4.9.4/mutex中。

我覺得上面的路徑在構建輸出線設置好的「-isystem外部/ linaroLinuxGcc49Repo /包括/ C++/4.9.4」

我怎麼能設置路徑互斥?用於交叉編譯nsync?

回答

相關問題