clangd / clangd

clangd language server
https://clangd.llvm.org
Apache License 2.0
1.5k stars 63 forks source link

Stack overflow when indexing Firefox on Mac with clangd-indexer #714

Open aslushnikov opened 3 years ago

aslushnikov commented 3 years ago

Hi folks,

I'm running clangd-indexer from llvm 12.0.0-rc2 against Firefox source code that we use at Playwright. Unfortunately, it is crashing for me, so I built a debug version with ASAN enabled

$ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=yes -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;' -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_SANITIZER='Address' ../llvm

Running the ASAN build yields a "stackoverflow" signal from ASAN (full-asan-report.txt)

AddressSanitizer:DEADLYSIGNAL
=================================================================
==65787==ERROR: AddressSanitizer: stack-overflow on address 0x70000c408ff8 (pc 0x00010227ac48 bp 0x70000c409010 sp 0x70000c409000 T1)
    #0 0x10227ac48 in clang::QualType::isNull() const Type.h:726
    #1 0x10229381d in clang::QualType::getCommonPtr() const Type.h:677
    #2 0x102292c7b in clang::QualType::getCanonicalType() const Type.h:6452
    #3 0x10227ae30 in clang::ASTContext::getCanonicalType(clang::QualType) const ASTContext.h:2350
    #4 0x1013b8024 in clang::ASTContext::hasSameType(clang::QualType, clang::QualType) const ASTContext.h:2366
    #5 0x1066feb2f in clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, clang::StandardConversionSequence const&, clang::Sema::AssignmentAction, clang::Sema::CheckedConversionKind) SemaExprCXX.cpp:4120
    #6 0x1066fdd37 in clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, clang::ImplicitConversionSequence const&, clang::Sema::AssignmentAction, clang::Sema::CheckedConversionKind) SemaExprCXX.cpp:3991
    #7 0x106bf7a9f in CheckConvertedConstantExpression(clang::Sema&, clang::Expr*, clang::QualType, clang::APValue&, clang::Sema::CCEKind, bool, clang::NamedDecl*) SemaOverload.cpp:5694
    #8 0x106bf6ef3 in clang::Sema::CheckConvertedConstantExpression(clang::Expr*, clang::QualType, clang::APValue&, clang::Sema::CCEKind, clang::NamedDecl*) SemaOverload.cpp:5800
    #9 0x106d5fdbb in clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*, clang::QualType, clang::Expr*, clang::TemplateArgument&, clang::Sema::CheckTemplateArgumentKind) SemaTemplate.cpp:6925
    #10 0x106d82e8b in clang::Sema::CheckTemplateArgument(clang::NamedDecl*, clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation, clang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::TemplateArgument>&, clang::Sema::CheckTemplateArgumentKind) SemaTemplate.cpp:5401
    #11 0x106fe10d6 in ConvertDeducedTemplateArgument(clang::Sema&, clang::NamedDecl*, clang::DeducedTemplateArgument, clang::NamedDecl*, clang::sema::TemplateDeductionInfo&, bool, llvm::SmallVectorImpl<clang::TemplateArgument>&)::$_15::operator()(clang::DeducedTemplateArgument, unsigned int) const SemaTemplateDeduction.cpp:2719
    #12 0x106fe030e in ConvertDeducedTemplateArgument(clang::Sema&, clang::NamedDecl*, clang::DeducedTemplateArgument, clang::NamedDecl*, clang::sema::TemplateDeductionInfo&, bool, llvm::SmallVectorImpl<clang::TemplateArgument>&) SemaTemplateDeduction.cpp:2788

Local reproduction is somewhat involved since it requires building firefox on mac, so I'd be happy to follow-up if you have any questions. If you still want to reproduce this locally, here are the instructions to do that:

  1. Check out playwright and playwright's firefox
    $ git clone https://github.com/microsoft/playwright
    $ cd playwright
    $ ./browser_patches/prepare_checkout.sh firefox # this might take some time and eat many GBs
  2. Install rust
  3. Compile firefox:
    $ # This will yield an error on the first run and explain where to get a custom MacOS SDK.
    $ ./browser_patches/firefox/build.sh --full

    Note: custom SDK could be taken from https://github.com/phracker/MacOSX-SDKs for the sake of the repro.

  4. Build compilation database for firefox:
    $ cd ./browser_patches/firefox/checkout
    $ ./mach build-backend -b CompileDB
    $ ls ./obj-build-playwright/compile_commands.json # here's the compilation database
  5. Since MacOS has custom include paths, make sure to get those from clang++ -E -x c++ - -v < /dev/null and pass them all as --extra-arg="-I..." args to the clangd-indexer
  6. Run indexer against the compilation database.

System information Output of clangd --version:

LLVM (http://llvm.org/):
  LLVM version 12.0.0
  Optimized build with assertions.
  Default target: x86_64-apple-darwin19.6.0
  Host CPU: skylake

Editor/LSP plugin: N/A Operating system: Mac 10.15.4

HighCommander4 commented 3 years ago

It would be helpful if you could narrow down which source file triggers the stack overflow.

You can do this by running clangd-indexer with the additional argument --execute-concurrency=1. It will then perform the indexing on a single thread, and you can look for the last line of output of the form [X/Y] Processing file <filename> before the stack overflow.

aslushnikov commented 3 years ago

@HighCommander4 Thank you for the instructions! I reduced compilation database to the following:

[{
  "directory":"/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/parser/html",
  "command":"/usr/bin/clang++ -isysroot /Users/aslushnikov/SDK-archive/MacOSX10.12.sdk/ -std=gnu++17 -o /dev/null -c -fvisibility=hidden -fvisibility-inlines-hidden -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -DNDEBUG=1 -DTRIMMED=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/parser/html -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/dom/base -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/dist/include -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/dist/include/nspr -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/dist/include/nss -fPIC -DMOZILLA_CLIENT -include /Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/mozilla-config.h -Qunused-arguments -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wunreachable-code -Wunreachable-code-return -Wwrite-strings -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wcomma -Wimplicit-fallthrough -Wunused-function -Wunused-variable -Wstring-conversion -Wtautological-overlap-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wno-error=tautological-type-limit-compare -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=return-std-move -Wno-error=atomic-alignment -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-unknown-warning-option -fno-sized-deallocation -fno-aligned-new -fno-exceptions -fno-strict-aliasing -stdlib=libc++ -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -O3 -fomit-frame-pointer -funwind-tables -Wno-error=shadow -ferror-limit=0 Unified_cpp_parser_html0.cpp",
  "file":"/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5HtmlAttributes.cpp"
}]

Note that mozilla build system groups C++ sources. The Unified_cpp_parser_html0.cpp is a concatenation of 16 other sources:

Unified_cpp_parser_html0.cpp ```cpp #define MOZ_UNIFIED_BUILD #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5AtomTable.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5AtomTable.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5AtomTable.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5AttributeName.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5AttributeName.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5AttributeName.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5DependentUTF16Buffer.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5DependentUTF16Buffer.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5DependentUTF16Buffer.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5DocumentBuilder.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5DocumentBuilder.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5DocumentBuilder.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5ElementName.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5ElementName.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5ElementName.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Highlighter.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Highlighter.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Highlighter.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5HtmlAttributes.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5HtmlAttributes.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5HtmlAttributes.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5MetaScanner.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5MetaScanner.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5MetaScanner.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Module.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Module.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Module.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5NamedCharacters.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5NamedCharacters.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5NamedCharacters.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5NamedCharactersAccel.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5NamedCharactersAccel.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5NamedCharactersAccel.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5OplessBuilder.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5OplessBuilder.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5OplessBuilder.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5OwningUTF16Buffer.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5OwningUTF16Buffer.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5OwningUTF16Buffer.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Parser.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Parser.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Parser.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5PlainTextUtils.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5PlainTextUtils.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5PlainTextUtils.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif #include "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Portability.cpp" #ifdef PL_ARENA_CONST_ALIGN_MASK #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Portability.cpp uses PL_ARENA_CONST_ALIGN_MASK, so it cannot be built in unified mode." #undef PL_ARENA_CONST_ALIGN_MASK #endif #ifdef INITGUID #error "/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5Portability.cpp defines INITGUID, so it cannot be built in unified mode." #undef INITGUID #endif ```
HighCommander4 commented 3 years ago

Do you get the stack overflow if you cd into that directory and manually run that command (using the clang from the same LLVM distrbution that your clangd is from)?

aslushnikov commented 3 years ago

Do you get the stack overflow if you cd into that directory and manually run that command (using the clang from the same LLVM distrbution that your clangd is from)?

@HighCommander4 No, there's no stack overflow.

Just in case, I forgot to mention that I have to add additional -I flags so that include paths work the same way as in my standard clang++ at /usr/bin/clang++. I pass these as multiple --extra-arg= CLI option to clangd-indexer.

I do get some error: use of undeclared identifier '__builtin_ia32_storehps' errors though, but I don't think that's of much importance for indexing.

HighCommander4 commented 3 years ago

Thanks. One more thing that would be helpful: could you run the compile command, with the extra arguments added, and also with -c replaced with -E ("only preprocess, do not compile"), and -o /dev/null replaced with -o preprocessed.cpp, and then upload preprocessed.cpp as an attachment?

aslushnikov commented 3 years ago

@HighCommander4 sure thing, here it is: preprocessed.cpp.zip

HighCommander4 commented 3 years ago

Thanks. I am not able to reproduce the stack overflow on the preprocessed source file.

However, I don't have a Mac and was testing on Linux, so I may not be exercising some relevant codepaths.

Perhaps someone with a Mac can test and see if they can reproduce the stack overflow on the preprocessed source file.

aslushnikov commented 3 years ago

@HighCommander4 I just tried running ./build/bin/clangd-indexer preprocessed.cpp > out.dex and it didn't crash for me as well. So maybe I did something wrong when generating the preprocessed.cpp - let me carefully check everything.

Meanwhile, if you have any more suggestions - I'd be happy to try things.

HighCommander4 commented 3 years ago

I noticed the compile command contains a -include /<...>/mozilla-config.h argument as well. Could you upload that file as well?

aslushnikov commented 3 years ago

@HighCommander4 The following results in a stackoverflow error for me on Mac 10.15:

  1. preprocessed.cpp.zip
  2. compile_commands.json

    [{
      "directory":"/Users/aslushnikov/prog/llvm",
      "command":"/usr/bin/clang++ -std=gnu++17 -o /dev/null -c preprocessed.cpp",
      "file":"/Users/aslushnikov/prog/llvm/preprocessed.cpp"
    }]
  3. running clangd-indexer:
    $ ./build/bin/clangd-indexer ./compile_commands.json --executor=all-TUs --execute-concurrency=1

Interestingly, simply running ./build/bin/clangd-indexer --extra-arg="-std=gnu++17" preprocessed.cpp > out.dex works fine.

aslushnikov commented 3 years ago

I noticed the compile command contains a -include /<...>/mozilla-config.h argument as well. Could you upload that file as well?

@HighCommander4 Here it is: mozilla-config.h.zip. Though I'm able to reproduce the same StackOverflow without this include.

aslushnikov commented 3 years ago

@HighCommander4 Unfortunately, I wasn't able to reproduce this crash on my Ubuntu 20.04. However, I was trying to reproduce the crash by cross-compiling from Linux to MacOS, so I'm not sure how relevant this is.

Cross-compilation steps I did on Ubuntu 20.04. 1. Compiled [`llvmorg-12.0.0-rc2`](https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0-rc2) on Ubuntu 20.04 in Release mode. (Debug + ASAN failed to compile for me for some reason) ```sh $ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=yes -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;' -DCMAKE_BUILD_TYPE=Release ../llvm ``` 2. Got [unofficial macos10.12 sdk](https://github.com/phracker/MacOSX-SDKs) ```sh $ cd /tmp $ wget -O mac-sdk.tar.xz https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.12.sdk.tar.xz $ tar xf mac-sdk.tar.xz ``` 2. [preprocessed.cpp.zip](https://github.com/clangd/clangd/files/6098787/preprocessed.cpp.zip) 3. `compile_commands.json` has a few extra flags for cross-compilation ```json [{ "directory":"/home/aslushnikov/prog/llvm", "command":"/usr/bin/clang++ --sysroot /tmp/MacOSX10.12.sdk -mmacosx-version-min=10.12 -target x86_64-apple-darwin-macho -std=gnu++17 -o /dev/null -c preprocessed.cpp", "file":"/home/aslushnikov/prog/llvm/preprocessed.cpp" }] ``` 3. running clangd-indexer: ```sh $ ./build/bin/clangd-indexer ./compile_commands.json --executor=all-TUs --execute-concurrency=1 ```