Skip to content

execinfo.h is not available on MUSLΒ #2397

Closed

Description

@radare

V version:
OS:

What did you do?

try to build v for musl,

What did you expect to see?

a working build

What did you see instead?

a failure because the current ifndef is only for BIONIC

in fact execinfo is a gnuism, so it should be guarded like this:

#if (__linux__ && __GNU_LIBRARY__) || defined(NETBSD_WITH_BACKTRACE) || \
  defined(FREEBSD_WITH_BACKTRACE) || __DragonFly__
# include <execinfo.h>
#endif

IMG_1046

Activity

  1. added
    BugThis tag is applied to issues which reports bugs.
    on Oct 17, 2019
  2. unknown-v commented on Oct 18, 2019

    @unknown-v
    Contributor

    alpineLinux has libexecinfo
    donΒ΄t know about other musl based distros.

  3. radare commented on Oct 19, 2019

    @radare
    ContributorAuthor

    FED6CE15-EFF6-4825-9AD5-6ADE24555F1C

  4. joe-conigliaro commented on Oct 19, 2019

    @joe-conigliaro
    Member

    @radare Good point. Aldo the current backtrace implementation rely's on functions from it, we should have a minimal or different backtrace implementation when it isn't available (or no backtrace in that case)

  5. unknown-v commented on Oct 19, 2019

    @unknown-v
    Contributor

    @radare

    Step 1/12 : FROM alpine:3.10.2
     ---> 961769676411
    Step 2/12 : RUN         apk update apk upgrade &&       apk add --update gcc make       git musl-dev libexecinfo-dev    &&      mkdir -p 
    /opt/v && cd /opt/v &&  git clone --quiet https://github.com/vlang/v .
     ---> Running in d45130455ecd
    fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
    fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
    v3.10.2-189-g393dc02e8c [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
    v3.10.2-189-g393dc02e8c [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
    OK: 10337 distinct packages available
    (1/20) Installing binutils (2.32-r0)
    Step 3/12 : WORKDIR /opt/v
     ---> Running in 912eb8788caa
    Removing intermediate container 912eb8788caa
     ---> 65d6a05e7ec2
    Step 4/12 : RUN CC=gcc LDFLAGS=-lexecinfo make MAKE_VERBOSE=1
     ---> Running in 7b52a241035b
    rm -rf vc/
    git clone --depth 1 --quiet https://github.com/vlang/vc
    rm -rf /var/tmp/tcc/
    git clone --depth 1 --quiet https://github.com/vlang/tccbin /var/tmp/tcc
    gcc -std=gnu11 -w -o v vc/v.c -lexecinfo -lm
    rm -rf vc/
    V has been successfully built
    Removing intermediate container 7b52a241035b
    
  6. radare commented on Oct 19, 2019

    @radare
    ContributorAuthor

    Ok i manage to compile it by adding the LDFLAGS=-lexecinfo env var but then it fails to do anything because:

    • theres no way to add -lexecinfo when compiling with v (theres -cflags but not -ldflags)
    • tcc fails hard. But using -cc gcc seems to work, is there a way to force this at compile time? May be better to fix tcc anyway

    B898D1D3-2766-4C8C-A5F2-3E22EAB3F1E0

  7. radare commented on Oct 19, 2019

    @radare
    ContributorAuthor

    3670BD72-625D-4CB9-AAFF-499D52BC1494
    023109BF-C7ED-46EA-A311-0CCEDD3905ED

  8. unknown-v commented on Oct 19, 2019

    @unknown-v
    Contributor

    tcc fails hard. But using -cc gcc seems to work, is there a way to force this at compile time?

    export VFLAGS="-cc gcc"

  9. bogen85 commented on Oct 23, 2019

    @bogen85
    Member

    I got tcc to work by replacing what what was put in tmp.

    $ cat /var/tmp/tcc/bin/tcc 
    #!/usr/bin/env bash
    
    tcc $@ -lexecinfo

    What was put in tmp for tcc by the v update process did not work for me anyways on alpine.

  10. medvednikov commented on Oct 23, 2019

    @medvednikov
    Member

    @bogen85 so tcc works with musl with -lexecinfo?

  11. bogen85 commented on Oct 23, 2019

    @bogen85
    Member

    @medvednikov well, compiles and links on alpine with -lexecinfo... (and a lot works) but backtrace does not... See #2508

  12. added this to the Beta Release milestone on Apr 6, 2020
  13. added
    Unit: CompilerBugs/feature requests, that are related to the V compiler in general.
    Unit: vlibBugs/feature requests, that are related to the vlib.
    Status: ConfirmedThis bug has been confirmed to be valid by a contributor.
    on Apr 6, 2020
  14. comcloudway commented on Dec 6, 2022

    @comcloudway

    alpineLinux has libexecinfo donΒ΄t know about other musl based distros.

    With Alpine Linux 3.17, they apparently removed libexecinfo-dev

    Manually building and installing https://github.com/ronchaine/libexecinfo fixes the execinfo.h error though

  15. removed this from the Beta Release milestone on May 26, 2023
  16. Brixy commented on Aug 8, 2024

    @Brixy

    I just tried to compile V on chimera linux and got the following error:

    clang -g -std=gnu11 -w -o v1 vc/v.c -lm -lexecinfo -lpthread 
    ld: error: unable to find library -lexecinfo
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    *** Error code 1
    

    After compiling and installing the libexecinfo library (repo has been archived!) the error message when compiling V changed to

    Details
    cc -pipe -g -std=gnu11 -w -o v1 vc/v.c -lm -lexecinfo -lpthread 
    ./v1 -no-parallel -o v2 -cc gcc cmd/v
    ================== C compilation error (from gcc): ==============
    cc: /tmp/v_1000/v2.01J4S9AQENEY9DHCEQC23JYGSS.tmp.c:21879:19: error: call to undeclared function 'backtrace'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    cc:  21879 |                                 int nr_ptrs = backtrace(&buffer[0], 100);
    cc:        |                                               ^
    cc: /tmp/v_1000/v2.01J4S9AQENEY9DHCEQC23JYGSS.tmp.c:21886:23: error: call to undeclared function 'backtrace_symbols'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    cc:  21886 |                                 char** csymbols = backtrace_symbols(((voidptr)(&buffer[v_fixed_index(skipframes, 100)])), nr_actual_frames);
    cc:        |                                                   ^
    cc: /tmp/v_1000/v2.01J4S9AQENEY9DHCEQC23JYGSS.tmp.c:21886:12: error: incompatible integer to pointer conversion initializing 'char **' with an expression of type 'int' [-Wint-conversion]
    cc:  21886 |                                 char** csymbols = backtrace_symbols(((voidptr)(&buffer[v_fixed_index(skipframes, 100)])), nr_actual_frames);
    cc:        |                                        ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc: /tmp/v_1000/v2.01J4S9AQENEY9DHCEQC23JYGSS.tmp.c:29920:4: warning: expression result unused [-Wunused-value]
    cc:  29920 |   (*(string*)_t3.data);
    cc:        |    ^~~~~~~~~~~~~~~~~~
    ... (the original output was 244 lines long, and was truncated to 12 lines)
    =================================================================
    (You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
    builder error: 
    ==================
    C error found. It should never happen, when compiling pure V code.
    This is a V compiler bug, please report it using `v bug file.v`,
    or goto https://github.com/vlang/v/issues/new/choose .
    You can also use #help on Discord: https://discord.gg/vlang .
    *** Error code 1
    

    Does anyone have any other ideas on how to get this to work reliably on a modern musl based distro? Thank you very much!

    P.S.: Compiling V on alpine works.

  17. medvednikov commented on Aug 9, 2024

    @medvednikov
    Member

    I think we only tested musl builds on alpine.

    execinfo is a common source of issues, would be best to avoid this dep.

  18. Brixy commented on Dec 27, 2024

    @Brixy

    Hello guys,

    I just tried again to compile and run V on Chimera Linux, and it working perfectly now. But I don't know whether anything relevant in V, execinfo or Chimera has changed.

    doas apk add gmake clang musl-devel
    
    make
    
    ./v
    
    >> Welcome to the V REPL ...
    
  19. added 3 commits that reference this issue on Feb 26, 2026
    ad162b7
    1dd5d5f
    9c8dbba
  20. added 3 commits that reference this issue on Mar 10, 2026
    f10fa1b
    cc1d023
    6b33de0
  21. added a commit that references this issue on Mar 10, 2026
    b66fc98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Unit: vlibBugs/feature requests, that are related to the vlib.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions