H.J.,
     The clang compilers exhibit the same behavior on these test cases.

Undefined symbols for architecture x86_64:
  "_foo", referenced from:
      _main in visibility-23-e1e564.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

however if I also pass "-Wl,-undefined -Wl,dynamic_lookup" to the
linker, both test
compile and run.
     FYI, the assembly from...

/sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/xgcc
-B/sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/
/sw/src/fink.build/gcc50-5.0.0-1000/gcc-5-20150206/gcc/testsuite/gcc.dg/visibility-23.c
-fno-diagnostics-show-caret -fdiagnostics-color=never -fPIC -S -m32 -o
visibility-23.s

contains...

        .text
        .globl _main
_main:
LFB0:
        pushl   %ebp
LCFI0:
        movl    %esp, %ebp
LCFI1:
        subl    $8, %esp
        call    ___x86.get_pc_thunk.ax
L1$pb:
        leal    L_foo$non_lazy_ptr-L1$pb(%eax), %eax
        movl    (%eax), %eax
        testl   %eax, %eax
        je      L2
        call    _foo
L2:
        movl    $0, %eax
        leave
LCFI2:
        ret
LFE0:
        .weak_reference _foo
        .section __TEXT,__textcoal_nt,coalesced,pure_instructions
        .weak_definition        ___x86.get_pc_thunk.ax
        .private_extern ___x86.get_pc_thunk.ax
___x86.get_pc_thunk.ax:
LFB1:
        movl    (%esp), %eax
        ret
LFE1:
        .section
__TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
EH_frame1:
        .set L$set$0,LECIE1-LSCIE1
        .long L$set$0
LSCIE1:
        .long   0
        .byte   0x1
        .ascii "zR\0"
        .byte   0x1
        .byte   0x7c
        .byte   0x8
        .byte   0x1
        .byte   0x10
        .byte   0xc
        .byte   0x5
        .byte   0x4
        .byte   0x88
        .byte   0x1
        .align 2
LECIE1:
LSFDE1:
        .set L$set$1,LEFDE1-LASFDE1
        .long L$set$1
LASFDE1:
        .long   LASFDE1-EH_frame1
        .long   LFB0-.
        .set L$set$2,LFE0-LFB0
        .long L$set$2
        .byte   0
        .byte   0x4
        .set L$set$3,LCFI0-LFB0
        .long L$set$3
        .byte   0xe
        .byte   0x8
        .byte   0x84
        .byte   0x2
        .byte   0x4
        .set L$set$4,LCFI1-LCFI0
        .long L$set$4
        .byte   0xd
        .byte   0x4
        .byte   0x4
        .set L$set$5,LCFI2-LCFI1
        .long L$set$5
        .byte   0xc4
        .byte   0xc
        .byte   0x5
        .byte   0x4
        .align 2
LEFDE1:
LSFDE3:
        .set L$set$6,LEFDE3-LASFDE3
        .long L$set$6
LASFDE3:
        .long   LASFDE3-EH_frame1
        .long   LFB1-.
        .set L$set$7,LFE1-LFB1
        .long L$set$7
        .byte   0
        .align 2
LEFDE3:
        .section __IMPORT,__pointers,non_lazy_symbol_pointers
        .weak_reference _foo
L_foo$non_lazy_ptr:
        .indirect_symbol _foo
        .long   0
        .subsections_via_symbols


On Fri, Feb 6, 2015 at 4:41 PM, H.J. Lu <hjl.to...@gmail.com> wrote:
> On Fri, Feb 6, 2015 at 1:31 PM, Jack Howarth <howarth.at....@gmail.com> wrote:
>> H.J.,
>>     On x86_64-apple-darwin14, your patch applied to r220481 results in...
>>
>> FAIL: gcc.dg/visibility-22.c (test for excess errors)
>> FAIL: gcc.dg/visibility-23.c scan-hidden private_extern[ \t_]*_?foo
>>
>> with...
>>
>> Executing on host:
>> /sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/xgcc
>> -B/sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/
>> /sw/src/fink.build/gcc50-5.0.0-1000/gcc-5-20150206/gcc/testsuite/gcc.dg/visibility-22.c
>>  -fno-diagnostics-show-caret -fdiagnostics-color=never   -fPIC  -lm
>> -m32  -o ./visibility-22.exe    (timeout = 300)
>> spawn -ignore SIGHUP
>> /sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/xgcc
>> -B/sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/
>> /sw/src/fink.build/gcc50-5.0.0-1000/gcc-5-20150206/gcc/testsuite/gcc.dg/visibility-22.c
>> -fno-diagnostics-show-caret -fdiagnostics-color=never -fPIC -lm -m32
>> -o ./visibility-22.exe^M
>> Undefined symbols for architecture i386:^M
>>   "_foo", referenced from:^M
>>       _main in ccMD1qjz.o^M
>>       _main in ccMD1qjz.o^M
>> ld: symbol(s) not found for architecture i386^M
>> collect2: error: ld returned 1 exit status^M
>> compiler exited with status 1
>> output is:
>> Undefined symbols for architecture i386:^M
>>   "_foo", referenced from:^M
>>       _main in ccMD1qjz.o^M
>>       _main in ccMD1qjz.o^M
>> ld: symbol(s) not found for architecture i386^M
>> collect2: error: ld returned 1 exit status^M
>>
>> FAIL: gcc.dg/visibility-22.c (test for excess errors)
>>
>> Executing on host:
>> /sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/xgcc
>> -B/sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/
>> /sw/src/fink.build/gcc50-5.0.0-1000/gcc-5-20150206/gcc/testsuite/gcc.dg/visibility-23.c
>>  -fno-diagnostics-show-caret -fdiagnostics-color=never   -fPIC -S
>> -m32  -o visibility-23.s    (timeout = 300)
>> spawn -ignore SIGHUP
>> /sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/xgcc
>> -B/sw/src/fink.build/gcc50-5.0.0-1000/darwin_objdir/gcc/
>> /sw/src/fink.build/gcc50-5.0.0-1000/gcc-5-20150206/gcc/testsuite/gcc.dg/visibility-23.c
>> -fno-diagnostics-show-caret -fdiagnostics-color=never -fPIC -S -m32 -o
>> visibility-23.s^M
>> PASS: gcc.dg/visibility-23.c (test for excess errors)
>> FAIL: gcc.dg/visibility-23.c scan-hidden private_extern[ \t_]*_?foo
>>
>
> Does Darwin support undefined hidden weak symbol?
> Can you compile and gcc/testsuite/gcc.dg/visibility-22.c
> with clang on Darwin?
>
> --
> H.J.

Reply via email to