Linker Options

The environment variable LINKFLAGS defines the general user options passed to the linker exclusing Library specific options (they are handled by other variables).

Suppose we wanted to generate the map file for our build (GCC specific):

env.Append(LINKFLAGS = ['-Wl,-Map,"program.map"'])

and on build we get:

g++ -o hello -Wl,-Map,"program.map" src/main.o support/message.o

with the file program.map being generated.

Note, for clang the command is -map instead of -Map, i.e.

env.Append(LINKFLAGS = ['-Wl,-map,"program.map"'])

Note: to use -pie you will also need to set the -fpie compiler flag.

To set the mapfile name specific to the target name, Python allows us to construct the appropriate string:

exe = 'hello'

generate_map_file = '-Wl,-Map,'+exe+'.map'
env.Append(LINKFLAGS = [generate_map_file])

or

env.Append(LINKFLAGS = ['-Wl,-Map,"%s.map"'%(exe),])

results matching ""

    No results matching ""