Skip to content

clangd no longer works out of the box with compile-commands.json #141640

@matanlurey

Description

@matanlurey

I'm seeing Unknown argument: '-i' at the top of every C++ file in the engine as reported by clangd:

{
  "file": "../../flutter/common/settings.cc",
  "directory": "/Users/matanl/Developer/engine/src/out/android_debug_unopt_arm64",
  "command": "/Users/matanl/Developer/engine/src/buildtools/mac-x64/goma/gomacc ../../buildtools/mac-x64/clang/bin/clang++ -MD -MF  obj/flutter/common/common.settings.o.d  -DUSE_OPENSSL=1 -DUSE_OPENSSL_CERTS=1 -DANDROID -DHAVE_SYS_UIO_H -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D__compiler_offsetof=__builtin_offsetof -Dnan=__builtin_nan -D_LIBCPP_DISABLE_AVAILABILITY=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -D_DEBUG -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  -fno-strict-aliasing -fPIC -pipe -fcolor-diagnostics -ffunction-sections -funwind-tables -fno-short-enums -nostdinc++ -mno-outline-atomics --target=aarch64-linux-android -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 -D__ANDROID_API__=22 -fvisibility=hidden --sysroot=../../third_party/android_tools/ndk/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -Wstring-conversion -Wnewline-eof -O0 -g2 -Wunreachable-code  -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions   -c ../../flutter/common/settings.cc -o  obj/flutter/common/common.settings.o && sed -i '' 's@/b/f/w@../..@g'  obj/flutter/common/common.settings.o.d"
}

On Discord I asked:

Is there any reason sed is being used? Is this part of Clang, or something specific to our infrastructure?

To which @jason-simmons responded:

This is a workaround for a behavior in the RBE/Goma workers used for distributed compilation.

The depfiles generated on those workers contain absolute paths to directories on the worker's filesystem. Those paths will not behave correctly when copied to the local filesystem and used in other contexts.

The sed command runs after the compile command and converts the absolute path to a usable relative path.

The clang-tidy driver script reads compile_commands.json and then filters out the sed command to obtain the compile command.

I noted:

It used to just work out of the box, I'd prefer RBE did the post-processing and not every single user that wants an IDE

After talking to @zanderso:

Ok. @zanderso informed me in person that "we're holding it wrong" and it should be possible after some interdeterminate change to have both RBE and clangd working out of the box


This issue should track no longer needing this sed hack. I'll also file a bug that we should keep clangd working on CI.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.engineflutter/engine related. See also e: labels.team-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