vim-syntastic / syntastic

Syntax checking hacks for vim
Do What The F*ck You Want To Public License
11.3k stars 1.14k forks source link

Assembly files of different architecture(s): how? #2392

Closed vazhnov closed 2 years ago

vazhnov commented 2 years ago

Hello!

I use vim-syntastic since 2015. Thank you very much for this project!

Before, I worked with Python and Shell scripts. Now, as a hobby, I'm trying to learn to program in Asm and C for RISC-V architecture.

I faced with a issue: when I open RISC-V asm file (for example, https://git.sr.ht/~matthias_t/hello-riscv/tree/master/item/src/hello.s), I receive:

hello.s|4 error| Error: no such instruction: `li s1,0x10000000' [asm/gcc]
hello.s|5 error| Error: no such instruction: `la s2,message' [asm/gcc]
hello.s|6 error| Error: no such instruction: `addi s3,s2,14' [asm/gcc]
hello.s|8 error| Error: no such instruction: `lb s4,0(s2)' [asm/gcc]
hello.s|9 error| Error: no such instruction: `sb s4,0(s1)' [asm/gcc]

I found I can change syntastic_asm_gcc_exec to riscv-nuclei-elf-gcc, and it almost works, but:

syntastic: 0.575801: checker output: [‘gcc: error: unrecognized command-line option ‘-masm=att’’, '']

In https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1008 , I found RISC-V is not AT&T or Intel syntax, it has it's own syntax.

Of course, it is possible to patch syntax_checkers/asm/gcc.vim and remove this option, like this:

function! SyntaxCheckers_asm_gcc_GetLocList() dict " {{{1
    …
    return syntastic#c#GetLocList('asm', 'gcc', {
        …
        \ 'main_flags': '-x assembler -fsyntax-only' })

But maybe there is some other way? Does anybody have recipes or ideas how to work with Assembly files with non-X86 architecture(s)?

lcd047 commented 2 years ago

Setting g:syntastic_asm_generic to 1 should have the same effect without patching the sources.

Also you might consider switching to ALE instead, it's actively maintained and it actually takes advantage of Vim 8 features. These days you should only use syntastic for backwards compatibility, if for whatever reasons you have to run Vim 7...