[LLVMdev] hello.bc & binary code

Chris Lattner sabre at nondot.org
Mon Dec 22 13:25:01 PST 2003


On Mon, 22 Dec 2003, yue wrote:

> I try to build hello.cpp using both llvmg++ and GNU g++,
> the generate llvm bytecode's size is about 960K,
> and the size of binary code generated by g++ is only 13K.
> Could anyone explain the difference between the two result?

I can certainly answer this one:

When you link a program with LLVM G++, it statically links in _all_ of
libstdc++ into the resultant executable.  This is good from an
optimization standpoint, but obviously results in a larger executable.  In
time, we will deal with this, but for now, there isn't a wonderful
solution to this.

Note that you can more directly compare by compiling your program with
'-c', which will not link in libstdc++, or by using 'llvmgcc' to link the
program, which will not link it in either.  This should allow you to
compare the sizes of the programs.  For another comparison, on my redhat
8.0 system, the native /usr/lib/libstdc++.so.5.0.1 is 4.1MB by itself.

> I rebuild the cfrontend in RH linux9.0, but when I build the hello.cpp
> the llvmG++ reports warnings too, it shows:

I'll leave this one to John, but the warnings are probably ignorable.  :)

-Chris


> [yue at RH9 Shootout-C++]$ llvmg++ -v hello.cpp -o hello
> Reading specs from
> /home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm/specs
> Configured with: '../src/configure'
> '--prefix=/home/yue/cfrontend/install '--disable-threads '--disable-nls
> '--disable-shared '--enable-languages=c,c++ : (reconfigured)
> '../src/configure' '--prefix=/home/yue/cfrontend/install
> '--disable-threads '--disable-nls '--disable-shared
> '--enable-languages=c,c++
> Thread model: single
> gcc version 3.4-llvm 20030827 (experimental)
>
> /home/yue/cfrontend/install/libexec/gcc/i686-pc-linux-gnu/3.4-llvm/cc1plus
> -quiet -v -D_GNU_SOURCE hello.cpp -quiet -dumpbase hello.cpp
> -mtune=pentiumpro -auxbase hello -version -o /tmp/ccb5CDSP.s
> ignoring nonexistent directory
> "/home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm/../../../../i686-pc-linux-gnu/include"
> #include "..." search starts here:
> #include <...> search starts here:
>
> /home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm/../../../../include/c++/3.4-llvm
>
> /home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm/../../../../include/c++/3.4-llvm/i686-pc-linux-gnu
>
> /home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm/../../../../include/c++/3.4-llvm/backward
>   /usr/local/include
>   /home/yue/cfrontend/install/include
>   /home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm/include
>   /usr/include
> End of search list.
> GNU C++ version 3.4-llvm 20030827 (experimental) (i686-pc-linux-gnu)
>          compiled by GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
> GGC heuristics: --param ggc-min-expand=55 --param ggc-min-heapsize=48067
>   gccas -o /tmp/ccppFGsT.o /tmp/ccb5CDSP.s
>   gccld -o hello
> -L/home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm
> -L/home/yue/cfrontend/install/lib/gcc/i686-pc-linux-gnu/3.4-llvm/../../..
> /tmp/ccppFGsT.o -lstdc++ -lm -lc -lcrtend
> WARNING: Found global types that are not compatible:
>           [16 x sbyte]* %_ZN9__gnu_cxx10messages_cE
>           "struct.std::messages<char>"* %_ZN9__gnu_cxx10messages_cE
> WARNING: Found global types that are not compatible:
>           [16 x sbyte]* %_ZN9__gnu_cxx10messages_wE
>           "struct.std::messages<char>"* %_ZN9__gnu_cxx10messages_wE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx10numpunct_cE
>           "struct.std::numpunct<char>"* %_ZN9__gnu_cxx10numpunct_cE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx10numpunct_wE
>           "struct.std::numpunct<wchar_t>"* %_ZN9__gnu_cxx10numpunct_wE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx10time_get_cE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx10time_get_cE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx10time_get_wE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx10time_get_wE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx10time_put_cE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx10time_put_cE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx10time_put_wE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx10time_put_wE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx11money_get_cE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx11money_get_cE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx11money_get_wE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx11money_get_wE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx11money_put_cE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx11money_put_cE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx11money_put_wE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx11money_put_wE
> WARNING: Found global types that are not compatible:
>           [20 x sbyte]* %_ZN9__gnu_cxx11timepunct_cE
>           "struct.std::__timepunct<char>"* %_ZN9__gnu_cxx11timepunct_cE
> WARNING: Found global types that are not compatible:
>           [20 x sbyte]* %_ZN9__gnu_cxx11timepunct_wE
>           "struct.std::__timepunct<wchar_t>"* %_ZN9__gnu_cxx11timepunct_wE
> WARNING: Found global types that are not compatible:
>           [36 x sbyte]* %_ZN9__gnu_cxx12buf_cin_syncE
>
> "struct.__gnu_cxx::stdio_sync_filebuf<char,std::char_traits<char> >"*
> %_ZN9__gnu_cxx12buf_cin_syncE
> WARNING: Found global types that are not compatible:
>           [36 x sbyte]* %_ZN9__gnu_cxx13buf_cerr_syncE
>
> "struct.__gnu_cxx::stdio_sync_filebuf<char,std::char_traits<char> >"*
> %_ZN9__gnu_cxx13buf_cerr_syncE
> WARNING: Found global types that are not compatible:
>           [36 x sbyte]* %_ZN9__gnu_cxx13buf_cout_syncE
>
> "struct.__gnu_cxx::stdio_sync_filebuf<char,std::char_traits<char> >"*
> %_ZN9__gnu_cxx13buf_cout_syncE
> WARNING: Found global types that are not compatible:
>           [36 x sbyte]* %_ZN9__gnu_cxx13buf_wcin_syncE
>
> "struct.__gnu_cxx::stdio_sync_filebuf<wchar_t,std::char_traits<wchar_t>
>  >"* %_ZN9__gnu_cxx13buf_wcin_syncE
> WARNING: Found global types that are not compatible:
>           [20 x sbyte]* %_ZN9__gnu_cxx13c_locale_implE
>           "struct.std::locale::_Impl"* %_ZN9__gnu_cxx13c_locale_implE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx13moneypunct_cfE
>           "struct.std::moneypunct<char, false>"*
> %_ZN9__gnu_cxx13moneypunct_cfE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx13moneypunct_ctE
>           "struct.std::moneypunct<char, false>"*
> %_ZN9__gnu_cxx13moneypunct_ctE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx13moneypunct_wfE
>           "struct.std::moneypunct<wchar_t, false>"*
> %_ZN9__gnu_cxx13moneypunct_wfE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx13moneypunct_wtE
>           "struct.std::moneypunct<wchar_t, false>"*
> %_ZN9__gnu_cxx13moneypunct_wtE
> WARNING: Found global types that are not compatible:
>           [36 x sbyte]* %_ZN9__gnu_cxx14buf_wcerr_syncE
>
> "struct.__gnu_cxx::stdio_sync_filebuf<wchar_t,std::char_traits<wchar_t>
>  >"* %_ZN9__gnu_cxx14buf_wcerr_syncE
> WARNING: Found global types that are not compatible:
>           [36 x sbyte]* %_ZN9__gnu_cxx14buf_wcout_syncE
>
> "struct.__gnu_cxx::stdio_sync_filebuf<wchar_t,std::char_traits<wchar_t>
>  >"* %_ZN9__gnu_cxx14buf_wcout_syncE
> WARNING: Found global types that are not compatible:
>           [92 x sbyte]* %_ZN9__gnu_cxx16numpunct_cache_cE
>           "struct.std::__numpunct_cache<char>"*
> %_ZN9__gnu_cxx16numpunct_cache_cE
> WARNING: Found global types that are not compatible:
>           [292 x sbyte]* %_ZN9__gnu_cxx16numpunct_cache_wE
>           "struct.std::__numpunct_cache<wchar_t>"*
> %_ZN9__gnu_cxx16numpunct_cache_wE
> WARNING: Found global types that are not compatible:
>           [200 x sbyte]* %_ZN9__gnu_cxx17timepunct_cache_cE
>           "struct.std::__timepunct_cache<char>"*
> %_ZN9__gnu_cxx17timepunct_cache_cE
> WARNING: Found global types that are not compatible:
>           [200 x sbyte]* %_ZN9__gnu_cxx17timepunct_cache_wE
>           "struct.std::__timepunct_cache<wchar_t>"*
> %_ZN9__gnu_cxx17timepunct_cache_wE
> WARNING: Found global types that are not compatible:
>           [44 x sbyte]* %_ZN9__gnu_cxx19moneypunct_cache_cfE
>           "struct.std::__moneypunct_cache<char>"*
> %_ZN9__gnu_cxx19moneypunct_cache_cfE
> WARNING: Found global types that are not compatible:
>           [44 x sbyte]* %_ZN9__gnu_cxx19moneypunct_cache_ctE
>           "struct.std::__moneypunct_cache<char>"*
> %_ZN9__gnu_cxx19moneypunct_cache_ctE
> WARNING: Found global types that are not compatible:
>           [52 x sbyte]* %_ZN9__gnu_cxx19moneypunct_cache_wfE
>           "struct.std::__moneypunct_cache<wchar_t>"*
> %_ZN9__gnu_cxx19moneypunct_cache_wfE
> WARNING: Found global types that are not compatible:
>           [52 x sbyte]* %_ZN9__gnu_cxx19moneypunct_cache_wtE
>           "struct.std::__moneypunct_cache<wchar_t>"*
> %_ZN9__gnu_cxx19moneypunct_cache_wtE
> WARNING: Found global types that are not compatible:
>           [96 x sbyte]* %_ZN9__gnu_cxx7buf_cinE
>           "struct.__gnu_cxx::stdio_filebuf<char,std::char_traits<char>
>  >"* %_ZN9__gnu_cxx7buf_cinE
> WARNING: Found global types that are not compatible:
>           [28 x sbyte]* %_ZN9__gnu_cxx7ctype_cE
>           "struct.std::ctype<char>"* %_ZN9__gnu_cxx7ctype_cE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx7ctype_wE
>           "struct.std::codecvt<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx7ctype_wE
> WARNING: Found global types that are not compatible:
>           [96 x sbyte]* %_ZN9__gnu_cxx8buf_cerrE
>           "struct.__gnu_cxx::stdio_filebuf<char,std::char_traits<char>
>  >"* %_ZN9__gnu_cxx8buf_cerrE
> WARNING: Found global types that are not compatible:
>           [96 x sbyte]* %_ZN9__gnu_cxx8buf_coutE
>           "struct.__gnu_cxx::stdio_filebuf<char,std::char_traits<char>
>  >"* %_ZN9__gnu_cxx8buf_coutE
> WARNING: Found global types that are not compatible:
>           [96 x sbyte]* %_ZN9__gnu_cxx8buf_wcinE
>
> "struct.__gnu_cxx::stdio_filebuf<wchar_t,std::char_traits<wchar_t> >"*
> %_ZN9__gnu_cxx8buf_wcinE
> WARNING: Found global types that are not compatible:
>           [4 x sbyte]* %_ZN9__gnu_cxx8c_localeE
>           "struct.std::locale"* %_ZN9__gnu_cxx8c_localeE
> WARNING: Found global types that are not compatible:
>           [12 x [4 x sbyte]]* %_ZN9__gnu_cxx8name_vecE
>           [12 x sbyte*]* %_ZN9__gnu_cxx8name_vecE
> WARNING: Found global types that are not compatible:
>           [96 x sbyte]* %_ZN9__gnu_cxx9buf_wcerrE
>
> "struct.__gnu_cxx::stdio_filebuf<wchar_t,std::char_traits<wchar_t> >"*
> %_ZN9__gnu_cxx9buf_wcerrE
> WARNING: Found global types that are not compatible:
>           [96 x sbyte]* %_ZN9__gnu_cxx9buf_wcoutE
>
> "struct.__gnu_cxx::stdio_filebuf<wchar_t,std::char_traits<wchar_t> >"*
> %_ZN9__gnu_cxx9buf_wcoutE
> WARNING: Found global types that are not compatible:
>           [28 x [4 x sbyte]]* %_ZN9__gnu_cxx9cache_vecE
>           [28 x "struct.std::locale::facet"*]* %_ZN9__gnu_cxx9cache_vecE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx9codecvt_cE
>           "struct.std::codecvt<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx9codecvt_cE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx9codecvt_wE
>           "struct.std::codecvt<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx9codecvt_wE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx9collate_cE
>           "struct.std::collate<char>"* %_ZN9__gnu_cxx9collate_cE
> WARNING: Found global types that are not compatible:
>           [12 x sbyte]* %_ZN9__gnu_cxx9collate_wE
>           "struct.std::collate<char>"* %_ZN9__gnu_cxx9collate_wE
> WARNING: Found global types that are not compatible:
>           [28 x [4 x sbyte]]* %_ZN9__gnu_cxx9facet_vecE
>           [28 x "struct.std::locale::facet"*]* %_ZN9__gnu_cxx9facet_vecE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx9num_get_cE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx9num_get_cE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx9num_get_wE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx9num_get_wE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx9num_put_cE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx9num_put_cE
> WARNING: Found global types that are not compatible:
>           [8 x sbyte]* %_ZN9__gnu_cxx9num_put_wE
>           "struct.std::__codecvt_abstract_base<char,char,__mbstate_t>"*
> %_ZN9__gnu_cxx9num_put_wE
> WARNING: Found global types that are not compatible:
>           [144 x sbyte]* %_ZSt3cin
>           "struct.std::basic_istream<char,std::char_traits<char> >"*
> %_ZSt3cin
> WARNING: Found global types that are not compatible:
>           [140 x sbyte]* %_ZSt4cerr
>           "struct.std::basic_ostream<char,std::char_traits<char> >"*
> %_ZSt4cerr
> WARNING: Found global types that are not compatible:
>           [140 x sbyte]* %_ZSt4clog
>           "struct.std::basic_ostream<char,std::char_traits<char> >"*
> %_ZSt4clog
> WARNING: Found global types that are not compatible:
>           "struct.std::basic_ostream<char,std::char_traits<char> >"*
> %_ZSt4cout
>           [140 x sbyte]* %_ZSt4cout
> WARNING: Found global types that are not compatible:
>           [148 x sbyte]* %_ZSt4wcin
>           "struct.std::basic_istream<wchar_t,std::char_traits<wchar_t>
>  >"* %_ZSt4wcin
> WARNING: Found global types that are not compatible:
>           [144 x sbyte]* %_ZSt5wcerr
>           "struct.std::basic_ostream<wchar_t,std::char_traits<wchar_t>
>  >"* %_ZSt5wcerr
> WARNING: Found global types that are not compatible:
>           [144 x sbyte]* %_ZSt5wclog
>           "struct.std::basic_ostream<wchar_t,std::char_traits<wchar_t>
>  >"* %_ZSt5wclog
> WARNING: Found global types that are not compatible:
>           [144 x sbyte]* %_ZSt5wcout
>           "struct.std::basic_ostream<wchar_t,std::char_traits<wchar_t>
>  >"* %_ZSt5wcout
> [yue at RH9 Shootout-C++]$
> -------------------------------------------
>
> yueqiang
> 2003/12/22
>
>
>
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list