Skip to content

[rbe] clangd emits unknown argument errors when RBE is enabled. #147767

Description

@bdero

Note

This does not cause clangd to fail analysis of C++ files, so I don't think this is a severe issue. Rather, it just pollutes/crowds the error pool in LSP editors. E.g. in vscode, all open cpp files end up getting highlighted as containing errors instead of just the files that actually do contain errors, which is somewhat annoying/disruptive.

Workaround at the bottom in case you also find it disruptive.

On macOS, enabling RBE results in build lines that are prepended with the reclient/rewrapper tool that ships with our Clang SDK. But clangd interprets everything that looks like a flags as a compiler flags, and so clangd emits an error for each of the rewrapper flags when parsing every file:

Unknown argument: '--cfg=/Users/bdero/projects/flutter/engine/src/flutter/build/rbe/rewrapper-mac-arm64.cfg'clang(drv_unknown_argument)
Unknown argument: '--exec_root=/Users/bdero/projects/flutter/engine/src/'clang(drv_unknown_argument)
Unknown argument: '--remote_wrapper=../../flutter/build/rbe/remote_wrapper.sh'clang(drv_unknown_argument)
Unknown argument: '--labels=type=compile,compiler=clang,lang=cpp'clang(drv_unknown_argument)

Example entry in compile_commands.json:

  {
    "file": "../../flutter/impeller/entity/entity_pass.cc",
    "directory": "/Users/bdero/projects/flutter/engine/src/out/host_debug_unopt_arm64",
    "command": "/Users/bdero/projects/flutter/engine/src/flutter/buildtools/mac-arm64/reclient/rewrapper --cfg=/Users/bdero/projects/flutter/engine/src/flutter/build/rbe/rewrapper-mac-arm64.cfg --exec_root=/Users/bdero/projects/flutter/engine/src/ --remote_wrapper=../../flutter/build/rbe/remote_wrapper.sh --labels=type=compile,compiler=clang,lang=cpp ../../flutter/buildtools/mac-x64/clang/bin/clang++ -MMD -MF  obj/flutter/impeller/entity/entity.entity_pass.o.d  -D_USE_MATH_DEFINES -DUSE_OPENSSL=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_LIBCPP_DISABLE_AVAILABILITY=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -D_DEBUG -DIMPELLER_DEBUG=1 -DIMPELLER_SUPPORTS_RENDERING=1 -DIMPELLER_ENABLE_METAL=1 -DIMPELLER_ENABLE_OPENGLES=1 -DIMPELLER_ENABLE_VULKAN=1 -DFLUTTER_RUNTIME_MODE_DEBUG=1 -DFLUTTER_RUNTIME_MODE_PROFILE=2 -DFLUTTER_RUNTIME_MODE_RELEASE=3 -DFLUTTER_RUNTIME_MODE_JIT_RELEASE=4 \"-DDART_LEGACY_API=[[deprecated]]\" -DFLUTTER_RUNTIME_MODE=1 -DFLUTTER_JIT_RUNTIME=1  -I../.. -Igen -I../../third_party/libcxx/include -I../../third_party/libcxxabi/include -I../../flutter/build/secondary/third_party/libcxx/config -I../../flutter -Igen/flutter -Igen/flutter/impeller/runtime_stage -I../../flutter/third_party/flatbuffers/include  -Wthread-safety-analysis -fno-strict-aliasing -fstack-protector-all --target=arm64-apple-macos -arch arm64 -fcolor-diagnostics -Wall -Wextra -Wendif-labels -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-implicit-int-float-conversion -Wno-deprecated-copy -Wno-psabi -Wno-deprecated-literal-operator -Wno-unqualified-std-cast-call -Wno-non-c-typedef-for-linkage -Wno-range-loop-construct -Wunguarded-availability -Wno-deprecated-declarations -fvisibility=hidden -Wstring-conversion -Wnewline-eof -O0 -g2 -Wno-newline-eof -Wunreachable-code  -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions -stdlib=libc++ -isysroot ../../flutter/prebuilts/SDKs/MacOSX14.4.sdk -mmacosx-version-min=10.14.0  -c ../../flutter/impeller/entity/entity_pass.cc -o  obj/flutter/impeller/entity/entity.entity_pass.o"
  },

So in this case, the extra wrapper content being prepended is:

/Users/bdero/projects/flutter/engine/src/flutter/buildtools/mac-arm64/reclient/rewrapper \
--cfg=/Users/bdero/projects/flutter/engine/src/flutter/build/rbe/rewrapper-mac-arm64.cfg \
--exec_root=/Users/bdero/projects/flutter/engine/src/ \
--remote_wrapper=../../flutter/build/rbe/remote_wrapper.sh \
--labels=type=compile,compiler=clang,lang=cpp

As a quick workaround to restore correct error emissions, I started doing a sed replace after running RBE builds with et:

et build -c host_debug_unopt_arm64 --verbose --rbe --no-lto

# Remove all command content before the compiler binary.
sed -r \
  -i.bak \
  -e 's/("command"[[:space:]]*:[[:space:]]*").*([[:space:]].*clang\+\+)/\1\2/' \
  ../out/host_debug_unopt_arm64/compile_commands.json

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projectteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions