Why does bloom `export LDFLAGS=`?
As of this writing, the bloom repository has at least one debian/rules
template featuring the following comment:
# TODO: remove the LDFLAGS override. It's here to avoid esoteric problems
# of this sort:
# https://code.ros.org/trac/ros/ticket/2977
# https://code.ros.org/trac/ros/ticket/3842
export LDFLAGS=
-- https://github.com/ros-infrastructure...
Those commented links are dead, and the internet archive wayback machine doesn't have them. The distant ancestor of that file already had those comments when it was added in 2012:
https://github.com/ros-infrastructure...
Does anyone remember what ROS trac tickets 2977 and 3842 were about? What were those "esoteric problems" mentioned by the author?
_Update_:
My ROS friends have pointed me toward catkin issue #72 and a commit referencing the same:
https://github.com/ros/catkin/commit/...
It's clear this LDFLAGS
override has something to do with preventing the linker from seeing the -Bsymbolic-functions
flag. More detail forthcoming as I dig into it.
_Update The Second_:
My further searching has led to several tickets reporting runtime segfaults caused by the use of -Bsymbolic-functions
during the link phase:
- grpc issue #11195: Segfault when library is linked using "-Bsymbolic-functions"
- autofs bug #1470687: Not working properly with compile options "-symbolic-functions"
- tango bug #1250534: Linker option -Wl,-Bsymbolic-functions
It is the dpkg-buildflags
command (of Ubuntu's dpkg-dev
package) that adds -Bsymbolic-functions
to the LDFLAGS
during a normal dpkg-buildpackage
:
root@c7dc18648a0e:/# cat /etc/issue.net && dpkg-buildflags --get LDFLAGS
Ubuntu 20.04 LTS
-Wl,-Bsymbolic-functions -Wl,-z,relro
Note that the Debian dpkg-dev
does _not_ do this:
root@b134afb3a682:/# cat /etc/issue.net && dpkg-buildflags --get LDFLAGS
Debian GNU/Linux 10
-Wl,-z,relro
The "proper" way to remove options from the set of linker flags is explained in man 1 dpkg-buildflags
"Environment" section:
DEB_flag_STRIP DEB_flag_MAINT_STRIP This variable can be used to provide a space separated list of options that will be stripped from the set of flags returned for the given flag.