Cannot run clangtidy on Manjaro

Hello everybody,
I recently moved from Mint to Manjaro, I’m running PlatformIO as VSCode plugin, I can compile, upload and manage my projects just fine but clangtidy checks is not working, it was working on Mint, I don’t know if the problem is Manjaro (that uses newer Clang and newer libraries, if it does matter…) or an update to PlatformIO that broke it.

VS Code version:

Version: 1.45.0
Commit: d69a79b73808559a91206d73d7717ff5f798f23c
Date: 2020-05-07T16:10:24.511Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
Operating system: Linux x64 5.6.11-1-MANJARO

PlatformIO version:

PlatformIO, version 4.3.3

System clang version:

clang version 10.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

platformio.ini (checks part only):

check_tool = clangtidy
check_flags =
clangtidy: -std=c++17 --checks=*
check_severity = low, medium, high

pio check --verbose command output (I trimmed some of the huge output)t:

Checking release > clangtidy (platform: https://github.com/platformio/platform-atmelavr.git; framework: arduino; board: controllino_maxi)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/labo/.platformio/packages/tool-clangtidy/clang-tidy --quiet -std=c++17 --checks=* /home/labo/Documenti/git-repos/lsh-arduino/src/device.cpp *TRIMMED: OTHER FILES* -- -DPLATFORMIO=40303 *TRIMMED: OTHER DFLAGS* --extra-arg=@"/tmp/tmphaqjzmwi"
LLVM ERROR: CommonOptionsParser: failed to parse command-line arguments. [CommonOptionsParser]: error: unsupported option '--extra-arg=@"/tmp/tmphaqjzmwi"'


Error: clangtidy failed to perform check! Please examine tool output in verbose mode.
============================================================================= [FAILED] Took 0.01 seconds =============================================================================

Environment    Tool       Status    Duration
-------------  ---------  --------  ------------
release        clangtidy  FAILED    00:00:00.015
debug          clangtidy  IGNORED
======================================================================= 1 failed, 0 succeeded in 00:00:00.015 =======================================================================

The problem is --extra-arg=@"/tmp/tmphaqjzmwi" since:

  • That file does not exist, I double checked, but since it’s on tmp it’s maybe destroied when the command exits, I don’t know.
  • It’s not a correct argument for clang-tidy

How can I solve my problem?

I run Manjaro as my linux install, so I’ll see if I can reproduce that when I boot into it next… will probably be tomorrow.

1 Like

Right, so first up, it’s not a Manjaro issue, as PlatformIO still uses it’s own bundled version of clangtidy on Manjaro. i.e., if you look at the top of the error message, it tells you it’s using /home/labo/.platformio/packages/tool-clangtidy/clang-tidy … not the system copy…

However, the version that PlatformIO uses is still v10…

LLVM (http://llvm.org/):
  LLVM version 10.0.0
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: westmere

But, -std is not a valid parameter for clang-tidy. When I removed just that flag, it ran as it should. So the bit of the errror about failed to parse command-line arguments is about the parameters given…

It looks like it needs to given via the -extra-arg= parameter… like this:

check_flags =
   clangtidy: -extra-arg=-std=c++17 --checks=*
1 Like

Thanks for your kind reply, in fact that was the problem!

1 Like