402N/AExplanation of some unusual compiler flags used when building the
402N/AApache Standard C++ Library:
402N/AAll the -D_STRICT_STDC -D_STRICT_STDC__ -D_STDC_C99 -D_ISOC99_SOURCE:
402N/ASince we are building a Standard conforming library, compliance with
402N/AStrict Standard C is assumed and expected.
402N/AHowever, the Apache Standard C++ Library provides some extensions to
402N/Athe C++ Standard, by allowing some C99 functions. Visibility of C99
402N/Ais enabled by passing -D_XPG6 -D_XOPEN_SOURCE=600 in CFLAGS. However,
402N/AStandard C++ disallows _XPG6 and _XOPEN_SOURCE=600, and only allows
402N/A_XPG5 and _XOPEN_SOURCE=500, so for CXXFLAGS we raise _XPG5 and
402N/Athe symbols for the Standard C++ exception classes, and it also provides
402N/Athe Solaris C++ run-time support.
402N/A-Qoption ccfe ++boolflag:sunwcch=false :
402N/Ado *NOT*, under any circumstances, use the default Studio 12 header
402N/Aimportant. We must build the Apache C++ Library using its own header
402N/Afiles, and we must ignore any other C++ header files.
402N/A-Qoption ccfe +d2,-xgeninl=system :
402N/AThe +d2,-xgeninl=system options causes functions that are generated
402N/Ainline also to be generated also as closed functions in the object file.
402N/ABy default, a function that is always inlined is not actually generated
402N/Aunless its address is needed.
402N/A-Qoption ccfe -expand=10000 :
402N/AThe C++ front end decides whether to inline a function in part depending
402N/Aon a complexity measure. The -expand=N option, where N is a decimal number,
402N/Asets the complexity limit. Functions of greater complexity are not inlined
402N/Aby the front end. The default limit is in the range 100-500 depending on
402N/Athe optimization level. Setting the limit to 10,000 effectively allows
402N/Ainlining of all but the largest functions.
402N/AWe use these options when building our system libraries for two reasons:
402N/A2.1. We want to allow maximum inlining of functions to improve runtime
402N/Aperformance. The size of a library (especially a shared library) is not
402N/Ausually important, so we trade size for speed.
402N/A2.2. A library function defined as inline in a standard header will be
402N/Ainlined in user code, unless inlining is disabled or the function address
402N/Ais taken. If library functions get defined in user code, the program can
402N/Awind up with circular dependencies among the various program parts.
402N/ASuppose library function F is defined as inline, but the library uses the
402N/Aaddress of F. Function F will be generated as a closed function in the
402N/Alibrary. If user code also needs the address of F, it will be generated in
402N/Auser code. The linker picks the first definition of F it sees, which will
402N/Abe in user code in this case, and discards any others. The library then
402N/Acalls F in user code instead of the one inside the library. If F is used
402N/Aas part of initializing the library, then the library has an initialization
402N/Adependency on the main program. The main program always has an
402N/Ainitialization dependency on the library. You can wind up with strange
402N/Aprogram failures, since you cannot satisfy the circular dependency.
402N/ATo prevent this possibility, we generate F unconditionally as a closed
402N/Afunction in the library. When a user function needs the address of F,
402N/Athe compiler first checks to see whether F is defined in the library.
402N/AIf so, it just generates a reference to F instead of generating a definition
402N/Aof F. There is then only one copy of F in the entire program, and it is in
402N/A-features=except,rtti,export,extensions,nestedaccess,tmplife,tmplrefstatic :
402N/AWe want to enable specific and Standard-mandated C++ Compiler features,
402N/Aand we want to be explicit about them, just in case the default C++
402N/ACompiler default features change in the future. This way, we are guaranteed
402N/Athat the Library builds in a consistent way, independent of any future
402N/Aupdates to the C++ Compiler.
402N/A-template=geninlinefuncs :
402N/AInstantiate inline member functions for the explicitly instantiated
402N/Aclass template which were not generated previously.
402N/ABe verbose about template instantiations. This is useful for tracking
402N/Awhat the compiler is doing when instantiating templates, and for debugging,
402N/Ain case we end up with undefined class template symbols.
402N/AAssume non-standard compatibility with C99. Allows C programming language
402N/Abehavior for objects which were compiled either with the c99 driver, or
402N/Awith the cc -xc99=%all driver, and are being linked with the Library.
402N/A(nothing after the '=').
402N/AWe've already told the compiler frontend (with the -Qoption ccfe flags)
402N/Ahow to inline, and what the inlining limits are. Therefore, do not make any
402N/Aother heuristic decisions about inlining (
i.e. assume nothing is inlined).
402N/ACause strict conformance to the IEEE 754 Standard for math routines in
402N/Aexceptional cases. The C++ Standard implicitly mandates IEEE 754
402N/A(cf. see libstdcxx4.3lib man page).
402N/AThe PAE Group and myself have tested the performance of the Apache Standard
402N/AC++ Library, and determined that linking with libumem provides the best