Closed mikeferguson closed 10 years ago
I can confirm the issue. I compared the sizes of roscpp
for Hydro and Indigo:
-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
-O2 -g -DNDEBUG
Quantal, Raring and Trusty do not pass any optimization flags.
dpkg-buildpackage
seems to only set any compiler / linker flags on Precise:
dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor): -D_FORTIFY_SOURCE=2
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor): -Wl,-Bsymbolic-functions -Wl,-z,relro
More surprising is actually that Saucy is still doing optimized builds because dpkg-buildpackage
does not that the flag on that platform either...
Anyway on my Trusty machine dpkg-buildflags
returns the "correct* enabling optimized builds (similar to the flags above on Precise.
@tfoote The question would now be what is different in the pbuilder environments compared to a "normal" Ubuntu installation?
The man page of dpkg-buildflags
(http://manpages.ubuntu.com/manpages/trusty/man1/dpkg-buildflags.1.html) states:
You should call dpkg-buildflags or include buildflags.mk from the
debian/rules file to obtain the needed build flags to pass to the build
system. Note that older versions of dpkg-buildpackage (before dpkg
1.16.1) exported these flags automatically. However, you should not
rely on this, since this breaks manual invocation of debian/rules.
It looks like that bloom does currently not contain an invocation of dpkg-buildflags
in the rules template: https://github.com/ros-infrastructure/bloom/blob/4952574611f37fec96c7d6f67bf9f6a5f8d2d3bf/bloom/generators/debian/templates/rules.em (@wjwwood FYI)
The version numbers of dpkg
in the different Ubuntu versions (http://packages.ubuntu.com/search?keywords=dpkg&searchon=names&exact=1&suite=all§ion=all) might support the assumption that this has just changed (if before dpkg 1.16.1
is interpreted as <= 1.16.1
) which is supported by the changelog: http://changelogs.ubuntu.com/changelogs/pool/main/d/dpkg/dpkg_1.17.5ubuntu5.2/changelog:
Compiler flags are no longer exported
Between versions 1.14.17 and 1.16.1, dpkg-buildpackage exported
compiler flags (CFLAGS, CXXFLAGS, FFLAGS, CPPFLAGS and LDFLAGS) with
values as returned by dpkg-buildflags. This is no longer the case.
Anyway it does not describe why Saucy is actually doing optimized builds:
While tracking down an issue with MoveIt/geometry_shapes (https://github.com/ros-planning/geometric_shapes/issues/19), I started looking into the flags between Hydro/Precise and Indigo/Trusty. The bigger question here though is the default flags. The size of just about every library in debs is 3-4 times larger on Indigo/Trusty than it was with Hydro/Precise. A couple examples:
The number of symbols is also significantly larger:
When building on precise/hydro (http://jenkins.ros.org/job/ros-hydro-geometric-shapes_binarydeb_precise_amd64/63/console) we get this for shapes.cpp:
On trusty/indigo (http://jenkins.ros.org/job/ros-indigo-geometric-shapes_binarydeb_trusty_amd64/22/console):
This holds true with at least RVIZ, (searching robot.cpp in the buildlog quickly shows that there are no optimization flags on the indigo build).
To me, it looks like this is missing at the beginning of the trusty builds:
Which is concerning -- why is there no optimization?