14.6 Building Libraries for Public Use

When an organization builds a library for use by other organizations, the management
of the libraries, platform generality, and other issues become significant. A simple test
for whether a library is public is to ask if the application programmer
can recompile the library easily. Public libraries should be built in conformance with
the system’s application binary interface (ABI). In general, this means that any processor-specific
options should be avoided. (For example, do not use -fast or -xtarget.)

The SPARC ABI reserves some registers exclusively for applications. For SPARC V7 and
V8, these registers are %g2, %g3, and %g4. For SPARC V9, these registers
are %g2 and %g3. Because most compilations are for applications, the C++
compiler, by default, uses these registers for scratch registers, improving program performance. However, use
of these registers in a public library is generally not compliant with the
SPARC ABI. When building a library for public use, compile all objects with
the -xregs=no%appl option to ensure that the application registers are not used.