使用集市在aarch64上建造Abseil



我无法使用Bazel构建abseil-cpp。我直接把它建在扶手64上。

  • 设备:NVIDIA Jetson Xavier NX
  • 操作系统:Ubuntu 18.04
  • CPU:6核NVIDIA Carmel ARM®v8.2 64位

/示例/hello_world.cc

#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;
}

/示例/BILD

cc_binary(
name = "hello_world",
deps = ["@com_google_absl//absl/strings", "@com_google_absl//absl/random"],
srcs = ["hello_world.cc"],
)

/工作空间

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",
)

结果

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构建的相同代码没有错误:

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

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)

有什么解决办法吗?

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

您必须等待最新版本。

最新更新