Skip to content

error: loop variable 'token' of type 'const absl::string_view' creates a copy from type 'const absl::string_view' #11949

@ankane

Description

@ankane

Hi, thanks for open sourcing this project!

I'm trying to add Envoy to Homebrew, so Mac users can do brew install envoy but am running into an error when building.

ERROR: /private/tmp/envoy-20200708-2339-14txihn/source/common/common/BUILD:332:1: C++ compilation of rule '//source/common/common:utility_lib' failed (Exit 1): wrapped_clang failed: error executing command 
  (cd /private/var/tmp/_bazel_runner/1f4862552b37dee9dfa99c1797b31a83/sandbox/processwrapper-sandbox/946/execroot/envoy && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.16 \
    BAZEL_LINKLIBS=-l%:libstdc++.a \
    BAZEL_LINKOPTS=-lm \
    CC=clang \
    CXX=clang++ \
    PATH=/usr/local/bin:/opt/local/bin:/usr/bin:/bin \
    XCODE_VERSION_OVERRIDE=12.0.0.12A6159 \
  external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' -iquote . -iquote bazel-out/darwin-fastbuild/bin -iquote external/com_google_absl -iquote bazel-out/darwin-fastbuild/bin/external/com_google_absl -iquote external/com_github_fmtlib_fmt -iquote bazel-out/darwin-fastbuild/bin/external/com_github_fmtlib_fmt -iquote external/com_github_gabime_spdlog -iquote bazel-out/darwin-fastbuild/bin/external/com_github_gabime_spdlog -iquote external/com_github_cyan4973_xxhash -iquote bazel-out/darwin-fastbuild/bin/external/com_github_cyan4973_xxhash -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/utility_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/assert_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/minimal_logger_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/base_logger_lib -Ibazel-out/darwin-fastbuild/bin/include/envoy/common/_virtual_includes/base_includes -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/fmt_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/lock_guard_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/thread_annotations -Ibazel-out/darwin-fastbuild/bin/include/envoy/thread/_virtual_includes/thread_interface -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/macros -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/non_copyable -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/logger_impl_lib_standard -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/hash_lib -Ibazel-out/darwin-fastbuild/bin/include/envoy/common/_virtual_includes/interval_set_interface -Ibazel-out/darwin-fastbuild/bin/include/envoy/common/_virtual_includes/time_interface -Ibazel-out/darwin-fastbuild/bin/source/common/singleton/_virtual_includes/const_singleton -isystem external/com_github_fmtlib_fmt/include -isystem bazel-out/darwin-fastbuild/bin/external/com_github_fmtlib_fmt/include -isystem external/com_github_gabime_spdlog/include -isystem bazel-out/darwin-fastbuild/bin/external/com_github_gabime_spdlog/include -MD -MF bazel-out/darwin-fastbuild/bin/source/common/common/_objs/utility_lib/utility.d -D__CLANG_SUPPORT_DYN_ANNOTATION__ -DSPDLOG_FMT_EXTERNAL -DFMT_HEADER_ONLY '-frandom-seed=bazel-out/darwin-fastbuild/bin/source/common/common/_objs/utility_lib/utility.o' -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks '-mmacosx-version-min=10.16' -Wall -Wextra -Werror -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Wformat -Wformat-security -Wvla '-std=c++14' -DTCMALLOC -DENVOY_HANDLE_SIGNALS -DENVOY_OBJECT_TRACE_ON_DUMP -D__APPLE_USE_RFC_3542 -DENVOY_GOOGLE_GRPC -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c source/common/common/utility.cc -o bazel-out/darwin-fastbuild/bin/source/common/common/_objs/utility_lib/utility.o)
Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox wrapped_clang failed: error executing command 
  (cd /private/var/tmp/_bazel_runner/1f4862552b37dee9dfa99c1797b31a83/sandbox/processwrapper-sandbox/946/execroot/envoy && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.16 \
    BAZEL_LINKLIBS=-l%:libstdc++.a \
    BAZEL_LINKOPTS=-lm \
    CC=clang \
    CXX=clang++ \
    PATH=/usr/local/bin:/opt/local/bin:/usr/bin:/bin \
    XCODE_VERSION_OVERRIDE=12.0.0.12A6159 \
  external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' -iquote . -iquote bazel-out/darwin-fastbuild/bin -iquote external/com_google_absl -iquote bazel-out/darwin-fastbuild/bin/external/com_google_absl -iquote external/com_github_fmtlib_fmt -iquote bazel-out/darwin-fastbuild/bin/external/com_github_fmtlib_fmt -iquote external/com_github_gabime_spdlog -iquote bazel-out/darwin-fastbuild/bin/external/com_github_gabime_spdlog -iquote external/com_github_cyan4973_xxhash -iquote bazel-out/darwin-fastbuild/bin/external/com_github_cyan4973_xxhash -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/utility_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/assert_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/minimal_logger_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/base_logger_lib -Ibazel-out/darwin-fastbuild/bin/include/envoy/common/_virtual_includes/base_includes -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/fmt_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/lock_guard_lib -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/thread_annotations -Ibazel-out/darwin-fastbuild/bin/include/envoy/thread/_virtual_includes/thread_interface -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/macros -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/non_copyable -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/logger_impl_lib_standard -Ibazel-out/darwin-fastbuild/bin/source/common/common/_virtual_includes/hash_lib -Ibazel-out/darwin-fastbuild/bin/include/envoy/common/_virtual_includes/interval_set_interface -Ibazel-out/darwin-fastbuild/bin/include/envoy/common/_virtual_includes/time_interface -Ibazel-out/darwin-fastbuild/bin/source/common/singleton/_virtual_includes/const_singleton -isystem external/com_github_fmtlib_fmt/include -isystem bazel-out/darwin-fastbuild/bin/external/com_github_fmtlib_fmt/include -isystem external/com_github_gabime_spdlog/include -isystem bazel-out/darwin-fastbuild/bin/external/com_github_gabime_spdlog/include -MD -MF bazel-out/darwin-fastbuild/bin/source/common/common/_objs/utility_lib/utility.d -D__CLANG_SUPPORT_DYN_ANNOTATION__ -DSPDLOG_FMT_EXTERNAL -DFMT_HEADER_ONLY '-frandom-seed=bazel-out/darwin-fastbuild/bin/source/common/common/_objs/utility_lib/utility.o' -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks '-mmacosx-version-min=10.16' -Wall -Wextra -Werror -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Wformat -Wformat-security -Wvla '-std=c++14' -DTCMALLOC -DENVOY_HANDLE_SIGNALS -DENVOY_OBJECT_TRACE_ON_DUMP -D__APPLE_USE_RFC_3542 -DENVOY_GOOGLE_GRPC -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c source/common/common/utility.cc -o bazel-out/darwin-fastbuild/bin/source/common/common/_objs/utility_lib/utility.o)
Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox
source/common/common/utility.cc:309:21: error: loop variable 'token' of type 'const absl::string_view' creates a copy from type 'const absl::string_view' [-Werror,-Wrange-loop-analysis]
    for (const auto token : tokens) {
                    ^
source/common/common/utility.cc:309:10: note: use reference type 'const absl::string_view &' to prevent copying
    for (const auto token : tokens) {
         ^~~~~~~~~~~~~~~~~~
                    &
1 error generated.
Target //source/exe:envoy-static failed to build

Compiler identification: AppleClang 11.0.3.11030032
OS Version: macOS 10.15
Full build logs: https://github.com/ankane/homebrew-core/runs/848972697?check_suite_focus=true
Homebrew formula (if it's useful): https://github.com/ankane/homebrew-core/blob/70e7d94a8e010f54ae52f377cb41816e1046240a/Formula/envoy.rb

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/buildstalestalebot believes this issue/PR has not been touched recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions