envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.83k stars 4.77k forks source link

Build Error: Missing Header File 'quiche/quic/core/batch_writer/quic_gso_batch_writer.h' When Compiling Envoy 1.26.4 on RISC-V 64 #36342

Open Boring545 opened 1 week ago

Boring545 commented 1 week ago

I am trying to build Envoy version 1.26.4 on a RISC-V 64 Linux system, but I am encountering some issues. During the build process, I found that the QUICHE-related components cannot be compiled correctly because it cannot find the header file quiche/quic/core/batch_writer/quic_gso_batch_writer.h. However, Bazel has successfully downloaded the QUICHE source files in the com_github_google_quiche directory.

I observed that the target udp_gso_batch_writer_lib uses this missing header file. The envoy_cc_library is defined as follows:

envoy_cc_library(
    name = "quic_core_batch_writer_gso_batch_writer_lib",
    srcs = select({
        "@envoy//bazel:linux": [
            "quiche/quic/core/batch_writer/quic_gso_batch_writer.cc",
        ],
        "//conditions:default": [],
    }),
    hdrs = select({
        "@envoy//bazel:linux": [
            "quiche/quic/core/batch_writer/quic_gso_batch_writer.h",
        ],
        "//conditions:default": [],
    }),
    copts = quiche_copts,
    repository = "@envoy",
    tags = ["nofips"],
    visibility = ["//visibility:public"],
    deps = [
        ":quic_core_batch_writer_batch_writer_base_lib",
        ":quic_core_linux_socket_utils_lib",
        ":quic_platform",
    ],
)

I am not sure what causes this issue. Since I have limited knowledge about Bazel, I am unsure how to modify it. Perhaps I should replace the corresponding statement with @com_github_google_quiche//quiche/quic/core/batch_writer/quic_gso_batch_writer.h?


Here is the build output for reference:

[zjq@openeuler-riscv-4-4 envoy-1.26.4]$ bazel build -c opt --workspace_status_command= --verbose_failures --fission=no --//source/extensions/wasm_runtime/v8:enabled=false envoy
INFO: Build option --//source/extensions/quic/crypto_stream:enabled has changed, discarding analysis cache.
INFO: Analyzed target //:envoy (0 packages loaded, 32320 targets configured).
INFO: Found 1 target...
ERROR: /home/zjq/build_factory/envoy/envoy-1.26.4/source/extensions/udp_packet_writer/gso/BUILD:12:19: Compiling source/extensions/udp_packet_writer/gso/config.cc failed: (Exit 1): gcc failed: error executing command (from target //source/extensions/udp_packet_writer/gso:config)
In file included from ./source/extensions/udp_packet_writer/gso/config.h:8,
                 from source/extensions/udp_packet_writer/gso/config.cc:1:
./source/common/quic/udp_gso_batch_writer.h:13:10: fatal error: quiche/quic/core/batch_writer/quic_gso_batch_writer.h: No such file or directory
   13 | #include "quiche/quic/core/batch_writer/quic_gso_batch_writer.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Target //source/exe:envoy-static failed to build
INFO: Elapsed time: 31.612s, Critical Path: 18.70s
INFO: 66 processes: 65 internal, 1 linux-sandbox.
FAILED: Build did NOT complete successfully
Boring545 commented 1 week ago
(cd /home/zjq/.cache/bazel/_bazel_zjq/ce2d960f2051ba39ca8054ce19936793/sandbox/linux-sandbox/8271/execroot/envoy && \
exec env - \
  BAZEL_LINKLIBS=-l%:libstdc++.a \
  BAZEL_LINKOPTS=-lm \
  PATH=/home/zjq/riscv_istio_test/go_golang/go/bin:/home/zjq/riscv_istio_test/go_golang/golang/bin:/home/zjq/.cargo/bin:/home/zjq/.wasmtime/bin:/home/zjq/local/bazel/bin:/home/zjq/.local/bin:/home/zjq/bin:/home/zjq/.cabal/bin:/home/zjq/build_factory/GHC/cabal/cabal2/cabal/_build/bin:/usr/local/bin:/usr/bin \
  PWD=/proc/self/cwd \
/usr/local/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/riscv64-opt/bin/source/extensions/udp_packet_writer/gso/_objs/config/config.d '-frandom-seed=bazel-out/riscv64-opt/bin/source/extensions/udp_packet_writer/gso/_objs/config/config.o' -DFMT_HEADER_ONLY -DSPDLOG_FMT_EXTERNAL -DENVOY_ADMIN_FUNCTIONALITY -DENVOY_ENABLE_QUIC -DENVOY_ENABLE_HTTP_DATAGRAMS -DENVOY_MOBILE_ENABLE_LISTENER -DENVOY_MOBILE_STATS_REPORTING -DENVOY_MOBILE_REQUEST_COMPRESSION -DENVOY_GOOGLE_GRPC -DNGHTTP2_STATICLIB '-DBAZEL_CURRENT_REPOSITORY=""' \
-iquote . \
-iquote bazel-out/riscv64-opt/bin \
-iquote external/com_google_absl \
-iquote bazel-out/riscv64-opt/bin/external/com_google_absl \
-iquote external/com_github_fmtlib_fmt \
-iquote bazel-out/riscv64-opt/bin/external/com_github_fmtlib_fmt \
-iquote external/envoy_api \
-iquote bazel-out/riscv64-opt/bin/external/envoy_api \
-iquote external/com_google_googleapis \
-iquote bazel-out/riscv64-opt/bin/external/com_google_googleapis \
-iquote external/com_google_protobuf \
-iquote bazel-out/riscv64-opt/bin/external/com_google_protobuf \
-iquote external/com_envoyproxy_protoc_gen_validate \
-iquote bazel-out/riscv64-opt/bin/external/com_envoyproxy_protoc_gen_validate \
-iquote external/com_googlesource_code_re2 \
-iquote bazel-out/riscv64-opt/bin/external/com_googlesource_code_re2 \
-iquote external/com_github_cncf_udpa \
-iquote bazel-out/riscv64-opt/bin/external/com_github_cncf_udpa \
-iquote external/opencensus_proto \
-iquote bazel-out/riscv64-opt/bin/external/opencensus_proto \
-iquote external/com_github_gabime_spdlog \
-iquote bazel-out/riscv64-opt/bin/external/com_github_gabime_spdlog \
-iquote external/com_github_cyan4973_xxhash \
-iquote bazel-out/riscv64-opt/bin/external/com_github_cyan4973_xxhash \
-iquote external/com_github_jbeder_yaml_cpp \
-iquote bazel-out/riscv64-opt/bin/external/com_github_jbeder_yaml_cpp \
-iquote external/boringssl \
-iquote bazel-out/riscv64-opt/bin/external/boringssl \
-iquote external/envoy \
-iquote bazel-out/riscv64-opt/bin/external/envoy \
-iquote external/com_github_google_quiche \
-iquote bazel-out/riscv64-opt/bin/external/com_github_google_quiche \
-iquote external/com_googlesource_googleurl \
-iquote bazel-out/riscv64-opt/bin/external/com_googlesource_googleurl \
-Ibazel-out/riscv64-opt/bin/external/com_google_protobuf/_virtual_includes/any_proto \
-Ibazel-out/riscv64-opt/bin/external/com_google_protobuf/_virtual_includes/descriptor_proto \
-Ibazel-out/riscv64-opt/bin/external/com_google_protobuf/_virtual_includes/duration_proto \
-Ibazel-out/riscv64-opt/bin/external/com_google_protobuf/_virtual_includes/empty_proto \
-Ibazel-out/riscv64-opt/bin/external/com_google_protobuf/_virtual_includes/struct_proto \
-Ibazel-out/riscv64-opt/bin/external/com_google_protobuf/_virtual_includes/timestamp_proto \
-Ibazel-out/riscv64-opt/bin/external/com_google_protobuf/_virtual_includes/wrappers_proto \
-Ibazel-out/riscv64-opt/bin/source/common/common/_virtual_includes/logger_impl_lib_standard \
-Ibazel-out/riscv64-opt/bin/source/common/common/_virtual_includes/thread_impl_lib_posix \
-Ibazel-out/riscv64-opt/bin/source/common/api/_virtual_includes/os_sys_calls_lib \
-Ibazel-out/riscv64-opt/bin/source/common/quic/platform/_virtual_includes/quiche_export_impl_lib \
-Ibazel-out/riscv64-opt/bin/source/common/quic/platform/_virtual_includes/quiche_logging_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_command_line_flags_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_flag_utils_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_reference_counted_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_testvalue_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_time_utils_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_prefetch_impl_lib \
-Ibazel-out/riscv64-opt/bin/source/common/quic/platform/_virtual_includes/quic_base_impl_lib \
-Ibazel-out/riscv64-opt/bin/source/common/quic/platform/_virtual_includes/quiche_flags_impl_lib \
-Ibazel-out/riscv64-opt/bin/source/common/quic/platform/_virtual_includes/quiche_mem_slice_impl_lib \
-Ibazel-out/riscv64-opt/bin/source/common/quic/platform/_virtual_includes/quiche_platform_iovec_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_server_stats_impl_lib \
-Ibazel-out/riscv64-opt/bin/source/common/quic/platform/_virtual_includes/quiche_stack_trace_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_client_stats_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_mutex_impl_lib \
-Ibazel-out/riscv64-opt/bin/external/com_github_google_quiche/_virtual_includes/quiche_common_platform_default_quiche_platform_impl_containers_impl_lib \
-Ibazel-out/riscv64-opt/bin/source/common/filesystem/_virtual_includes/directory_iterator_impl_lib_posix \
-isystem external/com_github_fmtlib_fmt/include \
-isystem bazel-out/riscv64-opt/bin/external/com_github_fmtlib_fmt/include \
-isystem external/com_google_protobuf/src \
-isystem bazel-out/riscv64-opt/bin/external/com_google_protobuf/src \
-isystem bazel-out/riscv64-opt/bin/external/envoy/bazel/foreign_cc/zlib/include \
-isystem external/com_github_gabime_spdlog/include \
-isystem bazel-out/riscv64-opt/bin/external/com_github_gabime_spdlog/include \
-isystem external/com_github_jbeder_yaml_cpp/include \
-isystem bazel-out/riscv64-opt/bin/external/com_github_jbeder_yaml_cpp/include \
-isystem bazel-out/riscv64-opt/bin/external/envoy/bazel/foreign_cc/event/include \
-isystem external/boringssl/src/include \
-isystem bazel-out/riscv64-opt/bin/external/boringssl/src/include \
-isystem external/envoy/bazel/external/http_parser \
-isystem bazel-out/riscv64-opt/bin/external/envoy/bazel/external/http_parser \
-isystem bazel-out/riscv64-opt/bin/external/envoy/bazel/foreign_cc/nghttp2/include \
'-DABSL_MIN_LOG_LEVEL=4' -fPIC -Wno-deprecated-declarations '-std=c++17' '-Wno-error=
Boring545 commented 1 week ago

Based on the -iquote external/com_github_google_quiche and -iquote bazel-out/riscv64-opt/bin/external/com_github_google_quiche, I placed the QUICHE source files in both locations, but it did not work.

Boring545 commented 1 week ago

I solved this issue because

 hdrs = select({ 
    "@envoy//bazel:linux": ["quiche/quic/core/batch_writer/quic_gso_batch_writer.h"], 
    "//conditions:default": [], 
}) 

didn't support RISC-V 64. I added the riscv64 related parts in envoy/bazel/BUILD to adapt to the bazel:linux label, and I have successfully compiled now.

This includes:

config_setting(
    name = "linux_riscv64",
    values = {"cpu": "riscv64"},
)

selects.config_setting_group(
    name = "linux",
    match_any = [
        ":linux_aarch64",
        ":linux_mips64",
        ":linux_ppc",
        ":linux_s390x",
        ":linux_x86_64",
        ":linux_riscv64",
    ],
)

selects.config_setting_group(
    name = "not_x86",
    match_any = [
        ":darwin_arm64",
        ":ios_arm64",
        ":ios_arm64e",
        ":ios_armv7",
        ":ios_armv7s",
        ":ios_i386",
        ":ios_sim_arm64",
        ":linux_aarch64",
        ":linux_mips64",
        ":linux_ppc",
        ":linux_s390x",
        ":linux_riscv64",
    ],
)
INFO: From Linking source/exe/envoy-static:
/usr/bin/ld: warning: unrecognized --build-id style ignored
Target //source/exe:envoy-static up-to-date:
  bazel-bin/source/exe/envoy-static
INFO: Elapsed time: 3406.686s, Critical Path: 1138.27s
INFO: 1088 processes: 12 internal, 1076 linux-sandbox.
INFO: Build completed successfully, 1088 total actions  

Unfortunately, I'm not sure why V8 cannot be effectively compiled with Envoy as an extension, so I specified the parameter --//source/extensions/wasm_runtime/v8:enabled=false. I will address this issue when I have time.

phlax commented 1 week ago

@Boring545 - Envoy 1.26 is no longer supported - would be good to know if the issue is present in supported versions

Boring545 commented 1 week ago

@Boring545 - Envoy 1.26 is no longer supported - would be good to know if the issue is present in supported versions

Due to RISC-V 64 compatibility issues with rules_python, I am currently unable to resolve the problems encountered with the newer version of Envoy. However, I believe this is a common issue, as the latest version of Envoy also lacks the registration of RISC-V 64 as a Linux target.