[Scons-users] HOWTO select a toolchain

Marc Branchaud marcnarc at xiplink.com
Mon Jan 4 15:08:03 EST 2016


On 16-01-04 02:36 PM, Stefan Seefeld wrote:
> On 04.01.2016 14:19, William Blevins wrote:
>> Stefan,
>>
>> SCons does not automatically import environment variables. The SCons
>> DefaultEnvironment is minimalistic.
>>
>> http://scons.org/new/faq.html#Why_doesn.27t_SCons_find_my_compiler.2BAC8-linker.2BAC8-etc..3F_I_can_execute_it_just_fine_from_the_command_line.
> 
> William,
> 
> thanks, but I believe that only addresses some of my concerns. I also
> found your answer to a similar question here:
> http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2927425,
> which is helpful, but not quite complete (as it isn't clear what other
> variables specifically need to be changed, and how. Can you point me to
> some documentation that explains how the various compiler-related
> variables are defined, so I know what exactly I need to redefine to be
> able to switch toolchains on the command-line ?

Can't speak to Microsoft tools, but in our Unix-only 64-bit/32-bit
cross-compilation environment the variables we override are:

ToolchainVars = [
    'AR',
    'AS',
    'CC',
    'CXX',
    # Don't need to override LINK and SHLINK because SCons maps them to
    # CC (or CXX)
    #'LINK',
    #'SHLINK',
    'RANLIB',
    'READELF',
    'STRIP'
]

In cases where we need to build something natively we have an
"UnsetToolchain" method that simply deletes the above variables from the
build environment so that we end up with SCons's auto-detected defaults.

AFAIK, SCons doesn't have anything like a "toolchain ID".  The most reliable
way to ensure that SCons is using the toolchain you want is to make sure its
binaries appear in your PATH before any other toolchain's.

Even if SCons had some kind of toolchain-ID feature, it's always wise to
ensure that your PATH is set to use the toolchain you want.  You never know
what esoteric sub-tool your compiler might want to invoke!

A while back our build used to do true cross-compilation, and we taught our
SConscripts to use a TOOLCHAIN_HOME variable.  The variable specified a home
directory for a toolchain (with various subdirectories like bin/, lib/ and
include/), which we used as a path prefix when setting the above variables
and others (like CPPPATH).

Hope that helps!

		M.



More information about the Scons-users mailing list