1. Introduction

For SPEC CPU you do not write your own Makefiles, nor
do you use your platform's native make program. Instead, your config file supplies options that are sent to a
SPEC-supplied copy of GNU make, known as specmake.

Basic options for specmake are described in the Config
Files document.

Advanced options for specmake are described in the document you are reading now.

The specmake utility can be run directly from the command line, as described in Utilities.

If you are asking questions like the following, this document is for you.

Can I send an OPTIMIZATION flag only to the compiler? Only the linker? Both?

Which PORTABILITY options go to the Fortran preprocessor?

Is it possible to get linker flags before the list of objects? After?

2. Which steps use which flags?

Y indicates that an option affects a particular compilation phase
Y(D) is explained in Note 1.

[1] specpp:FPPP options are sent to specpp, a SPEC-supplied Fortran preprocessor. From
Y(D) options, -Dx /Dx -Ux /Ux go
to specpp (it does not see the rest). In the example, speccp sees the mumble request
but not the endian request. The compiler sees the endian request but not the mumble
request. (more detail)

521.wrf_r:
FPORTABILITY = -DMUMBLE --endian-fix

[2] Linking: For multi-language
benchmarks, the first one mentioned in the Documentation Index
benchmarks table is considered "primary", meaning that
only its flags are used for linking. In the example, the
--bigpages switch is not used. (more detail)

3. Items used in Makefile.defaults

A file called Makefile.spec, which is generated from your config file. It is found
in

$SPEC/benchspec/CPU/<benchmark>/build/build_<tune>_<label>.nnnn/Makefile.spec or
%SPEC%\benchspec\CPU\<benchmark>\build\build_<tune>_<label>.nnnn\Makefile.spec

The overall control file which is used by all benchmarks, and which contains most of the build
rules:

$SPEC/benchspec/Makefile.defaults or
%SPEC%\benchspec\Makefile.defaults

The list above is in order from highest to lowest priority. That is, if a setting for a particular variable exists in
object.pm, it cannot be overridden. Variables not specified in object.pm can be set by the user in the
config file and thus in
Makefile.spec. If a setting is needed, and does not appear in either of those two places, a reasonable default is
provided by Makefile.defaults.

Do you need to worry about all three of these?

Usually you do not need to think about settings from object.pm because these set
very basic choices that define a benchmark, for example switches to include benchmark header files, disable use of MPI,
or disable code that is known to be non-portable. (If you believe that a flag defined in object.pm causes a
problem, you may write to SPEC.)

Usually, you do need to think about settings in your own config file.

Occasionally, you might want to see how your config file settings interact with Makefile.defaults, especially if you are adept at reading GNU makefiles.

This section is addressed to such readers. The table below briefly describes nearly all the items in
Makefile.defaults and classifies by type:

config = If you wish, you are free to set this in your config file.
bench = The benchmark sets it in Spec/object.pm. Do not attempt to touch.
tools = Something computed by SPEC tools. Really do not touch.
xdebug = eXtra item for debug, normally useful only during development.
Type Item Meaning
----- ------------------- --------------------------------------------------------------------------------------------------
bench BENCHLANG Benchmark language; one of C, CXX, F, F77
tools BENCHMARK The formal benchmark name, e.g. 999.specrand
bench BENCH_CFLAGS Benchmark specific C flags predefined by SPEC; cannot be changed
bench BENCH_CXXFLAGS Benchmark specific C++ flags predefined by SPEC; cannot be changed
bench BENCH_FFLAGS Benchmark specific Fortran flags predefined by SPEC; cannot be changed
bench BENCH_FLAGS Benchmark specific flags predefined by SPEC; cannot be changed
bench BENCH_FPPFLAGS Benchmark specific Fotran preprocessor flags predefined by SPEC; cannot be changed
config CC How to invoke your C compiler
config CLD How to invoke the linker when building C programs (default: CC)
config COBJOPT Special OBJOPT for C. Defaults to same as OBJOPT.
config COPTIMIZE Optimization flags to be used when compiling and when linking C programs
config CPORTABILITY Portability options to be applied when compiling and when linking C programs
tools CPUFLAGS Macros defined on a suite-wide basis for C, C++, and preprocessed Fortran codes
config CXX How to invoke your C++ compiler
tools CXXC Same as CXX. A minor coding trick uses this to help figure out how to invoke linker.
config CXXLD How to invoke the linker when building C++ programs (default: CXX)
config CXXOBJOPT Special OBJOPT for C++. Defaults to same as OBJOPT.
config CXXOPTIMIZE Optimization flags to be used when compiling and when linking C++ programs
config CXXPORTABILITY Portability options to be applied when compiling and when linking C++ programs
config ECHO How to spell "echo" command. Defaults to 'echo'.
bench EXEBASE Name of the base benchmark executable (without label or tuning information)
config EXTRA_CFLAGS Additional flags to use when compiling and when linking C programs
config EXTRA_CLIBS Additional libraries to link in to C benchmarks.
config EXTRA_COPTIMIZE Additional optimization flags to pass to your C compiler
config EXTRA_CPORTABILITY Additional portability flags to pass to your C compiler (not used when linking)
config EXTRA_CXXFLAGS Additional flags to use when compiling and when linking C++ programs
config EXTRA_CXXLIBS Additional libraries to link in to C++ benchmarks.
config EXTRA_CXXOPTIMIZE Additional optimization flags to pass to your C++ compiler
config EXTRA_CXXPORTABILITY Additional portability flags to pass to your C++ compiler (not used when linking)
config EXTRA_FFLAGS Additional flags to use when compiling and when linking Fortran programs
config EXTRA_FLIBS Additional libraries to link in to Fortran and mixed-language benchmarks.
config EXTRA_FOPTIMIZE Additional optimization flags to pass to your Fortran compiler
config EXTRA_FPORTABILITY Additional portability flags to pass to your Fortran compiler (not used when linking)
config EXTRA_FPPFLAGS Additional flags to pass to Fortran preprocessor
config EXTRA_LDFLAGS Additional flags to pass to your linker
config EXTRA_LIBS Extra libraries to appear at the end of the link command
config EXTRA_OPTIMIZE Additional flags to pass to all compilers
config EXTRA_PORTABILITY Additional portability flags to pass to all compilers (not used when linking)
config EXTRA_RMFILES Additional files to be deleted before a build
config EXTRA_SOURCES Sources to add when doing a build. Must be explained to SPEC!
config FC How to invoke your Fortran-90 compiler
tools FDO The current build pass number (for FDO builds only)
tools FDO_COPTIMIZE Optimization flags to pass to the C compiler to do the current FDO pass
tools FDO_CXXOPTIMIZE Optimization flags to pass to the C++ compiler to do the current FDO pass
tools FDO_FOPTIMIZE Optimization flags to pass to the Fortran compiler to do the current FDO pass
tools FDO_LDCFLAGS For the linker used with C programs, flags to pass to the linker to do the current FDO pass
tools FDO_LDCXXFLAGS For the linker used with C++ programs, flags to pass to the linker to do the current FDO pass
tools FDO_LDFFLAGS For the linker used with Fortran programs, flags to pass to the linker to do the current FDO pass
tools FDO_LDFLAGS Flags to pass to the linker to do the current FDO pass
tools FDO_OPTIMIZE Optimization flags for the current FDO pass
tools FINAL_CFLAGS Full list of flags passed to C compiler
tools FINAL_CXXFLAGS Full list of flags passed to C++ compiler
tools FINAL_FFLAGS Full list of flags passed to F90 compiler
tools FINAL_FPPFLAGS Full list of flags passed to Fortran preprocessor
tools FINAL_LDOPT Full list of flags passed to linker
tools FINAL_LIBS Full list of libraries
tools FINAL_SOURCES Full list of source files to be used for compilation
config FLD How to invoke the linker when building Fortran programs (default: FC)
config FOBJOPT Special OBJOPT for f90. Defaults to same as OBJOPT.
config FOPTIMIZE Optimization flags to be used when compiling and when linking Fortran programs
config FPORTABILITY Portability options to be applied when compiling and when linking Fortran programs
config FPPFLAGS Flags to be added to Fortran preprocessor
config FPPPORTABILITY Portability flags to be added to Fortran preprocessor
tools FPP_USED Does this benchmark use the Fortran preprocessor?
config LABEL Desired label for the object files. Set via 'label' in config file or '--label' on command line.
tools LD The name of your linker. Do not set this directly; set the language specific value (CLD, FLD, etc)
config LDCFLAGS Flags to add to link lines used for C builds
config LDCXXFLAGS Flags to add to link lines used for C++ builds
config LDFFLAGS Flags to add to link lines used for Fortran benchmarks or benchmarks that use both Fortran and C
config LDFLAGS Flags to add to link lines for all languages
config LDOPTIMIZE Optimization flags for the linker
config LDOPTIONS Additional options to supply to the linker
tools LDOPTFLAGS Optimization flags supplied to the linker
config LDOUT Linker flag used to specify an output file. Defaults to '-Fe$@' on Windows and '-o $@' elsewhere.
config LDOUT_OPTIONS Flags that need to appear after LDOUT
config LDOUT_EXTRA_OPTIONS More flags that need to appear after LDOUT
config LDPORTABILITY Portability flags to be used when linking
config LIBS Libraries to link into the final executable
config MATHLIBOPT Set of math libraries (if any) to link into the final executable
tools MATH_LIBS Set of math libraries (if any) to link into the final executable (just $MATHLIBOPT again)
bench NAME The benchmark name, e.g. dealII
config NEEDATFILE Reduce length of command lines by using @files. (Set NEEDATFILE=1 to enable the feature.)
bench NEED_MATH Flag telling whether or not the benchmark needs to be linked with the math libraries
bench NUMBER The benchmark number, e.g. 447
config OBJ The file name extension for object files. Defaults to '.obj' on Windows and '.o' elsewhere
tools OBJNAMES Name of a file to store the names of the object files
config OBJOPT Option to compile and name an output file. Defaults to "-c -Fo$@" on Windows and "-c -o $@" elsewhere.
tools OBJS List of object files needed to link the final executable
config OPTIMIZATION_LIBS Libraries used for optimization purposes, to be added to all builds
config OPTIMIZATION_CLIBS Libraries used for optimization purposes, to be added to C builds
config OPTIMIZATION_CXXLIBS Libraries used for optimization purposes, to be added to C++ builds
config OPTIMIZATION_FLIBS Libraries used for optimization purposes, to be added to Fortran and mixed C and Fortran builds
config OPTIMIZE Optimization flags. Typically used only for a single benchmark.
tools OS Name of OS being used. Supplied automatically by specmake.
config OS_LIBS List of OS-specific libs to link with
tools OUTPUT_RMFILES Files to be cleaned bewteen builds
config PASSn_* PASSn_ may prefixed to these, to add to that option only for the nth pass:
LDOPT FLAGS OPTIMIZE LDFLAGS
CFLAGS COPTIMIZE LDCFLAGS
CXXFLAGS CXXOPTIMIZE LDCXXFLAGS
FFLAGS FOPTIMIZE LDFFLAGS
config PORTABILITY Portability options to be applied to all steps for all programs
config PORTABILITY_CLIBS Portability libraries to link in with C benchmarks.
config PORTABILITY_CXXLIBS Portability libraries to link in with C++ benchmarks.
config PORTABILITY_FLIBS Portability libraries to link in with Fortran and mixed-language benchmarks.
config PORTABILITY_LIBS Portability libraries to link in with all benchmarks.
xdebug PPCFLAGS Flags that enable your C preprocessor
xdebug PPCXXFLAGS Flags that enable your C++ preprocessor
xdebug PPFLAGS Flags that enable your C/C++ preprocessor
xdebug PP_SOURCES List of preprocessed sources
tools PRIMARY_BENCHLANG Primary benchmark language; one of C, CXX, F, F77
tools RAW_FFLAGS Temporary variable, used while figuring out final flag list
config RMRF The name of a program (with arguments, if necessary) that can be used to delete a directory tree.
config RM_SOURCES Sources to exclude from a build. Must explained to SPEC!
bench SOURCES What the benchmark/src/Makefile expects will normally be used
tools TARGET Benchmarks with multiple executables use Makefile.exename.spec. runcpu sets TARGET=exename
tools tmpBENCHLANG Temporary variable, used while figuring out languages
tools TMP1_SOURCES Temporary variable, used while figuring out final source file list
tools TMP2_SOURCES Temporary variable, used while figuring out final source file list
tools TMP3_SOURCES Temporary variable, used while figuring out final source file list
tools TMP_SOURCES Temporary variable, used while figuring out final source file list
tools TUNE The tuning currently being used (to set in config file, use tune=)

4. Order of flag application

Sometimes, you may need more detail about flag order and presence (e.g. Is OPTIMIZE applied before or after
COPTIMIZE? Is LDOPTIONS included for both FDO and non-FDO builds?) In such cases, you have several choices:

You can do a fake build. In practice, this is often the easiest, and
is highly recommended. Fake is your friend.

You can consult the lists below, which show where all user-settable variables end up (position-wise).
The lists are automatically generated from Makefile.defaults
and therefore may save you considerable time versus trying to read it on your own.