Menu

Cppcheck doesn't build with musl libc

ams21
2026-03-06
2026-03-06
  • ams21

    ams21 - 2026-03-06

    I've noticed since version 2.19.0 building with musl libc (alpine for example). I get the following error:

    /dev/cppcheck/cli/stacktrace.cpp:29:10: fatal error: execinfo.h: No such file or directory
       29 | #include <execinfo.h>
          |          ^~~~~~~~~~~~
    

    But using the following patch it works:

    diff --git a/lib/config.h b/lib/config.h
    index a63cf773d..d29e630f6 100644
    --- a/lib/config.h
    +++ b/lib/config.h
    @@ -206,7 +206,7 @@
     #define USE_WINDOWS_SEH
     #endif
    
    -#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(__GNUC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX)
    +#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(__GNUC__) && defined(__GLIBC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX)
     #define USE_UNIX_BACKTRACE_SUPPORT
     #endif
    

    Not sure if this is the appropriate fix but reading this it mentions explicitly that execinfo.h is not available on the following platforms: musl libc, FreeBSD 9.3, NetBSD 6.1, OpenBSD 6.9, Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 10, Cygwin, mingw, MSVC 14, Android 9.0

     
  • CHR

    CHR - 2026-03-06

    If you want this merged, please open a PR at https://github.com/danmar/cppcheck/pulls

     

Log in to post a comment.

MongoDB Logo MongoDB