ar, nm, and ranlib are provided by the binutils package. gcc-ar, gcc-nm, and gcc-ranlib are provided by the GCC package. I read somewhere that the gcc-ar, gcc-nm, and gcc-ranlib are "effectively wrappers" around the ar, nm, and ranlib binaries respectively.
What is the technical difference between the gcc-ar, gcc-nm, and gcc-ranlib vs. ar, nm, and ranlib? There must be a reason why GCC provides these binaries in its builds.
When should a build system of a userland package use one vs. the other? If the toolchain being used to build a userland package is GCC based, does it matter which one you use (e.g., ar vs gcc-ar, nm vs gcc-nm)?
gcc-aris a wrapper for GNUarsuch that a command:is equivalent to:
On my present system, Ubuntu 17.10, GCC 7.2, that would be e.g:
There is just the same relationship between
nmandgcc-nm.The
--pluginoption of the binutilsarandnmenables them to dynamically load a recognizer/analyser for some non-default format of object file that they have to deal with.The shared library
liblto_plugin.sois one that enables them to deal with the IR (intermediate representation) object files produced and consumed in link-time-optimized builds.So, if you would do your plain old build like this:
then you'd do your link-time-optimized build like:
In recent releases of
binutils- I don't know which was the first; within the last 3 or 4 years -liblto_plugin.sohas been loaded by default byarandnm; so in fact:will work fine; and
nm foo.owill work fine. But thegcc-*versions still serve a purpose in being independently shipped with GCC, since your regulararandnmmight not support that default, and if not then that last build, for instance, would fail in the linkage with undefined references, sincearwould fail to insert in the archive a true symbol table forfoo.oandbar.o.