<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>consider the following Boost.Python code:</div><div><br></div><div>// demo.cpp</div><div><div>#include <boost/python.hpp></div><div><br></div><div>template <typename T, typename U></div><div>T foo(T i, U j) { return i*j; }</div><div><br></div><div>#define ARGS , (arg("i")=0, arg("j")=0)</div><div><br></div><div>BOOST_PYTHON_MODULE(demo_ext)</div><div>{</div><div> using namespace boost::python;</div><div> def("fii", foo<int,int> ARGS);</div><div> def("fil", foo<int,long> ARGS);</div><div> def("fif", foo<int,float> ARGS);</div><div> def("fid", foo<int,double> ARGS);</div><div> def("fic", foo<int,char> ARGS);</div><div> def("fli", foo<long,int> ARGS);</div><div> def("fll", foo<long,long> ARGS);</div><div> def("flf", foo<long,float> ARGS);</div><div> def("fld", foo<long,double> ARGS);</div><div> def("flc", foo<long,char> ARGS);</div><div> def("ffi", foo<float,int> ARGS);</div><div> def("ffl", foo<float,long> ARGS);</div><div> def("fff", foo<float,float> ARGS);</div><div> def("ffd", foo<float,double> ARGS);</div><div> def("ffc", foo<float,char> ARGS);</div><div> def("fdi", foo<double,int> ARGS);</div><div> def("fdl", foo<double,long> ARGS);</div><div> def("fdf", foo<double,float> ARGS);</div><div> def("fdd", foo<double,double> ARGS);</div><div> def("fdc", foo<double,char> ARGS);</div><div>}</div></div><div><br></div><div>Then compare</div><div><br></div><div><div>~> g++ -c -DBOOST_PYTHON_MAX_BASES=2 -fPIC -fno-strict-aliasing -DNDEBUG -march=native -O3 -DBOOST_ALL_NO_LIB -DBOOST_DISABLE_THREADS -I../cctbx/boost -I/usr/include/python2.6 demo.cpp</div><div>~> g++ -o demo.so -shared demo.o -L../cctbx/cctbx_build/lib -lboost_python~>> g++ -o demo_strip.so -s -shared demo.o -L../cctbx/cctbx_build/lib -lboost_python</div><div>~> ls -lhS</div><div><font class="Apple-style-span" face="'Lucida Console'">total 540K</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rw-r--r-- 1 luc devcom 240K Nov 27 07:50 demo.o</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rwxr-xr-x 1 luc devcom 170K Nov 27 07:50 demo.so*</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rwxr-xr-x 1 luc devcom 121K Nov 27 07:50 demo_strip.so*</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rw-r--r-- 1 luc devcom  902 Nov 27 07:18 demo.cpp</font></div><div>~> g++ --version</div><div>g++ (GCC) 4.4.4 20100630 (Red Hat 4.4.4-10)</div></div><div><br></div><div>to</div><div><br></div><div><div>~> clang++ -c -DBOOST_PYTHON_MAX_BASES=2 -fPIC -fno-strict-aliasing -DNDEBUG -O3 -DBOOST_ALL_NO_LIB -DBOOST_DISABLE_THREADS -I/Users/luc/Developer/cctbx/boost -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 demo.cpp</div><div>~> clang++ -o demo.so -w -bundle -undefined dynamic_lookup demo.o -L$cctbx_build_clang_pch/lib -lboost_python</div><div>~> clang++ -o demo_strip.so -s -w -bundle -undefined dynamic_lookup demo.o -L$cctbx_build_clang_pch/lib -lboost_python</div><div>~> ls -lhS</div><div><font class="Apple-style-span" face="'Lucida Console'">total 1184</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rwxr-xr-x  1 luc  luc   203K Nov 27 16:56 demo.so</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rwxr-xr-x  1 luc  luc   202K Nov 27 16:56 demo_strip.so</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rw-------  1 luc  luc   178K Nov 27 16:56 demo.o</font></div><div><font class="Apple-style-span" face="'Lucida Console'">-rw-r--r--@ 1 luc  luc   952B Nov 27 05:13 demo.cpp</font></div></div><div><font class="Apple-style-span" face="'Lucida Console'"><br></font></div><div><font class="Apple-style-span" face="'Lucida Console'">~> </font>> clang++ --version</div><div>clang version 2.9 (trunk 116866)</div><div>Target: x86_64-apple-darwin10</div><div>Thread model: posix</div><div><br></div><div><font class="Apple-style-span" face="'Lucida Grande'">First demo.so is significantly smaller than demo.o with gcc 4.4 whereas this is the other way around with clang. Moreover the stripping -s option significantly reduce the size of the .so further whereas clang -s does not do so.</font></div><div><font class="Apple-style-span" face="'Lucida Grande'"><br></font></div><div><font class="Apple-style-span" face="'Lucida Grande'">Is there any way to make clang++ competitive with GCC 4.4 here?</font></div><div><font class="Apple-style-span" face="'Lucida Grande'"><br></font></div><div><font class="Apple-style-span" face="'Lucida Grande'">Thanks for any insight,</font></div><div><font class="Apple-style-span" face="'Lucida Grande'"><br></font></div><div><font class="Apple-style-span" face="'Lucida Grande'">Luc Bourhis</font></div><div><font class="Apple-style-span" face="'Lucida Grande'"><br></font></div><div><br></div></body></html>