profiling variant of newlib

J. Johnston jjohnstn@cygnus.com
Wed Nov 3 11:30:00 GMT 1999


Richard Black wrote:
> 
> I am currently using newlib 1.8.1 in the gdb simulator for teaching
> undergraduates.
> 
> I observe that the current newlib build system builds variants of newlib for
> all of --print-multi-lib ; what I am interested in is a variant compiled with
> -p(g) .  I cannot currently see any way of making the make system do this.
> 
> Is there something I've missed, or can this be added in the next release? I
> suppose that it is unusual to want to do this for most sourceware components,
> but for library code this is a useful option.
> 
> I am not currently on the newlib@ mailing list so please copy me on any
> responses.
> 
> Thanks,
> 
> Richard.
> 
> Hmm. Thinks, maybe I could replace gcc with a hacked script that returned some
> strange output for --print-multi-lib..... I might be able to get the libaries
> I need with the wrong names in a different directory, but then I could just do
> some renaming and moving??

The fact you want a variant version of the library means it belongs as a multilib.
The multilib mechanism uses --print-multi-lib at configuration time and is not
dynamically adjustable.  However, adding a multilib is relatively easy to do.

To add the multilib, you edit the appropriate gcc/config/<TARGET>/t-xxxx file in your source
tree and add to MULTILIB_OPTIONS and MULTILIB_DIRNAMES.

For example, let's say we want little-endian and big-endian for an arm elf configuration.
In gcc/config/arm/t-arm-elf we have:

MULTILIB_OPTIONS     = mlittle-endian/mbig-endian
MULTILIB_DIRNAMES    = le be

The directory name is the name that will be used in the build and it must
correspond one for one with the options above.  The options are the compile options
to be used when building.  If options are mutually exclusive with other options, they should
appear side by side, separated by slashes.  If not mutually exclusive, use
spaces.  Permutations are performed such that no two mutually exclusive options are
specified together.  So, to add profiling as a variant to our example:

MULTILIB_OPTION      = mlittle-endian/mbig-endian p
MULTILIB_DIRNAMES    = le be prof

Note that you can pick whatever directory name you want for clarity sake.  Permutations
will be done on the sets separated by blanks.

Now, you should delete your old build, reconfigure, then rebuild.

This should give you your variant libraries.  To access, specify -mprof when you compile/link.
If you pick another directory name (e.g. profile, then the option is -mprofile).
The option tells the compiler/linker what libraries to link in.

You can find all this information and more about MULTILIB in the gcc info files.

-- Jeff Johnston (Cygnus Solutions)


More information about the Newlib mailing list