源码编译bazel

由于公司不能连接外网,且还要在飞腾、龙芯上安装、因此源码编译tensorflow,但编译tensorflow要用bazel工具包来进行编译,因此要首先编译安装bazel。

开始报了很多错误,由于公司只有我一个人在做这一块,也解决了很长时间。直奔主题

下载apt-get install build-essential openjdk-8-jdk python zip unzip

root@251e58a468aa:/opt/soft/bazelpack/bazel10# ./compile.sh
?  Building Bazel from scratch......
?  Building Bazel with Bazel.
WARNING: /tmp/bazel_0TCQ69sS/out/external/bazel_tools/WORKSPACE:1: Workspace name in /tmp/bazel_0TCQ69sS/out/external/bazel_tools/WORKSPACE (@io_bazel) does not match the name given in the repository's definition (@bazel_tools); this will cause a build error in future versions
INFO: Analysed target //src:bazel (179 packages loaded).
INFO: Found 1 target...
INFO: From Compiling src/main/cpp/blaze_util_posix.cc:
src/main/cpp/blaze_util_posix.cc: In function 'void blaze::Daemonize(const char*)':
src/main/cpp/blaze_util_posix.cc:225:28: warning: ignoring return value of 'int dup(int)', declared with attribute warn_unused_result [-Wunused-result]
   (void) dup(STDOUT_FILENO);  // stderr (2>&1)
                            ^
src/main/cpp/blaze_util_posix.cc: In function 'void blaze::DieAfterFork(const char*)':
src/main/cpp/blaze_util_posix.cc:272:49: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
   write(STDERR_FILENO, message, strlen(message));  // strlen should be OK
                                                 ^
src/main/cpp/blaze_util_posix.cc:273:32: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
   write(STDERR_FILENO, ": ", 2);
                                ^
src/main/cpp/blaze_util_posix.cc:274:59: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
   write(STDERR_FILENO, error_string, strlen(error_string));
                                                           ^
src/main/cpp/blaze_util_posix.cc:275:32: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
   write(STDERR_FILENO, "\n", 1);
                                ^
src/main/cpp/blaze_util_posix.cc: In function 'uint64_t blaze::AcquireLock(const string&, bool, bool, blaze::BlazeLock*)':
src/main/cpp/blaze_util_posix.cc:669:30: warning: ignoring return value of 'int ftruncate(int, __off_t)', declared with attribute warn_unused_result [-Wunused-result]
   (void) ftruncate(lockfd, 0);
                              ^
INFO: From Generating Java (Immutable) proto_library @googleapis//:google_bytestream_bytestream_proto:
google/bytestream/bytestream.proto: warning: Import google/protobuf/wrappers.proto but not used.
INFO: From Generating Java (Immutable) proto_library @googleapis//:google_watch_v1_proto:
google/watcher/v1/watch.proto: warning: Import google/protobuf/empty.proto but not used.
INFO: From Generating Java (Immutable) proto_library @googleapis//:google_devtools_build_v1_build_events_proto:
google/devtools/build/v1/build_events.proto: warning: Import google/rpc/status.proto but not used.
INFO: From Executing genrule //tools/jdk:gen_platformclasspath [for host]:
Note: tools/jdk/DumpPlatformClassPath.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
INFO: From Linking third_party/grpc/grpc-java-plugin [for host]:
Erratum 843419 found and fixed at "bazel-out/host/bin/third_party/protobuf/3.4.0/_objs/protobuf_lite/third_party/protobuf/3.4.0/src/google/protobuf/extension_set.o", section 358, offset 0x00000000.
Erratum 843419 found and fixed at "bazel-out/host/bin/third_party/protobuf/3.4.0/_objs/protobuf_lite/third_party/protobuf/3.4.0/src/google/protobuf/extension_set.o", section 358, offset 0x00000000.
INFO: From SkylarkAction external/googleapis/google_bytestream_bytestream_java_grpc_srcs.jar:
google/bytestream/bytestream.proto: warning: Import google/protobuf/wrappers.proto but not used.
INFO: From SkylarkAction external/googleapis/google_watch_v1_java_grpc_srcs.jar:
google/watcher/v1/watch.proto: warning: Import google/protobuf/empty.proto but not used.
INFO: From JavacBootstrap src/java_tools/buildjar/java/com/google/devtools/build/buildjar/libbootstrap_JarOwner.jar [for host]:
warning: Implicitly compiled files were not subject to annotation processing.
  Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation.
1 warning
INFO: From JavacBootstrap src/main/java/com/google/devtools/build/lib/shell/libshell-skylark.jar [for host]:
warning: Implicitly compiled files were not subject to annotation processing.
  Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation.
1 warning
INFO: From JavacBootstrap src/java_tools/singlejar/java/com/google/devtools/build/singlejar/libbootstrap.jar [for host]:
warning: Implicitly compiled files were not subject to annotation processing.
  Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation.
1 warning
INFO: From JavacBootstrap src/java_tools/buildjar/java/com/google/devtools/build/buildjar/libskylark-deps.jar [for host]:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
INFO: From JavacBootstrap src/java_tools/buildjar/java/com/google/devtools/build/buildjar/libbootstrap.jar [for host]:
Note: src/java_tools/buildjar/java/com/google/devtools/build/buildjar/instrumentation/JacocoInstrumentationProcessor.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
INFO: From Executing genrule //src/java_tools/junitrunner/java/com/google/testing/coverage:Jacoco_jarjar:
May 23, 2018 2:46:19 AM com.tonicsystems.jarjar.transform.JarTransformer transform
INFO: Transforming archive ZipArchive(/tmp/bazel_0TCQ69sS/out/execroot/io_bazel/bazel-out/arm-opt/bin/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoCoverage_deploy.jar)
May 23, 2018 2:46:24 AM com.tonicsystems.jarjar.transform.jar.ClassTransformerJarProcessor process
WARNING: Failed to read class module-info.class: java.lang.RuntimeException
Target //src:bazel up-to-date:
  bazel-bin/src/bazel
INFO: Elapsed time: 497.872s, Critical Path: 269.35s
INFO: Build completed successfully, 1866 total actions
WARNING: /tmp/bazel_0TCQ69sS/out/external/bazel_tools/WORKSPACE:1: Workspace name in /tmp/bazel_0TCQ69sS/out/external/bazel_tools/WORKSPACE (@io_bazel) does not match the name given in the repository's definition (@bazel_tools); this will cause a build error in future versions

Build successful! Binary is here: /opt/soft/bazelpack/bazel10/output/bazel

编译完成之后建立软链接  ln -s /opt/soft/bazel/output/bazel /usr/bin/bazel ,执行bazel --help 测试bazel是否编译成功!

猜你喜欢

转载自blog.csdn.net/qq_41587243/article/details/81301486