[Scons-users] HowTo: toggle between toolchains during scons build

PhilAPol philapol at hotmail.com
Sat Aug 31 20:35:55 EDT 2013


Hi All,

The current scons build for mongodb assumes that it will be built on the target machine. This is not possible since there is not enough memory on the target. Consequently, I would like to cross-build mongodb under Ubuntu targeting the ARM processor.

I will need to toggle between using the native tool-chain (under Ubuntu) and the ARM tool-chain in the middle of the build. I have set up my Ubuntu environment under /usr/bin to symbolically link to either the ARM tool-chain or the Ubuntu tool-chain by invoking the use-arm-tools.sh or use-native-tools.sh scripts. Before building I invoke use-arm-tools.sh to start in ARM mode. I have tried a several different approaches (see below) without success. I am looking for a solution.

Building the third-party tools in mongodb requires the ability to switch back to Ubuntu native tools to build and execute programs that generate output to be used in subsequent steps (in ARM mode) of the build.

To be specific, the following SConscript file (found under: mongo-nonx86-master/build/linux2/normal/third_party/js-1.7 shown below) needs to be modified to build and execute the jskwgen and jscpucfg programs under Ubuntu and generate the jsautokw.h and jsautocfg.h files to be subsequently used in the ARM build. Take a look at the indicated comments where this should happen in the following SConscript file:

#========================================================================================
# -*- mode: python -*-

Import("env windows linux darwin solaris freebsd")

def removeIfPresent(lst, item):
try:
lst.remove(item)
except ValueError:
pass

env = env.Clone()

env.Append(CPPDEFINES=["JSFILE", "EXPORT_JS_API", "JS_C_STRINGS_ARE_UTF8"])

for to_remove in ['-Werror', '/TP', '/O2', '/Gy']:
removeIfPresent(env['CCFLAGS'], to_remove)

if windows:
env.Append(CCFLAGS=['/wd4748'])
else:
# Force language to be c. Does not work when setting --cxx=g++ otherwise
env.Append(CCFLAGS=['-xc'])

removeIfPresent(env['CPPDEFINES'], 'NDEBUG')

if linux or darwin or freebsd:
env.Append(CPPDEFINES=['HAVE_VA_COPY', 'VA_COPY=va_copy'])
elif solaris:
env.Append(CPPDEFINES=['SOLARIS', 'HAVE_VA_COPY', 'VA_COPY=va_copy', 'SVR4', 'SYSV', 'HAVE_LOCALTIME_R'])

############################################################################
# We need to change the tool environment from ARM to native Ubuntu mode here.
# Thus jskwgen.c would be built for the Ubuntu environment then executed to
# produce the jskautokw.h and jsautocfg.h files for subsequent use in the
# overall ARM build.
############################################################################
env.Program('jskwgen', 'jskwgen.c')
env.Program('jscpucfg', 'jscpucfg.c')
env.Command('jsautokw.h', ['${PROGREFIX}jskwgen${PROGSUFFIX}'],
'$SOURCE >$TARGET')
env.Command('jsautocfg.h', ['${PROGREFIX}jscpucfg${PROGSUFFIX}'],
'$SOURCE >$TARGET')
############################################################################
# We need to restore the tool environment from native mode back to ARM mode here.
# The build should now continue using ARM tools.
############################################################################

env.StaticLibrary(
"js",
[ "jsapi.c",
"jsarena.c",
"jsarray.c",
"jsatom.c",
"jsbool.c",
"jscntxt.c",
"jsdate.c",
"jsdbgapi.c",
"jsdhash.c",
"jsdtoa.c",
"jsemit.c",
"jsexn.c",
"jsfun.c",
"jsgc.c",
"jshash.c",
"jsiter.c",
"jsinterp.c",
"jslock.c",
"jslog2.c",
"jslong.c",
"jsmath.c",
"jsnum.c",
"jsobj.c",
"jsopcode.c",
"jsparse.c",
"jsprf.c",
"jsregexp.c",
"jsscan.c",
"jsscope.c",
"jsscript.c",
"jsstr.c",
"jsutil.c",
"jsxdrapi.c",
"jsxml.c",
"prmjtime.c",
])
#========================================================================================

I have tried:

1) saving, replacing the env[‘CC’] value with the Ubuntu gcc path and then restoring it to the ARM gcc - surrounding the indicated section above.
2) executing a shell scripts (use-native-tools.sh and use-arm-tools.sh) invoked by env.Command() - surrounding the section,
3) executing shell scripts using python methods - surrounding the section.

Method 1 fails when the Ubuntu gcc invokes the ARM assembler (since /usr/bin/as is linked to the ARM assembler) and Methods 2/3 don’t invoke the indicated shell scripts to select the proper tool-chain.

So what can you recommended as a solution?

Thanks for you help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20130831/34667765/attachment.htm


More information about the Scons-users mailing list