vtable `llvm::raw_string_ostream` missing from assembly on powerpc-darwin8 (MC)
| Bugzilla Link | 14579 |
| Version | trunk |
| OS | MacOS X |
| Reporter | LLVM Bugzilla Contributor |
| CC | @hfinkel,@iains,@isanbard |
Extended Description
from bug 14387 (originally about .line directives in asm):
I built r169799 on powerpc-darwin8, and started a stage 2 build using -gdwarf2 -no-integrated-as.
[ 0%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o
cd /Users/fang/local/src/LLVM-svn/gcc40-stage2-build/lib/Support && /Volumes/Isolde/sources/LLVM-svn/gcc40-cmake-build/bin/clang++ -DLLVMSupport_EXPORTS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-common -no-integrated-as -fPIC -fvisibility-inlines-hidden -fno-rtti -O2 -gdwarf2 -fPIC -I/Users/fang/local/src/LLVM-svn/gcc40-stage2-build/lib/Support -I/Users/fang/local/src/LLVM-svn/llvm/lib/Support -I/Users/fang/local/src/LLVM-svn/gcc40-stage2-build/include -I/Users/fang/local/src/LLVM-svn/llvm/include -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fno-exceptions -o CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o -c /Users/fang/local/src/LLVM-svn/llvm/lib/Support/CommandLine.cpp
clang-3: warning: argument unused during compilation: '-gdwarf2'
/tmp/CommandLine-qnrm7J.s:11052:non-relocatable subtraction expression, "__ZTVN4llvm18raw_string_ostreamE" minus "L95$pb"
/tmp/CommandLine-qnrm7J.s:11052:symbol: "__ZTVN4llvm18raw_string_ostreamE" can't be undefined in a subtraction expression
/tmp/CommandLine-qnrm7J.s:11051:non-relocatable subtraction expression, "__ZTVN4llvm18raw_string_ostreamE" minus "L95$pb"
/tmp/CommandLine-qnrm7J.s:11051:symbol: "__ZTVN4llvm18raw_string_ostreamE" can't be undefined in a subtraction expression
/tmp/CommandLine-qnrm7J.s:10812:non-relocatable subtraction expression, "__ZTVN4llvm18raw_string_ostreamE" minus "L94$pb"
/tmp/CommandLine-qnrm7J.s:10812:symbol: "__ZTVN4llvm18raw_string_ostreamE" can't be undefined in a subtraction expression
/tmp/CommandLine-qnrm7J.s:10811:non-relocatable subtraction expression, "__ZTVN4llvm18raw_string_ostreamE" minus "L94$pb"
/tmp/CommandLine-qnrm7J.s:10811:symbol: "__ZTVN4llvm18raw_string_ostreamE" can't be undefined in a subtraction expression
Apparently, llvm::raw_string_ostream is unimplemented (MC) for powerpc-darwin8.
Note: Iain and Rafael discussed this issue offline, and Rafael committed r220580 (trunk, 3.6) that helps with this, by introducing isDeclarationForLinker. Modernized patch would need to call that instead.
I am currently testing bootstrap on 3.4.2 on powerpc-darwin8 with the previous patch...
Well, it did manage to bootstrap 3.4.2 through all 3 stages (even a 4th stage) at -O2 -no-integrated-as, but LLVM and clang tests fared worse than stage1's. Still, this is progress!
I noticed that trunk cleaned up with calls to
bool isDecl = GV->isDeclaration();
there is now a GlobalValue::isDeclarationForLinker() that essentially does hasAvailableExternallyLinkage() || isDeclaration().
Should we now use:
bool isDecl = GV->isDeclarationForLinker();
at the same spot in PPCSubtarget.cpp?
Very likely yes, that is what every other backend is doing I think.
Note: Iain and Rafael discussed this issue offline, and Rafael committed r220580 (trunk, 3.6) that helps with this, by introducing isDeclarationForLinker. Modernized patch would need to call that instead.
I am currently testing bootstrap on 3.4.2 on powerpc-darwin8 with the previous patch...
Well, it did manage to bootstrap 3.4.2 through all 3 stages (even a 4th stage) at -O2 -no-integrated-as, but LLVM and clang tests fared worse than stage1's. Still, this is progress!
I noticed that trunk cleaned up with calls to
bool isDecl = GV->isDeclaration();
there is now a GlobalValue::isDeclarationForLinker() that essentially does hasAvailableExternallyLinkage() || isDeclaration().
Should we now use:
bool isDecl = GV->isDeclarationForLinker();
at the same spot in PPCSubtarget.cpp?
Note: Iain and Rafael discussed this issue offline, and Rafael committed r220580 (trunk, 3.6) that helps with this, by introducing isDeclarationForLinker. Modernized patch would need to call that instead.
I am currently testing bootstrap on 3.4.2 on powerpc-darwin8 with the previous patch...
Iain shared with me this patch, which allows the test case in comment 30 to pass at -O1! Iain intends to submit this upstream. Huzzah!
diff --git a/lib/Target/PowerPC/PPCSubtarget.cpp b/lib/Target/PowerPC/PPCSubtarget.cpp index d6b964d..fa46f91 100644 --- a/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/lib/Target/PowerPC/PPCSubtarget.cpp @@ -182,7 +182,8 @@ bool PPCSubtarget::hasLazyResolverStub(const GlobalValue *GV, return false; // If symbol visibility is hidden, the extra load is not needed if // the symbol is definitely defined in the current translation unit.
- bool isDecl = GV->isDeclaration() && !GV->isMaterializable();
- bool isDecl = (GV->isDeclaration() && !GV->isMaterializable()) ||
-
if (GV->hasHiddenVisibility() && !isDecl && !GV->hasCommonLinkage()) return false; return GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||GV->hasAvailableExternallyLinkage();
Not sure if this helps, but for comparison, gcc-4.0 -O1 gives the following asm:
% gcc -v -save-temps -O1 -DPIC -fno-common -c llvm/llvm-bugzilla-archive#14579 b.cpp -o llvm/llvm-bugzilla-archive#14579 .gcc-o Using built-in specs. Target: powerpc-apple-darwin8 Configured with: /var/tmp/gcc/gcc-5370~2/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8 Thread model: posix gcc version 4.0.1 (Apple Computer, Inc. build 5370) /usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/cc1plus -E -quiet -v -D__DYNAMIC__ -DPIC llvm/llvm-bugzilla-archive#14579 b.cpp -fPIC -fno-common -O1 -fpch-preprocess -D__private_extern__=extern -o llvm/llvm-bugzilla-archive#14579 b.ii ignoring nonexistent directory "/usr/local/include" ignoring nonexistent directory "/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../../powerpc-apple-darwin8/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.0.0 /usr/include/c++/4.0.0/powerpc-apple-darwin8 /usr/include/c++/4.0.0/backward /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include /usr/include /System/Library/Frameworks /Library/Frameworks End of search list. /usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/cc1plus -fpreprocessed llvm/llvm-bugzilla-archive#14579 b.ii -fPIC -quiet -dumpbase llvm/llvm-bugzilla-archive#14579 b.cpp -auxbase-strip llvm/llvm-bugzilla-archive#14579 .gcc-o -O1 -version -fno-common -D__private_extern__=extern -o llvm/llvm-bugzilla-archive#14579 b.s GNU C++ version 4.0.1 (Apple Computer, Inc. build 5370) (powerpc-apple-darwin8) compiled by GNU C version 4.0.1 (Apple Computer, Inc. build 5370). GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 83c106e4a4e660b766abd877880d9b62 /usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/as -arch ppc -o llvm/llvm-bugzilla-archive#14579 .gcc-o llvm/llvm-bugzilla-archive#14579 b.s
% cat llvm/llvm-bugzilla-archive#14579 b.s .section __TEXT,__text,regular,pure_instructions .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 .machine ppc .mod_init_func .align 2 .long _GLOBAL__I#14579 b.cpp_00000000_9A6A7F1F .lcomm _foo,1,0 .section __TEXT,__StaticInit,regular,pure_instructions .align 2 __Z41__static_initialization_and_destruction_0ii: LFB7: mflr r0 LCFI0: stw r31,-4(r1) LCFI1: stw r0,8(r1) LCFI2: stwu r1,-80(r1) LCFI3: bcl 20,31,"L00000000001$pb" "L00000000001$pb": mflr r31 li r0,0 ori r0,r0,65535 cmpw cr7,r4,r0 bne cr7,L5 cmpwi cr7,r3,1 bne cr7,L5 addis r3,r31,ha16(___tcf_0-"L00000000001$pb") la r3,lo16(___tcf_0-"L00000000001$pb")(r3) li r4,0 addis r5,r31,ha16(L___dso_handle$non_lazy_ptr-"L00000000001$pb") lwz r5,lo16(L___dso_handle$non_lazy_ptr-"L00000000001$pb")(r5) bl L___cxa_atexit$stub L5: addi r1,r1,80 lwz r0,8(r1) mtlr r0 lwz r31,-4(r1) blr LFE7: .text .align 2 ___tcf_0: LFB8: mflr r0 LCFI4: stw r31,-4(r1) LCFI5: stw r0,8(r1) LCFI6: stwu r1,-80(r1) LCFI7: bcl 20,31,"L00000000002$pb" "L00000000002$pb": mflr r31 addis r3,r31,ha16(_foo-"L00000000002$pb") la r3,lo16(_foo-"L00000000002$pb")(r3) bl L__ZN12basic_stringIcE7nothingEv$stub addi r1,r1,80 lwz r0,8(r1) mtlr r0 lwz r31,-4(r1) blr LFE8: .section __TEXT,__StaticInit,regular,pure_instructions .align 2 _GLOBAL__I#14579 b.cpp_00000000_9A6A7F1F: LFB12: mflr r0 LCFI8: stw r0,8(r1) LCFI9: stwu r1,-80(r1) LCFI10: li r3,1 li r4,0 ori r4,r4,65535 bl __Z41__static_initialization_and_destruction_0ii addi r1,r1,80 lwz r0,8(r1) mtlr r0 blr LFE12: __Z41__static_initialization_and_destruction_0ii.eh = 0 .no_dead_strip __Z41__static_initialization_and_destruction_0ii.eh _GLOBAL__I#14579 b.cpp_00000000_9A6A7F1F.eh = 0 .no_dead_strip _GLOBAL__I#14579 b.cpp_00000000_9A6A7F1F.eh .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 0x0 .byte 0x1 .ascii "zPR\0" .byte 0x1 .byte 0x7c .byte 0x41 .byte 0x6 .byte 0x9b .long L___gxx_personality_v0$non_lazy_ptr-. .byte 0x10 .byte 0xc .byte 0x1 .byte 0x0 .align 2 LECIE1: ___tcf_0.eh: LSFDE3: .set L$set$1,LEFDE3-LASFDE3 .long L$set$1 LASFDE3: .long LASFDE3-EH_frame1 .long LFB8-. .set L$set$2,LFE8-LFB8 .long L$set$2 .byte 0x0 .byte 0x4 .set L$set$3,LCFI7-LFB8 .long L$set$3 .byte 0xe .byte 0x50 .byte 0x9f .byte 0x1 .byte 0x11 .byte 0x41 .byte 0x7e .align 2 LEFDE3: .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 .align 5 L__ZN12basic_stringIcE7nothingEv$stub: .indirect_symbol __ZN12basic_stringIcE7nothingEv mflr r0 bcl 20,31,"L00000000001$spb" "L00000000001$spb": mflr r11 addis r11,r11,ha16(L__ZN12basic_stringIcE7nothingEv$lazy_ptr-"L00000000001$spb") mtlr r0 lwzu r12,lo16(L__ZN12basic_stringIcE7nothingEv$lazy_ptr-"L00000000001$spb")(r11) mtctr r12 bctr .lazy_symbol_pointer L__ZN12basic_stringIcE7nothingEv$lazy_ptr: .indirect_symbol __ZN12basic_stringIcE7nothingEv .long dyld_stub_binding_helper .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 .align 5 L___cxa_atexit$stub: .indirect_symbol ___cxa_atexit mflr r0 bcl 20,31,"L00000000002$spb" "L00000000002$spb": mflr r11 addis r11,r11,ha16(L___cxa_atexit$lazy_ptr-"L00000000002$spb") mtlr r0 lwzu r12,lo16(L___cxa_atexit$lazy_ptr-"L00000000002$spb")(r11) mtctr r12 bctr .lazy_symbol_pointer L___cxa_atexit$lazy_ptr: .indirect_symbol ___cxa_atexit .long dyld_stub_binding_helper .non_lazy_symbol_pointer L___dso_handle$non_lazy_ptr: .indirect_symbol ___dso_handle .long 0 L___gxx_personality_v0$non_lazy_ptr: .indirect_symbol ___gxx_personality_v0 .long 0 .constructor .destructor .align 1 .subsections_via_symbols
Reduced test case:
% cat llvm/llvm-bugzilla-archive#14579 b.ii
template
invocation: % /Volumes/Isolde/sources/LLVM-svn/gcc40-cmake-build/bin/clang++ -v -O1 -fno-common -no-integrated-as -save-temps -fPIC -o llvm/llvm-bugzilla-archive#14579 b.o -c llvm/llvm-bugzilla-archive#14579 b.ii clang version 3.4 Target: powerpc-apple-darwin8.11.0 Thread model: posix "/Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/clang-3.5" -cc1 -triple powerpc-apple-macosx10.4.0 -S -disable-free -main-file-name llvm/llvm-bugzilla-archive#14579 b.ii -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -target-cpu ppc -v -coverage-file /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support/#14579 b.s -resource-dir /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.4 -O1 -fdeprecated-macro -fno-dwarf2-cfi-asm -fno-dwarf-directory-asm -fno-autolink -fdebug-compilation-dir /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support -ferror-limit 19 -fmessage-length 80 -mstackrealign -fblocks -fblocks-runtime-optional -fobjc-runtime=macosx-fragile-10.4.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fno-common -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o llvm/llvm-bugzilla-archive#14579 b.s -x c++-cpp-output llvm/llvm-bugzilla-archive#14579 b.ii clang -cc1 version 3.4 based upon LLVM 3.4git-bb410b7 default target powerpc-apple-darwin8.11.0 ignoring nonexistent directory "/usr/local/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.0.0 /usr/include/c++/4.0.0/powerpc-apple-darwin8 /usr/include/c++/4.0.0/backward /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.4/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/usr/bin/as" -arch ppc -o llvm/llvm-bugzilla-archive#14579 b.o llvm/llvm-bugzilla-archive#14579 b.s llvm/llvm-bugzilla-archive#14579 b.s:21:non-relocatable subtraction expression, "__ZN12basic_stringIcED1Ev" minus "L0$pb" llvm/llvm-bugzilla-archive#14579 b.s:21:symbol: "__ZN12basic_stringIcED1Ev" can't be undefined in a subtraction expression llvm/llvm-bugzilla-archive#14579 b.s:18:non-relocatable subtraction expression, "__ZN12basic_stringIcED1Ev" minus "L0$pb" llvm/llvm-bugzilla-archive#14579 b.s:18:symbol: "__ZN12basic_stringIcED1Ev" can't be undefined in a subtraction expression clang-3.5: error: assembler command failed with exit code 1 (use -v to see invocation)
assembly: % cat llvm/llvm-bugzilla-archive#14579 b.s .machine ppc .section __TEXT,__textcoal_nt,coalesced,pure_instructions .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 .section __TEXT,__text,regular,pure_instructions .section __TEXT,__StaticInit,regular,pure_instructions .align 4 ___cxx_global_var_init: ; @__cxx_global_var_init ; BB#0: ; %entry mflr r0 stw r31, -4(r1) stw r0, 8(r1) stwu r1, -64(r1) bl L0$pb L0$pb: mr r31, r1 mflr r2 addis r3, r2, ha16(L___dso_handle$non_lazy_ptr-L0$pb) addis r4, r2, ha16(__ZN12basic_stringIcED1Ev-L0$pb) addis r2, r2, ha16(__ZL3foo-L0$pb) lwz r5, lo16(L___dso_handle$non_lazy_ptr-L0$pb)(r3) la r3, lo16(__ZN12basic_stringIcED1Ev-L0$pb)(r4) la r4, lo16(__ZL3foo-L0$pb)(r2) bl L___cxa_atexit$stub addi r1, r1, 64 lwz r0, 8(r1) lwz r31, -4(r1) mtlr r0 blr
.align 4
__GLOBAL__I_a: ; @_GLOBAL__I_a ; BB#0: ; %entry mflr r0 stw r31, -4(r1) stw r0, 8(r1) stwu r1, -64(r1) mr r31, r1 bl ___cxx_global_var_init addi r1, r1, 64 lwz r0, 8(r1) lwz r31, -4(r1) mtlr r0 blr
.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
.align 4
L___cxa_atexit$stub: .indirect_symbol ___cxa_atexit mflr r0 bcl 20, 31, L___cxa_atexit$stub$tmp L___cxa_atexit$stub$tmp: mflr r11 addis r11, r11, ha16(L___cxa_atexit$lazy_ptr-L___cxa_atexit$stub$tmp) mtlr r0 lwzu r12, lo16(L___cxa_atexit$lazy_ptr-L___cxa_atexit$stub$tmp)(r11) mtctr r12 bctr .section __DATA,__la_symbol_ptr,lazy_symbol_pointers L___cxa_atexit$lazy_ptr: .indirect_symbol ___cxa_atexit .long dyld_stub_binding_helper
.section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
.align 2
L___dso_handle$non_lazy_ptr: .indirect_symbol ___dso_handle .long 0
.subsections_via_symbols .zerofill __DATA,__bss,__ZL3foo,1,0 ; @_ZL3foo .section __DATA,__mod_init_func,mod_init_funcs .align 2 .long __GLOBAL__I_a
Though not preprocessed, the following test case triggers the problem:
#include
% /Volumes/Isolde/sources/LLVM-svn/gcc40-cmake-build/bin/clang++
-DLLVMSupport_EXPORTS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-I/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include
-O1 -fno-common -no-integrated-as -fno-dwarf2-cfi-asm -save-temps -fPIC
-fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings
-pedantic -Wno-long-long -Wnon-virtual-dtor -fno-rtti
-isysroot /Developer/SDKs/MacOSX10.4u.sdk -fPIC
-I/Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support
-I/Users/fang/local/src/LLVM-svn/llvm/lib/Support
-I/Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/include
-I/Users/fang/local/src/LLVM-svn/llvm/include
-fno-exceptions
-o CMakeFiles/LLVMSupport.dir/Debug-reduce.cpp.o
-c /Users/fang/local/src/LLVM-svn/llvm/lib/Support/Debug-reduce.cpp
Debug-reduce.s:27:non-relocatable subtraction expression, "__ZNSsD1Ev" minus "L0$pb"
Debug-reduce.s:27:symbol: "__ZNSsD1Ev" can't be undefined in a subtraction expression
Debug-reduce.s:24:non-relocatable subtraction expression, "__ZNSsD1Ev" minus "L0$pb"
Debug-reduce.s:24:symbol: "__ZNSsD1Ev" can't be undefined in a subtraction expression
clang-3.5: error: assembler command failed with exit code 1 (use -v to see invocation)
I can reduce further...
working asm with -O1 -no-use-cxa-atexit Hi Tobias, thanks for the references. I tried your workaround -fno-use-cxa-atexit, and it compiled successfully, with the attached -save-temps .s asm, emitting a stub and lazy-ptr for __ZNSsD1Ev. Does this indicate what a proper fix could be?
Does it work when passing "-fno-use-cxa-atexit" to clang? That might be a workaround.
Glad to see progress in PowerPC Clang - looking forward to having a decent Objective-C++ compiler for PowerPC OS X (gcc doesn't seem to do that job well enough for something as complex as WebKit).
The problematic code is part of the global constructor for std::basic_string and wants to pass the destructor's address to cxa_exit(). And there is also a correctly generated lazy reference to that same destructor (and the corresponding constructor) in the code. The Mach-O docs say that "The compiler generates non-lazy symbol references for data symbols or function addresses." (see link at the bottom), which is what it might want to do here. But the Mach-O docs also say that "The compiler generates lazy symbol references when it encounters a call to a function defined in another file.", which is why there is a lazy reference in the generated code, used for calling the destructor directly from other parts of the code. Linking to the same symbol lazily and non-lazily in one compilation unit doesn't seem to make sense to me (although it might actually work). Maybe that's confusing the compiler as well. I'd think function calls should also use a non-lazy reference in case some other code in the compilation unit needs to get the address of the same function (needing a non-lazy reference).
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/indirect_addressing.html
another bad asm at -O1 Perhaps I got excited to soon. Elsewhere in stage-2 of powerpc-darwin8 at -O1:
make[2]: Entering directory /Volumes/Isolde/builds/LLVM/gcc40-stage2-opt-build' /Volumes/Mercedes2/sw/bin/cmake -E cmake_progress_report /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/CMakeFiles [ 0%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Debug.cpp.o cd /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support && /Volumes/Isolde/sources/LLVM-svn/gcc40-cmake-build/bin/clang++ -DLLVMSupport_EXPORTS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include -O1 -fno-common -no-integrated-as -fno-dwarf2-cfi-asm -save-temps -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -Wnon-virtual-dtor -fno-rtti -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fPIC -I/Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support -I/Users/fang/local/src/LLVM-svn/llvm/lib/Support -I/Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/include -I/Users/fang/local/src/LLVM-svn/llvm/include -fno-exceptions -o CMakeFiles/LLVMSupport.dir/Debug.cpp.o -c /Users/fang/local/src/LLVM-svn/llvm/lib/Support/Debug.cpp Debug.s:214:non-relocatable subtraction expression, "__ZNSsD1Ev" minus "L8$pb" Debug.s:214:symbol: "__ZNSsD1Ev" can't be undefined in a subtraction expression Debug.s:211:non-relocatable subtraction expression, "__ZNSsD1Ev" minus "L8$pb" Debug.s:211:symbol: "__ZNSsD1Ev" can't be undefined in a subtraction expression clang-3.5: error: assembler command failed with exit code 1 (use -v to see invocation) make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/Debug.cpp.o] Error 1 make[2]: Leaving directory /Volumes/Isolde/builds/LLVM/gcc40-stage2-opt-build'
make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2
make[1]: Leaving directory `/Volumes/Isolde/builds/LLVM/gcc40-stage2-opt-build'
make: *** [all] Error 2
% echo __ZNSsD1Ev | c++filt
std::basic_string<char, std::char_traits
Using a slightly newer assembler from odcctools-2009 doesn't help either.
compiled with -v shows: "/Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/clang-3.5" -cc1 -triple powerpc-apple-macosx10.4.0 -E -disable-free -main-file-name Debug.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -v -coverage-file /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support/Debug.ii -resource-dir /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.5 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -D LLVMSupport_EXPORTS -D _DEBUG -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include -I /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support -I /Users/fang/local/src/LLVM-svn/llvm/lib/Support -I /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/include -I /Users/fang/local/src/LLVM-svn/llvm/include -O1 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-long-long -Wnon-virtual-dtor -pedantic -fdeprecated-macro -fno-dwarf2-cfi-asm -fno-dwarf-directory-asm -fno-autolink -fdebug-compilation-dir /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support -ferror-limit 19 -fmessage-length 100 -fvisibility-inlines-hidden -mstackrealign -fblocks -fblocks-runtime-optional -fno-rtti -fobjc-runtime=macosx-10.4.0 -fencode-extended-block-signature -fno-common -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o Debug.ii -x c++ /Users/fang/local/src/LLVM-svn/llvm/lib/Support/Debug.cpp clang -cc1 version 3.5 based upon LLVM 3.5git-5247dc3 default target powerpc-apple-darwin8.11.0 ignoring nonexistent directory "/Developer/SDKs/MacOSX10.4u.sdk/usr/local/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support /Users/fang/local/src/LLVM-svn/llvm/lib/Support /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/include /Users/fang/local/src/LLVM-svn/llvm/include /Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0 /Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/powerpc-apple-darwin8 /Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/backward /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.5/include /Developer/SDKs/MacOSX10.4u.sdk/usr/include /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks (framework directory) /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks (framework directory) End of search list. "/Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/clang-3.5" -cc1 -triple powerpc-apple-macosx10.4.0 -S -disable-free -main-file-name Debug.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -v -coverage-file /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support/Debug.s -resource-dir /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.5 -O1 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-long-long -Wnon-virtual-dtor -pedantic -fdeprecated-macro -fno-dwarf2-cfi-asm -fno-dwarf-directory-asm -fno-autolink -fdebug-compilation-dir /Users/fang/local/src/LLVM-svn/gcc40-stage2-opt-build/lib/Support -ferror-limit 19 -fmessage-length 100 -fvisibility-inlines-hidden -mstackrealign -fblocks -fblocks-runtime-optional -fno-rtti -fobjc-runtime=macosx-10.4.0 -fencode-extended-block-signature -fno-common -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o Debug.s -x c++-cpp-output Debug.ii clang -cc1 version 3.5 based upon LLVM 3.5git-5247dc3 default target powerpc-apple-darwin8.11.0 ignoring nonexistent directory "/usr/local/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.0.0 /usr/include/c++/4.0.0/powerpc-apple-darwin8 /usr/include/c++/4.0.0/backward /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.5/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/usr/bin/as" -arch ppc -o CMakeFiles/LLVMSupport.dir/Debug.cpp.o Debug.s Debug.s:214:non-relocatable subtraction expression, "__ZNSsD1Ev" minus "L8$pb" Debug.s:214:symbol: "__ZNSsD1Ev" can't be undefined in a subtraction expression Debug.s:211:non-relocatable subtraction expression, "__ZNSsD1Ev" minus "L8$pb" Debug.s:211:symbol: "__ZNSsD1Ev" can't be undefined in a subtraction expression clang-3.5: error: assembler command failed with exit code 1 (use -v to see invocation)
If I switch to -integrated-as, I get a similar error: clang -cc1as: fatal error: error in backend: symbol '__ZNSsD1Ev' can not be undefined in a subtraction expression
The offending -O1 asm excerpt looks like: .section __TEXT,__StaticInit,regular,pure_instructions .align 4 ___cxx_global_var_init5: ; @__cxx_global_var_init5 ; BB#0: ; %entry ... L8$pb: ... addis r3, r29, ha16(__ZNSsD1Ev-L8$pb) mr r4, r30 lwz r5, lo16(L___dso_handle$non_lazy_ptr-L8$pb)(r2) la r3, lo16(__ZNSsD1Ev-L8$pb)(r3) bl L___cxa_atexit$stub ... blr
However, -O0 (which works) produces: ... addis r3, r2, ha16(L__ZNSsD1Ev$non_lazy_ptr-L9$pb) addis r4, r2, ha16(L___dso_handle$non_lazy_ptr-L9$pb) lwz r3, lo16(L__ZNSsD1Ev$non_lazy_ptr-L9$pb)(r3) lwz r5, lo16(L___dso_handle$non_lazy_ptr-L9$pb)(r4) ...
.section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
.align 2
...
L__ZNSsD1Ev$non_lazy_ptr: .indirect_symbol __ZNSsD1Ev .long 0
Note the use of L...$non_lazy_ptr.
Suddenly, as of r197897, the reduced test case now works. The one missing label/symbol now has a proper declaration, even at -O1.
% diff -u old.s new.s
@@ -104,6 +104,9 @@
.section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
.align 2
+L__ZTV4Base$non_lazy_ptr:
- .indirect_symbol __ZTV4Base
- .long 0 L__ZTV7DerivedIvE$non_lazy_ptr: .indirect_symbol __ZTV7DerivedIvE .long 0
Again, thanks goes out to whomever fixed this. I'd still like to know which patch(es) in recent months would have affected this, so that I could back-port the fix the powerpc-darwin8-rel-3.4 release branch.
Does the same file compile with -fno-PIC instead of -fPIC ? And what about -mdynamic-no-pic instead?
Application binaries should link well using -fno-PIC while dynamic libraries need -mdynamic-no-pic or -fPIC in order to be linked, the latter being only useful for libraries that are really shared by different applications, like the c/c++/objc runtime libraries for example, as all applications will then use the same code loaded at the same address, hence saving RAM.
-fPIC will result in slower code compared to -mdynamic-no-pic , while -fno-PIC should be the fastest.
Since it's related to -fPIC, it's probably a Darwin-only issue. From what I've seen in the code, PIC is only currently implemented for Darwin in the PPC back end. You may be on your own here... :( Not much to do but start turning on debug dumps and look for clues.
Ping? Any diagnosis on this issue? (I hope this can be fixed in time for 3.3.)
bad PPC asm produced with -O1 -fno-common Produced by:
~/local/src/LLVM-svn/gcc40-cmake-build/bin/clang++ -v -fno-common -no-integrated-as -save-temps -O1 -c llvm/llvm-bugzilla-archive#14579 .cpp -o llvm/llvm-bugzilla-archive#14579 .o1 clang version 3.3 Target: powerpc-apple-darwin8.11.0 Thread model: posix "/Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/clang-3.1" -cc1 -triple powerpc-apple-macosx10.4.0 -E -disable-free -main-file-name llvm/llvm-bugzilla-archive#14579 .cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -v -coverage-file /Users/fang/temp/clang/#14579 /#14579 .ii -resource-dir /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.3 -O1 -fdeprecated-macro -fno-dwarf2-cfi-asm -fno-dwarf-directory-asm -fdebug-compilation-dir /Users/fang/temp/clang/#14579 -ferror-limit 19 -fmessage-length 80 -mstackrealign -fblocks -fblocks-runtime-optional -fobjc-runtime=macosx-10.4.0 -fobjc-default-synthesize-properties -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fno-common -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o llvm/llvm-bugzilla-archive#14579 .ii -x c++ llvm/llvm-bugzilla-archive#14579 .cpp clang -cc1 version 3.3 based upon LLVM 3.3svn default target powerpc-apple-darwin8.11.0 ignoring nonexistent directory "/usr/local/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.0.0 /usr/include/c++/4.0.0/powerpc-apple-darwin8 /usr/include/c++/4.0.0/backward /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.3/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/clang-3.1" -cc1 -triple powerpc-apple-macosx10.4.0 -S -disable-free -main-file-name llvm/llvm-bugzilla-archive#14579 .cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -v -coverage-file /Users/fang/temp/clang/#14579 /#14579 .s -resource-dir /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.3 -O1 -fdeprecated-macro -fno-dwarf2-cfi-asm -fno-dwarf-directory-asm -fdebug-compilation-dir /Users/fang/temp/clang/#14579 -ferror-limit 19 -fmessage-length 80 -mstackrealign -fblocks -fblocks-runtime-optional -fobjc-runtime=macosx-10.4.0 -fobjc-default-synthesize-properties -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fno-common -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o llvm/llvm-bugzilla-archive#14579 .s -x c++-cpp-output llvm/llvm-bugzilla-archive#14579 .ii clang -cc1 version 3.3 based upon LLVM 3.3svn default target powerpc-apple-darwin8.11.0 ignoring nonexistent directory "/usr/local/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.0.0 /usr/include/c++/4.0.0/powerpc-apple-darwin8 /usr/include/c++/4.0.0/backward /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.3/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/usr/bin/as" -arch ppc -o llvm/llvm-bugzilla-archive#14579 .o1 llvm/llvm-bugzilla-archive#14579 .s llvm/llvm-bugzilla-archive#14579 .s:63:non-relocatable subtraction expression, "__ZTV4Base" minus "L2$pb" llvm/llvm-bugzilla-archive#14579 .s:63:symbol: "__ZTV4Base" can't be undefined in a subtraction expression llvm/llvm-bugzilla-archive#14579 .s:62:non-relocatable subtraction expression, "__ZTV4Base" minus "L2$pb" llvm/llvm-bugzilla-archive#14579 .s:62:symbol: "__ZTV4Base" can't be undefined in a subtraction expression clang-3.1: error: assembler command failed with exit code 1 (use -v to see invocation) make: *** [#14579 .o1] Error 1
Still problematic at r179187. Same issue, asm rejected because no "vtable for Base" symbol is declared, though it is referenced.
Hal, or anyone with PPC, can you post the resulting asm of compiling: class Class; struct Base { virtual void foo(); }; template
struct Derived : Base { Derived(const Class&) { } }; with: clang++ -fno-common -no-integrated-as -O1 -save-temps -c
Does the resulting .s assemble fine?
Can you attach the .s file that your clang produces? This works just fine on PPC64/Linux. Could it be a Darwin-specific issue?
also -fPIC on systems where PIC is not default. The error occurs in relocatable assembly.
Still problematic at r179187. Same issue, asm rejected because no "vtable for Base" symbol is declared, though it is referenced.
Hal, or anyone with PPC, can you post the resulting asm of compiling:
class Class;
struct Base {
virtual void foo();
};
template
with: clang++ -fno-common -no-integrated-as -O1 -save-temps -c
Does the resulting .s assemble fine?
This error keeps triggering when I compile various C++ sources with my stage 1 clang++.
Escalating priority (for me) -- this pretty much precludes using the stage 1 clang from compiling critical components such as libcxxabi and llvm in stage 2 without resorting to -O0. The goal is to self-host clang using at least a reasonable level of optimization like -O2.