ale icon indicating copy to clipboard operation
ale copied to clipboard

Can not use cross compiler for ale_linter

Open laoshaw opened this issue 2 years ago • 3 comments

Information

VIM version

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32) Included patches: 1-2269, 3612, 3625, 3669, 3741

ubuntu 20.04

What went wrong

I use cross-compiler(arm-none-gcc) and ALE sends out a lot of warning because it is use native gcc and could not find the correct path for cross-compiler's headers. I use compiler as the linter(not clangtidy etc which respects compile_commands.json but gcc/clang ignores compile_commands.json)

so I change let g:ale_linters={'c':['arm-none-gcc']} even let g:ale_linters={'c':['my/path/to/arm-none-gcc']}, as long as I put cross compiler here, ALEInfo will no longer show ale_linter and ale_c_cc_options at all. If I change it back to a native gcc/clang, ale_linter etc shows as expected.

Reproducing the bug

in .vimrc, do: let g:ale_linters={'c':['arm-none-gcc']}, open any c file, run :ALEinfo, the new linter setting is totally ignored and default native linters are used instead.

:ALEInfo

 Current Filetype: c
Available Linters: ['cc', 'ccls', 'clangd', 'clangtidy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder']
   Linter Aliases:
'cc' -> ['gcc', 'clang']
  Enabled Linters: []
  Ignored Linters: []
 Suggested Fixers:
  'astyle' - Fix C/C++ with astyle.
  'clang-format' - Fix C/C++ and cuda files with clang-format.
  'clangtidy' - Fix C/C++ and ObjectiveC files with clang-tidy.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
  'uncrustify' - Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.
 Linter Variables:
let g:ale_c_build_dir = ''
 Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = v:null
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 1
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1

laoshaw avatar Apr 08 '22 21:04 laoshaw

Forgot to mention, I did have: let g:ale_c_cc_executable="/opt/arm-none-gcc/bin/arm-none-gcc" and this one always showed up in ALEInfo, it's just ignored as ALE treats my code as native c code and uses all native settings for it.

laoshaw avatar Apr 08 '22 21:04 laoshaw

If I do not have any above manual changes and I produce a compile_commands.json file that has correct directory, cross-compiler name, flags etc, ALEInfo still shows it uses 'clang' to build instead of my 'arm-none-gcc' in compile_commands.json', it is ignoring that line for some reason(other flags are picked up correctly, however)

laoshaw avatar Apr 26 '22 02:04 laoshaw

work around: put something like let g:ale_c_cc_executable="/usr/bin/arm-none-eabi-gcc" into local.vimrc will force ALE to use cross compiler, still ALE ignores first argument in compile_commands.json(e.g. the compiler)

laoshaw avatar Sep 19 '22 21:09 laoshaw