MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.73k stars 254 forks source link

Error using MS-style inline assembly. #889

Open gabrhell opened 2 years ago

gabrhell commented 2 years ago

Observed behavior

I came across the following error when using MS-style inline assembly:

MS-style inline assembly is not available: Unable to find target for this triple (no targets are registered).

Example code:

int main(void)
{
    __asm__
    {
        nop
        nop
        nop
    }
    return 0;
}

Example .ccls file:

-masm=intel
-fasm-blocks
--target=i386-pc-linux-elf

Consider the following screenshot:

image_2022-07-04_16-03-24

This comment in another repository suggests that the error could be due to missing LLVM targets initialization.

Then I added initializations and compiled ccls:

llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllAsmParsers();

The error disappeared!

image_2022-07-04_18-13-30

System information