Repository navigation
Description
This issue was originally created at: 2007-05-15 11:52:01.
This issue was reported by: johan_boule.
johan_boule said at 2007-05-15 11:52:01
I'm trying to build a c++ dynamic library with the mingw tool.
Firstly, because msvc is (unfortunately) selected as the default tool on
mswindows and i'm unsure as to how tell scons to use mingw from the commandline
and/or within SCons' API itself, i've modified the SCons.Tool.tool_list function
as follows to get mingw selected in preference over msvc:if str(platform) == 'win32':
# Override by bohan: Prefer mingw over msvc!
#"prefer Microsoft tools on Windows"
if False:
linkers = ['mslink', 'gnulink', 'ilink', 'linkloc', 'ilink32' ]
c_compilers = ['msvc', 'mingw', 'gcc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ]
cxx_compilers = ['msvc', 'intelc', 'icc', 'g++', 'c++', 'bcc32' ]
assemblers = ['masm', 'nasm', 'gas', '386asm' ]
fortran_compilers = ['g77', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
ars = ['mslib', 'ar', 'tlib']
else:
linkers = ['gnulink', 'mslink', 'ilink', 'linkloc', 'ilink32' ]
c_compilers = ['mingw', 'gcc', 'msvc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ]
cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++', 'bcc32' ]
assemblers = ['gas', 'masm', 'nasm', '386asm' ]
fortran_compilers = ['g77', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
ars = ['ar', 'mslib' 'tlib']After this, i try to run scons on my project, and the following output:
packageneric: trace: c++ compiler is g++ version 3.4.2
packageneric: checking for gnug 4 ... no
packageneric: checking for gnug 3 ... yes
packageneric: trace: platform is win32
packageneric: trace: platform executable format is pe
packageneric: checking for mingw ... yes
[...]
packageneric: compiling object from c++
src\universalis\operating_system\detail\check_version.cpp
packageneric: compiling object from c++
src\universalis\compiler\exceptions\ellipsis.cpp
packageneric: compiling object from c++
src\universalis\compiler\detail\pragmatic\demangle.cpp
scons: *** 'dict' object has no attribute 'FindIxes'
scons: building terminated because of errors.There is no stacktrace so i'm unsure where FindIxes is called from, but it seems
to be called on an Environment's _dict member instead of the env itself.If i grep for FindIxes through SCons' sources, i see that it's called only in a
few tools:SCons/Tool/mingw.py
SCons/Tool/mslink.py
SCons/Tool/mwld.pyEach time it shows as env.FindIxes, so i suspect one of these "env" is a simple
dict object.
johan_boule said at 2007-05-15 12:21:37
in SCons/Tool/mingw.py, in the shlib_generator function, i added some debug prints:
def shlib_generator(target, source, env, for_signature):
cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])print 'xxxx', isinstance(env, SCons.Environment.Environment)
dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
print 'xxxx ok'The output when running scons is now:
scons: done reading SConscript files.
scons: Building targets ...
xxxx True
xxxx ok
xxxx False
scons: *** 'dict' object has no attribute 'FindIxes'
scons: building terminated because of errors.So it seems sometimes the "env" argument is a real env, sometimes just a dictionary.
johan_boule said at 2007-05-15 12:24:42
I modified again the sources to:
def shlib_generator(target, source, env, for_signature):
cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])if not isinstance(env, SCons.Environment.Environment):
print 'x'
return [cmd]
dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')and the build was successful.
johan_boule said at 2007-05-15 12:30:24
Actually, it didn't work. I got a file "a.exe" created in same dir as the
SConstruct file, instead of a .dll file in the build dir.
johan_boule said at 2007-05-15 13:00:56
With the followin code:
def shlib_generator(target, source, env, for_signature):
cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])if not isinstance(env, SCons.Environment.Base):
import traceback
traceback.print_stack()
dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')I get the stack trace:
File "", line 1, in ?
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Script\Main.py",
line 1428, in main
_exec_main()
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Script\Main.py",
line 1421, in _exec_main
_main(args, parser)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Script\Main.py",
line 1377, in main
jobs.run()
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Job.py", line 69,
in run
self.job.start()
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Job.py", line 105,
in start
task = self.taskmaster.next_task()
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Taskmaster.py",
line 663, in next_task
task.make_ready()
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Script\Main.py",
line 205, in make_ready
SCons.Taskmaster.Task.make_ready(self)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Taskmaster.py",
line 278, in make_ready_current
is_up_to_date = t.disambiguate().current()
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Node\FS.py", line
2269, in current
self.binfo = self.gen_binfo(calc)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Node_init.py",
line 709, in gen_binfo
binfo.bactsig = calc.module.signature(executor)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Sig\MD5.py", line
96, in signature
return new_md5(gc()).hexdigest()
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Executor.py", line
178, in get_contents
result = string.join(map(get, self.get_action_list()), "")
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Executor.py", line
176, in
get = lambda action, t=self.targets, s=self.sources, e=env:
File
"X:\home\bohan\work\dev\psycle.mingw\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Action.py",
line 747, in get_contents
self.list),
File
"X:\home\bohan\work\dev\psycle.mingw\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Action.py",
line 745, in
return string.join(map(lambda x, t=target, s=source, e=env:
File
"X:\home\bohan\work\dev\psycle.mingw\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Action.py",
line 592, in get_contents
return c.get_contents(self, target, source, env)
File
"X:\home\bohan\work\dev\psycle.mingw\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Action.py",
line 494, in get_contents
return env.subst_target_source(cmd, SUBST_SIG, target, source)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Environment.py",
line 391, in subst
return SCons.Subst.scons_subst(string, self, raw, target, source, gvars,
lvars, conv)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
510, in scons_subst
result = ss.substitute(strSubst, lvars)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
464, in substitute
result = _dollar_exps.sub(sub_match, args)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
463, in sub_match
return conv(expand(match.group(1), lvars))
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
429, in expand
return self.substitute(s, lv)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
464, in substitute
result = _dollar_exps.sub(sub_match, args)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
463, in sub_match
return conv(expand(match.group(1), lvars))
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
429, in expand
return self.substitute(s, lv)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
482, in substitute
return self.expand(args, lvars)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Subst.py", line
447, in expand
s = self.conv(s)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Util.py", line 131,
in to_String_for_signature
return to_String(obj)
File "X:\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Util.py", line 123,
in to_String
return str(s)
File
"X:\home\bohan\work\dev\psycle.mingw\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Action.py",
line 521, in str
act = self._generate([], [], env, 1)
File
"X:\home\bohan\work\dev\psycle.mingw\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Action.py",
line 510, in _generate
ret = self.generator(target=target, source=source, env=env,
for_signature=for_signature)
File
"X:\home\bohan\work\dev\psycle.mingw\psycle-dev-pack-for-mswindows\opt\scons\lib\SCons\Tool\mingw.py",
line 58, in shlib_generator
traceback.print_stack()
scons: *** 'dict' object has no attribute 'FindIxes'
scons: building terminated because of errors.
johan_boule said at 2007-05-15 13:05:46
In SCons/Action.py, class CommandGeneratorAction, i see:
def str(self):
try:
env = self.presub_env or {}
except AttributeError:
env = {}
act = self._generate([], [], env, 1)
return str(act)
stevenknight said at 2007-05-25 14:12:33
Hi John--
Thanks for the bug report and the detective work. Could you see if the patch
below fixes the problem for you? I don't have a ready access to a MinGW system.If that works, I'll look at creating a reasonable unit test and getting the fix
into the code base.--SK
Index: src/engine/SCons/Action.py
--- src/engine/SCons/Action.py (revision 1935)
+++ src/engine/SCons/Action.py (working copy)
@@ -515,9 +515,11 @@def __str__(self): try:
env = self.presub_env or {}
env = self.presub_env except AttributeError:
env = {}
env = Noneif env is None:env = SCons.Defaults.DefaultEnvironment() act = self._generate([], [], env, 1) return str(act)
johan_boule said at 2007-05-26 11:27:32
Hi Steven,
The patch appeared to have worked fine.
However, i found another bug with mingw concerning the LoadableModule builder.
I posted it issue/patch 1669 (
http://scons.tigris.org/issues/show_bug.cgi?id=1669 ),
but i paste here the description/patch.The action of the default LoadableModule builder is a command line made from the
substitution of a $LDMODULECOM env var, which expands to $SHLINKCOM.SCons/Tool/mingw.py overrides the default SHLINKCOM env var with a shlink_action
python function.It turns out that the LDMODULECOM must also directly points to the shlink_action
function:--- opt/scons/lib/SCons/Tool/mingw_orig.py
+++ opt/scons/lib/SCons/Tool/mingw.py
@@ -130,6 +130,7 @@
env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
env['SHLINKCOM'] = shlib_action
- env['LDMODULECOM'] = shlib_action
env.Append(SHLIBEMITTER = [shlib_emitter])
env['AS'] = 'as'
stevenknight said at 2007-05-26 14:35:44
Fixed in next release. Thanks for the report, and for testing the patch on your
system.
stevenknight said this issue blocks #1664 at 2007-05-26 14:35:44.
Activity