首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用bazel在aarch64上建立Abseil

使用bazel在aarch64上建立Abseil
EN

Stack Overflow用户
提问于 2021-06-30 16:30:06
回答 1查看 559关注 0票数 1

我不能用Bazel构建abseil-cpp。我正在arm64上直接构建它。

  • 设备: NVIDIA Jetson Xavier NX
  • OS: Ubuntu18.04
  • CPU:6核NVIDIA卡梅尔ARM v8.2 64位

./example/hello_world.cc

代码语言:javascript
运行
复制
#include <iostream>
#include <string>
#include <vector>

#include "absl/strings/str_join.h"
#include "absl/random/random.h"

int main() {
  std::vector<std::string> v = {"foo", "bar", "baz"};
  std::string s = absl::StrJoin(v, "-");

  absl::BitGen bitgen;

  std::cout << "Joined string: " << s << "\n";
  std::cout << "Number: " << absl::Uniform(bitgen, 0, 1.0) << "\n"; 

  return 0;
}

/示例/构建

代码语言:javascript
运行
复制
cc_binary(
  name = "hello_world",
  deps = ["@com_google_absl//absl/strings", "@com_google_absl//absl/random"],
  srcs = ["hello_world.cc"],
)

./工作区

代码语言:javascript
运行
复制
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
  name = "com_google_absl",
  urls = ["https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip"],
  strip_prefix = "abseil-cpp-98eb410c93ad059f9bba1bf43f5bb916fc92a5ea",
)

结果

代码语言:javascript
运行
复制
ubuntu@NVIDIA-01:~/Projects/my_workspace$ bazel build //example:hello_world
DEBUG: Rule 'com_google_absl' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "aabf6c57e3834f8dc3873a927f37eaf69975d4b28117fc7427dfb1c661542a87"
DEBUG: Repository com_google_absl instantiated at:
  /home/ubuntu/Projects/my_workspace/WORKSPACE:3:13: in <toplevel>
Repository rule http_archive defined at:
  /home/ubuntu/.cache/bazel/_bazel_ubuntu/b8008d82eb65899d4e39675de40d6cec/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
INFO: Analyzed target //example:hello_world (7 packages loaded, 98 targets configured).
INFO: Found 1 target...
ERROR: /home/ubuntu/.cache/bazel/_bazel_ubuntu/b8008d82eb65899d4e39675de40d6cec/external/com_google_absl/absl/random/internal/BUILD.bazel:331:11: C++ compilation of rule '@com_google_absl//absl/random/internal:randen_hwaes_impl' failed (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 31 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 31 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
In file included from external/com_google_absl/absl/random/internal/randen_hwaes.cc:225:0:
/usr/lib/gcc/aarch64-linux-gnu/7/include/arm_neon.h: In function 'Vector128 {anonymous}::AesRound(const Vector128&, const Vector128&)':
/usr/lib/gcc/aarch64-linux-gnu/7/include/arm_neon.h:12440:1: error: inlining failed in call to always_inline 'uint8x16_t vaesmcq_u8(uint8x16_t)': target specific option mismatch
 vaesmcq_u8 (uint8x16_t data)
 ^~~~~~~~~~
external/com_google_absl/absl/random/internal/randen_hwaes.cc:251:20: note: called from here
   return vaesmcq_u8(vaeseq_u8(state, uint8x16_t{})) ^ round_key;
          ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from external/com_google_absl/absl/random/internal/randen_hwaes.cc:225:0:
/usr/lib/gcc/aarch64-linux-gnu/7/include/arm_neon.h:12426:1: error: inlining failed in call to always_inline 'uint8x16_t vaeseq_u8(uint8x16_t, uint8x16_t)': target specific option mismatch
 vaeseq_u8 (uint8x16_t data, uint8x16_t key)
 ^~~~~~~~~
external/com_google_absl/absl/random/internal/randen_hwaes.cc:251:20: note: called from here
   return vaesmcq_u8(vaeseq_u8(state, uint8x16_t{})) ^ round_key;
          ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-pass-failed'
Target //example:hello_world failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 8.358s, Critical Path: 2.18s
INFO: 14 processes: 3 internal, 11 linux-sandbox.
FAILED: Build did NOT complete successfully

但是,相同的代码是使用CMake生成的,没有错误:

代码语言:javascript
运行
复制
ubuntu@NVIDIA-01:~/Projects/TestProject/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/Projects/TestProject/build

ubuntu@NVIDIA-01:~/Projects/TestProject/build$ cmake --build . --target hello_world
[  3%] Built target absl_log_severity
[  6%] Built target absl_raw_logging_internal
[  9%] Built target absl_bad_optional_access
[ 12%] Built target absl_spinlock_wait
[ 21%] Built target absl_base
[ 27%] Built target absl_throw_delegate
[ 30%] Built target absl_int128
[ 33%] Built target absl_random_internal_platform
[ 36%] Built target absl_random_internal_randen_hwaes_impl
[ 39%] Built target absl_random_internal_randen_hwaes
[ 45%] Built target absl_random_internal_randen_slow
[ 48%] Built target absl_random_internal_randen
[ 51%] Built target absl_random_seed_gen_exception
[ 57%] Built target absl_strings_internal
[ 81%] Built target absl_strings
[ 84%] Built target absl_random_distributions
[ 87%] Built target absl_random_internal_seed_material
[ 90%] Built target absl_random_internal_pool_urbg
[ 93%] Built target absl_random_seed_sequences
[100%] Built target hello_world

./CMakeLists.txt

代码语言:javascript
运行
复制
cmake_minimum_required(VERSION 3.5)

project(my_project)

# Abseil requires C++11
set(CMAKE_CXX_STANDARD 11)

# Process Abseil's CMake build system
add_subdirectory(abseil-cpp)

add_executable(hello_world hello_world.cc)

# Declare dependency on the absl::strings library
target_link_libraries(hello_world absl::strings)
target_link_libraries(hello_world absl::random_random)

有什么解决办法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-19 19:01:39

这里的解决方案:https://github.com/abseil/abseil-cpp/pull/984

你必须等待最新的版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68198520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档