Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt4 issue with missing 2 required positional arguments #45

Closed
jhdub23 opened this issue Mar 9, 2022 · 18 comments
Closed

qt4 issue with missing 2 required positional arguments #45

jhdub23 opened this issue Mar 9, 2022 · 18 comments
Assignees

Comments

@jhdub23
Copy link

jhdub23 commented Mar 9, 2022

We just upgraded to scons-4.3.0 (using python-3.10.2) and also updated the qt4 tool as well. I'm getting many errors such as:

scons: *** [build/linux_x86_64_rhel7/Optimized/gui/moc_GUBase.cc] TypeError `_defines() missing 2 required positional arguments: 'target' and 'source'' trying to evaluate `${_defines(QT4_MOCDEFPREFIX, CPPDEFINES, QT4_MOCDEFSUFFIX, __env__)}'

Is there something obvious that I can fix? We are using qt-4.8.7.

@bdbaddog
Copy link
Contributor

bdbaddog commented Mar 9, 2022

Rerun with --debug=stacktrace and post that output.

@jhdub23
Copy link
Author

jhdub23 commented Mar 9, 2022

scons: *** [build/linux_x86_64_rhel7/Optimized/gui/moc_GUBase.cc] TypeError `_defines() missing 2 required positional arguments: 'target' and 'source'' trying to evaluate `${_defines(QT4_MOCDEFPREFIX, CPPDEFINES, QT4_MOCDEFSUFFIX, __env__)}'
scons: internal stack trace:
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Job.py", line 391, in start
    task.prepare()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Script/Main.py", line 178, in prepare
    return SCons.Taskmaster.OutOfDateTask.prepare(self)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Taskmaster.py", line 167, in prepare
    self.exception_raise()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Taskmaster.py", line 540, in _exception_raise
    raise exc_value.with_traceback(exc_traceback)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Taskmaster.py", line 814, in _find_next_ready_node
    children = executor.get_all_children()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Executor.py", line 311, in get_all_children
    result.extend(target.children())
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/__init__.py", line 1412, in children
    self.scan()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/__init__.py", line 1101, in scan
    executor.scan_sources(self.builder.source_scanner)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Executor.py", line 476, in scan_sources
    self.scan(scanner, self.get_all_sources())
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Executor.py", line 493, in scan
    deps.extend(node.get_implicit_deps(env, scanner, path, kw))
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/__init__.py", line 996, in get_implicit_deps
    included_deps = [x for x in node.get_found_includes(env, scanner, path) if x not in seen]
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/FS.py", line 2980, in get_found_includes
    result = [n.disambiguate() for n in scanner(self, env, path)]
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Scanner/__init__.py", line 212, in __call__
    if self.scan_check and not self.scan_check(node, env):
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Scanner/__init__.py", line 323, in current_check
    return not node.has_builder() or node.is_up_to_date()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/FS.py", line 3562, in is_up_to_date
    self.changed()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/FS.py", line 3318, in changed
    has_changed = SCons.Node.Node.changed(self, node)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/__init__.py", line 1483, in changed
    children = self.children()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/__init__.py", line 1412, in children
    self.scan()
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Node/__init__.py", line 1101, in scan
    executor.scan_sources(self.builder.source_scanner)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Executor.py", line 476, in scan_sources
    self.scan(scanner, self.get_all_sources())
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Executor.py", line 495, in scan
    deps.extend(self.get_implicit_deps())
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Executor.py", line 543, in get_implicit_deps
    deps = act.get_implicit_deps(self.get_all_targets(),
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Action.py", line 1134, in get_implicit_deps
    return self._generate(target, source, env, 1, executor).get_implicit_deps(target, source, env)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Action.py", line 1134, in get_implicit_deps
    return self._generate(target, source, env, 1, executor).get_implicit_deps(target, source, env)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Action.py", line 985, in get_implicit_deps
    return self._get_implicit_deps_lightweight(target, source, env, executor)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Action.py", line 996, in _get_implicit_deps_lightweight
    cmd_list = env.subst_list(self.cmd_list, SUBST_SIG, target, source)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Environment.py", line 518, in subst_list
    return SCons.Subst.scons_subst_list(string, self, raw, target, source, gvars, lvars, conv)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Subst.py", line 920, in scons_subst_list
    ls.substitute(strSubst, lvars, 0)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Subst.py", line 642, in substitute
    self.expand(a, lvars, within_list)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Subst.py", line 590, in expand
    self.substitute(s, lv, 0)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Subst.py", line 642, in substitute
    self.expand(a, lvars, within_list)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Subst.py", line 569, in expand
    raise_exception(e, lvars['TARGETS'], old_s)
  File "/usr/local/pkgs/python-3.10.2/lib/python3.10/site-packages/SCons-4.3.0-py3.10.egg/SCons/Subst.py", line 52, in raise_exception
    raise SCons.Errors.BuildError(target[0], msg)

@bdbaddog
Copy link
Contributor

Nothing in the stack trace is qt4.. Can you make a small reproducer?

@jhdub23
Copy link
Author

jhdub23 commented Mar 10, 2022

@bdbaddog : Thanks for looking into this. The error happens if there is both a *.h file and *.cpp (e.g. hello.h and hello.cpp). The following example reproduces the error. If the hello.h file is renamed, the compile is fine.
Edit: Replaced with a new example testcase that compiles fine with scons-4.1.0.post1
example2.tar.gz
This testcase fails with scons-4.2.0 and scons-4.3.0.

@bdbaddog
Copy link
Contributor

Builds for me.

$ python ~/devel/scons//git/as_scons/scripts/scons.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o hello.os -c -fPIC -DQT_NO_KEYWORDS -I/usr/include/qt4 hello.cpp
/usr/share/qt4/bin/moc -DQT_NO_KEYWORDS -o moc_hello.cc hello.h
g++ -o moc_hello.o -c -DQT_NO_KEYWORDS -I/usr/include/qt4 moc_hello.cc
g++ -o hello hello.os moc_hello.o -lQtGui -lQtCore
scons: done building targets.

I did have to modify SConstruct to fit my environment..

You should have

env_qt.Append(CPPPATH=[qt_include, gcc_include])

instead of

env_qt.Append(CCFLAGS = ['-I'+qt_include, '-I'+gcc_include])

btw. I installed qt4 via the instructions here:
https://askubuntu.com/questions/1274134/cannot-install-qt-4-on-ubuntu-20-04-quite-universal-circuit-simulator-qucs

And just used the ubuntu 20.04 default gcc.

Try changing your SConstruct as above and report back?

@jhdub23
Copy link
Author

jhdub23 commented Mar 10, 2022

I changed to env_qt.Append(CPPPATH=[qt_include, gcc_include]) but still have the same problem. I'm on CentOS 7.6. I would suspect my Qt4 installation, but downgrading scons to 4.1.0.post1 fixes the problem. I also see similar reports in camotics and gentoo.

@bdbaddog
Copy link
Contributor

Can you attach the full log of your reproducer running on your system excluding the stack trace?

@jhdub23
Copy link
Author

jhdub23 commented Mar 10, 2022

This is running on CentOS 7.6, python-3.10.2, qt-4.8.7 with everything built with gcc-10.2.0. For both of the below runs, I also set env_qt.Replace(QT4_DEBUG = 1). Downloaded a fresh clone of scons-contrib. I also get similar results with Qt5 (qt-5.15.8).

scons was installed by first downloading the source and then installing:

pip3 download --no-binary :all: -d pip_downloads scons==4.3.0
pip3 install scons==4.3.0 --no-binary :all --no-index --find-links pip_downloads

Updated example: example3.tar.gz for debug setting and to be able to test both Qt4 and Qt5.

Failed run with scons-4.3.0:

scons: Reading SConscript files ...
scons: qt4: Scanning 'hello.h' (header of 'hello.cpp')
scons: qt4: found Q_OBJECT macro in 'hello.h', moc'ing to '['moc_hello.cc']'
scons: qt4: compiling 'hello.cpp' to '['moc_hello.o']'
scons: qt4: found Q_OBJECT macro in 'hello.cpp', moc'ing to '['hello.moc']'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o hello.os -c -fPIC -DUSE_QT_VERSION=4 -DQT_NO_KEYWORDS -Iqt4_link/include -Igcc_link/include hello.cpp
scons: *** [moc_hello.cc] TypeError `_defines() missing 2 required positional arguments: 'target' and 'source'' trying to evaluate `${_defines(QT4_MOCDEFPREFIX, CPPDEFINES, QT4_MOCDEFSUFFIX, __env__)}'
scons: building terminated because of errors.

Good run with scons-4.1.0.post1:

scons: Reading SConscript files ...
scons: qt4: Scanning 'hello.h' (header of 'hello.cpp')
scons: qt4: found Q_OBJECT macro in 'hello.h', moc'ing to '['moc_hello.cc']'
scons: qt4: compiling 'hello.cpp' to '['moc_hello.o']'
scons: qt4: found Q_OBJECT macro in 'hello.cpp', moc'ing to '['hello.moc']'
scons: done reading SConscript files.
scons: Building targets ...
g++ -o hello.os -c -fPIC -DUSE_QT_VERSION=4 -DQT_NO_KEYWORDS -Iqt4_link/include -Igcc_link/include hello.cpp
qt4_link/bin/moc -DUSE_QT_VERSION=4 -DQT_NO_KEYWORDS -o moc_hello.cc hello.h
g++ -o moc_hello.o -c -DUSE_QT_VERSION=4 -DQT_NO_KEYWORDS -Iqt4_link/include -Igcc_link/include moc_hello.cc
g++ -o hello hello.os moc_hello.o -Lqt4_link/lib -Lgcc_link/lib64 -Lgcc_link/lib -lQtGui -lQtCore
scons: done building targets.

@bdbaddog
Copy link
Contributor

Try commenting this line out from the q4/init.py

    QT4_MOCDEFINES = '${_defines(QT4_MOCDEFPREFIX, CPPDEFINES, QT4_MOCDEFSUFFIX, __env__)}',

See if the error goes away.

@bdbaddog
Copy link
Contributor

And/or try changing it to

QT4_MOCDEFINES = '${_defines(QT4_MOCDEFPREFIX, CPPDEFINES, QT4_MOCDEFSUFFIX, __env__, TARGET, SOURCE)}',

@jhdub23
Copy link
Author

jhdub23 commented Mar 11, 2022

Both suggestions worked! Is one recommended over the other? Is there a reason the problem appeared on my system but not yours, without the change?

@bdbaddog
Copy link
Contributor

The latter is more correct as we added SOURCES and TARGETS as arguments to _defines() to allow the logic to use those values when expanding defines lists.

@bdbaddog
Copy link
Contributor

Likewise we should probably add a default value for _defines() in scons to avoid such failures, but that is proper calling signature going forward (with TARGET, SOURCE)

@jhdub23
Copy link
Author

jhdub23 commented Mar 11, 2022

Thanks. Will you be making the fixes in the code, or should I submit the code fix/pull request?

@bdbaddog bdbaddog self-assigned this Mar 13, 2022
@bdbaddog
Copy link
Contributor

I'd do it.
I'd like to fix both SCons to have a reasonable default values for such or maybe simpler error messaging if SOURCE and TARGET aren't specified..

@mwichmann
Copy link
Collaborator

See SCons/scons#3790 and SCons/scons#3949

@bdbaddog
Copy link
Contributor

Should be fixed by:
b716f70

Marking closed.
@jhdub23 - please reopen if this doesn't fix.
Note the "old" _defines() usage is in comments should someone be running with scons < 4.2.0

@bdbaddog
Copy link
Contributor

Closing

bdbaddog added a commit to bdbaddog/scons that referenced this issue Mar 20, 2022
…d for expanding among other things CPPDEFINES). source and target arguements were previously added to allow those values to be used by alternative definitions for _defines. This broke previous usage, including scons-contribs qt4 and qt5 tools. (See SCons/scons-contrib#45 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants