Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCons long command line TEMPFILE with MinGW

I'm trying to build a shared library from gcc and gfortran objects using SCons and MinGW on Windows, but during the final link the command line is too long, in excess of 18000 characters. I know I need to use a tempfile (response file?) to pass the command line, but I can't find a way to get SCons to do this directly. I was using CMake for this library and it handled the response file without my interference.

SCons appears to be using the CommandGeneratorAction to generate the shared library command line. Is there a way to tell this action to use the response file mechanism? Is there another method for handling long command lines that I'm overlooking?

Relevant SConscript:

sqllib = env.SharedLibrary(target='fvssql', source=sqllib_sources, LIBS=['odbc32',])
ffelib = env.SharedLibrary(target='fvspncffe', source=ffelib_sources, LIBS=[sqllib,], LIBPATH=['.',])

fvsobjs = env.SharedObject(fvslib_sources)
fvsobjs = [obj for obj in fvsobjs if obj.get_suffix()=='.o']

fvslib = env.SharedLibrary(target='fvspnc', source=fvsobjs, LIBS=sqllib+ffelib, LIBPATH=['.',])

Relevant output from env.Dump():

'SHLIBSUFFIX': '.dll',
'SHLINK': '$LINK',
'SHLINKCOM': <SCons.Action.CommandGeneratorAction object at 0x02DDF770>,
'SHLINKFLAGS': ['$LINKFLAGS', '-shared'],

I could prepare the command line template in my environment env['SHLINKCOM']="${TEMPFILE('$SHLINK -o $TARGET ... $SOURCE')}", but this seems fragile and I'd prefer to let SCons handle it if possible.

I tried using string substitution env['SHLINKCOM']='${TEMPFILE("%s")}' % (env['SHLINKCOM'],), but the result was an incomplete command line and now response file anyhow.

EDIT

I have seen the LongCmdLinesOnWin32 workaround. I would prefer to use the TEMPFILE, TempFileMunge, commandline indirection mechanism if possible.

like image 669
tharen Avatar asked Nov 12 '22 17:11

tharen


1 Answers

Have you seen http://scons.org/wiki/LongCmdLinesOnWin32? It looks like there is an answer to your exact problem with long command ling during the link phase.

like image 189
anatoly techtonik Avatar answered Dec 11 '22 03:12

anatoly techtonik