c++gcclinux-kernelllvm-clangllvm-gcc

Clang error: Cannot compile builtin function


I'm compiling a code which has GCC library extra separately added. While compiling it with clang error

cannot compile

is showing

I've tried added flags. -std=89gnu does not work with a clang. After some inspection found the same function in compiler file.

BUILTIN(__builtin_init_dwarf_reg_size_table, "vv*", "n")

Error:

gcc/unwind-dw2.c:1336:3: error: cannot compile this __builtin_init_dwarf_reg_size_table

Solution

  • That's a really weird error message, can you put the full one here? Also, I'm surprised that you want to compile libgcc with clang, I don't think anyone has really tried before. Some better repro instructions would help though as this seems to work:

    echristo@jhereg ~/tmp> cat foo.c

    char x[16]; void a() { __builtin_init_dwarf_reg_size_table(x); }
    

    echristo@jhereg ~/tmp> clang -S -o - foo.c --target=x86_64-linux-gnu

        .text
        .file   "foo.c"
        .globl  a                       # -- Begin function a
        .p2align    4, 0x90
        .type   a,@function
    a:                                      # @a
        .cfi_startproc
    # %bb.0:
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset %rbp, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register %rbp
        movb    $8, x
        movb    $8, x+1
        movb    $8, x+2
        movb    $8, x+3
        movb    $8, x+4
        movb    $8, x+5
        movb    $8, x+6
        movb    $8, x+7
        movb    $8, x+8
        movb    $8, x+9
        movb    $8, x+10
        movb    $8, x+11
        movb    $8, x+12
        movb    $8, x+13
        movb    $8, x+14
        movb    $8, x+15
        movb    $8, x+16
        popq    %rbp
        .cfi_def_cfa %rsp, 8
        retq
    .Lfunc_end0:
        .size   a, .Lfunc_end0-a
        .cfi_endproc
                                            # -- End function
        .type   x,@object               # @x
        .comm   x,16,16
    
        .ident  "clang version 9.0.0 (https://github.com/llvm/llvm-project.git b669fea42f5c2a5b203c3f0da2a6b04b90bfd5a7)"
        .section    ".note.GNU-stack","",@progbits
        .addrsig
        .addrsig_sym x