ale icon indicating copy to clipboard operation
ale copied to clipboard

Why does ALE's linting omit the -Xclang compiler flag even though it is inside the compilation database?

Open themightyoarfish opened this issue 3 years ago • 3 comments

Information

VIM version

NVIM v0.6.1 Build type: Release

Operating System: macOS 10.15.7

What went wrong

I have ALE configured like this:

call dein#add('dense-analysis/ale')
let g:ale_linters = { 'cpp' : ['clang', 'clangtidy'] }
let g:ale_cpp_clangtidy_checks = []
let g:ale_cpp_clangtidy_executable = '/usr/local/Cellar/llvm/13.0.0/bin/clang-tidy'
let g:ale_c_parse_compile_commands=1
let g:ale_cpp_clangtidy_extra_options = '-p compile_commands.json'
let g:ale_cpp_clangtidy_options = ''
let g:ale_set_balloons=1
let g:ale_linters_explicit=1
let g:ale_c_build_dir_names=['build', '.']

I have compile_commands.json both in the build dir and symlinked to project root. Inside are commands like this for the file in question (src/main.cpp):

{
  "directory": "/project/build",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DCORE_DEBUG -DDISABLE_PCAP -DDISABLE_PNG -DEIGEN_MAX_ALIGN_BYTES=32 -DJSON_USE_IMPLICIT_CONVERSIONS=1  -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DTBB_SUPPRESS_DEPRECATED_MESSAGES -DWITH_OUSTER -DWITH_QT -DWITH_SPINNAKER -DXTENSOR_USE_TBB -DXTENSOR_USE_XSIMD -DvtkRenderingCore_AUTOINIT=\"3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)\" -/project/build -/project/src -/project/tools/lidar/pcd_browser -isystem /project/deps/include/spinnaker -isystem /usr/local/include -isystem /project/deps/include/eigen3/unsupported -isystem /project/deps/include/eigen3 -isystem /project/deps/include/pcl-1.12 -isystem /project/deps/include -isystem /usr/local/opt/[email protected]/include/vtk-8.2 -isystem /usr/local/include/opencv4 -isystem /project/build/psiact/include -isystem /usr/local/include/optional-lite -iframework /usr/local/opt/qt@5/lib -isystem /usr/local/opt/qt@5/lib/QtWidgets.framework/Headers -isystem /usr/local/opt/qt@5/lib/QtGui.framework/Headers -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /usr/local/opt/qt@5/lib/QtCore.framework/Headers -isystem /usr/local/opt/qt@5/./mkspecs/macx-clang -isystem /project/third_party/autocrane-utils/include  -Xclang -fopenmp -DWITH_OPENMP  -g -g -O0 -fno-omit-frame-pointer -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.15 -Wall -Wextra -Wnarrowing -Werror=unknown-pragmas -Werror=uninitialized -Werror=return-type -Werror=non-virtual-dtor -Werror=parentheses -Werror=old-style-cast -Wno-unused-parameter -Wno-unused-function -Wno-pragmas -Werror=format -Wunreachable-code -Wno-error=unused-variable -Wextra-semi -ferror-limit=2 -Werror=unused-private-field -Werror=return-stack-address -Werror=mismatched-new-delete -Werror=implicit-fallthrough -Wmost -msse4.2 -mfpmath=sse -march=native -mavx2 -fPIC -Xclang -fopenmp -std=gnu++14 -o CMakeFiles/execurale.dir/src/main.cpp.o -c /project/src/main.cpp",
  "file": "/project/src/main.cpp"
},

The project uses OpenMP which on Apple Clang needs the -Xclang flag before -fopenmp, which you can find in the above excerpt. However, as per :ALEInfo, the compiler invocation run by ALE does not have this flag:

  Command History:
(executable check - success) clang++
(finished - exit code 1) ['/usr/local/bin/bash', '-c', '''clang++'' -S -x c++ -o
/dev/null -iquote ''/project/src'' -DBOOST_ALL_NO_LIB -DBOOST_DATE_TIME_DYN_LINK
-DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_SERIALIZATION_DYN_LINK
-DBOOST_SYSTEM_DYN_LINK -DCORE_DEBUG -DDISABLE_PCAP -DDISABLE_PNG
-DEIGEN_MAX_ALIGN_BYTES=32 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -DQT_CORE_LIB -DQT_GUI_LIB
-DQT_WIDGETS_LIB -DTBB_SUPPRESS_DEPRECATED_MESSAGES -DWITH_OUSTER -DWITH_QT
-DWITH_SPINNAKER -DXTENSOR_USE_TBB -DXTENSOR_USE_XSIMD
-DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)"
-I ''/project/build'' -I ''/project/src'' -I ''/project/tools/lidar/pcd_browser''
-isystem ''/project/deps/include/spinnaker'' -isystem ''/usr/local/include'' -isystem
''/project/deps/include/eigen3/unsupported'' -isystem ''/project/deps/include/eigen3''
-isystem ''/project/deps/include/pcl-1.12'' -isystem ''/Users/rasmus/Documents/Psior
i/Projects/AutoCrane/autocrane-core/deps/include'' -isystem
''/usr/local/opt/[email protected]/include/vtk-8.2'' -isystem ''/usr/local/include/opencv4''
-isystem ''/Users/rasmus/Documents/Psiori/Proje
cts/AutoCrane/autocrane-core/build/psiact/include'' -isystem
''/usr/local/include/optional-lite'' -iframework ''/usr/local/opt/qt@5/lib'' -isystem
''/usr/local/opt/qt@5/lib/QtWidgets.framewo rk/Headers'' -isystem
''/usr/local/opt/qt@5/lib/QtGui.framework/Headers'' -isystem
''/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System
/Library/Frameworks/OpenGL.framework/Headers'' -isystem
''/usr/local/opt/qt@5/lib/QtCore.framework/Headers'' -isystem
''/usr/local/opt/qt@5/./mkspecs/macx-clang'' -isystem ''/Users/rasmus/Do
cuments/Psiori/Projects/AutoCrane/autocrane-core/third_party/autocrane-utils/include''
-fopenmp -DWITH_OPENMP -O0 -fno-omit-frame-pointer -isysroot
/Applications/Xcode.app/Contents/Developer
/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.15
-Wall -Wextra -Wnarrowing -Werror=unknown-pragmas -Werror=uninitialized
-Werror=return-type -Werror=non-vi rtual-dtor -Werror=parentheses -Werror=old-style-cast
-Wno-unused-parameter -Wno-unused-function -Wno-pragmas -Werror=format
-Wunreachable-code -Wno-error=unused-variable -Wextra-semi -ferro r-limit=2
-Werror=unused-private-field -Werror=return-stack-address -Werror=mismatched-new-delete
-Werror=implicit-fallthrough -Wmost -msse4.2 -mfpmath=sse -march=native -mavx2 -fPIC
-fopenm p -std=gnu++14  -Wall - <
''/var/folders/75/x51fz_v904n0d0tpdbvdcfmm0000gp/T/nvim9Zz6Kb/2/main.cpp''']
<<<OUTPUT STARTS>>>
clang: error: unsupported option '-fopenmp'

So for some reason, the flags used by ALE's compiler invocation are missing something

Reproducing the bug

  1. Make a CMakeProject that uses OpenMP and exports compilation database
  2. Configure ALE as above
  3. Open cpp file from the project
  4. ???

:ALEInfo


 Current Filetype: cpp
Available Linters: ['cc', 'ccls', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'cspell', 'flawfinder']
   Linter Aliases:
'cc' -> ['gcc', 'clang', 'g++', 'clang++']
  Enabled Linters: ['cc', 'clangtidy']
  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_cpp_cc_executable = '<auto>'
let g:ale_cpp_cc_options = '-std=c++14 -Wall'
let g:ale_cpp_clangtidy_checks = []
let g:ale_cpp_clangtidy_executable = '/usr/local/Cellar/llvm/13.0.0/bin/clang-tidy'
let g:ale_cpp_clangtidy_extra_options = '-p compile_commands.json'
let g:ale_cpp_clangtidy_options = ''
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
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 = 0
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 = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'cpp': ['clang', 'clangtidy']}
let g:ale_linters_explicit = 1
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 1
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) clang++
(finished - exit code 1) ['/usr/local/bin/bash', '-c', '''clang++'' -S -x c++ -o /dev/null -iquote ''/project/src'' -DBOOST_ALL_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DCORE_DEBUG -DDISABLE_PCAP -DDISABLE_PNG -DEIGEN_MAX_ALIGN_BYTES=32 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -DMETADATA_GIT_COMMIT_HASH=\"8b372b8b8\" -DMETADATA_HOSTNAME=\"Falcon-10\" -DMETADATA_USERNAME=\"rasmus\" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DTBB_SUPPRESS_DEPRECATED_MESSAGES -DWITH_OUSTER -DWITH_QT -DWITH_SPINNAKER -DXTENSOR_USE_TBB -DXTENSOR_USE_XSIMD -DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)" -I ''/project/build'' -I ''/project/src'' -I ''/project/tools/lidar/pcd_browser'' -isystem ''/project/deps/include/spinnaker'' -isystem ''/usr/local/include'' -isystem ''/project/deps/include/eigen3/unsupported'' -isystem ''/project/deps/include/eigen3'' -isystem ''/project/deps/include/pcl-1.12'' -isystem ''/project/deps/include'' -isystem ''/usr/local/opt/[email protected]/include/vtk-8.2'' -isystem ''/usr/local/include/opencv4'' -isystem ''/project/build/psiact/include'' -isystem ''/usr/local/include/optional-lite'' -iframework ''/usr/local/opt/qt@5/lib'' -isystem ''/usr/local/opt/qt@5/lib/QtWidgets.framework/Headers'' -isystem ''/usr/local/opt/qt@5/lib/QtGui.framework/Headers'' -isystem ''/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework/Headers'' -isystem ''/usr/local/opt/qt@5/lib/QtCore.framework/Headers'' -isystem ''/usr/local/opt/qt@5/./mkspecs/macx-clang''  -fopenmp -DWITH_OPENMP -O0 -fno-omit-frame-pointer -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.15 -Wall -Wextra -Wnarrowing -Werror=unknown-pragmas -Werror=uninitialized -Werror=return-type -Werror=non-virtual-dtor -Werror=parentheses -Werror=old-style-cast -Wno-unused-parameter -Wno-unused-function -Wno-pragmas -Werror=format -Wunreachable-code -Wno-error=unused-variable -Wextra-semi -ferror-limit=2 -Werror=unused-private-field -Werror=return-stack-address -Werror=mismatched-new-delete -Werror=implicit-fallthrough -Wmost -msse4.2 -mfpmath=sse -march=native -mavx2 -fPIC -fopenmp -std=gnu++14  -Wall - < ''/var/folders/75/x51fz_v904n0d0tpdbvdcfmm0000gp/T/nvim9Zz6Kb/2/main.cpp''']

<<<OUTPUT STARTS>>>
clang: error: unsupported option '-fopenmp'
<<<OUTPUT ENDS>>>

(executable check - success) /usr/local/Cellar/llvm/13.0.0/bin/clang-tidy
(finished - exit code 1) ['/usr/local/bin/bash', '-c', '''/usr/local/Cellar/llvm/13.0.0/bin/clang-tidy'' ''-p compile_commands.json'' ''/project/src/main.cpp'' -p ''/project''']

<<<NO OUTPUT RETURNED>>>

themightyoarfish avatar Apr 01 '22 07:04 themightyoarfish

Anyone got an idea about this? Seems to make ALE useless for any project that uses OpenMP

themightyoarfish avatar May 13 '22 08:05 themightyoarfish