NS3.27 not able to ./waf --apiscan for python bindings / CastXml complaining of Name not simple identifier.

690 views
Skip to first unread message

bjfons...@gmail.com

unread,
Nov 28, 2017, 12:33:49 PM11/28/17
to ns-3-users
Hello,

I'm sorry for taking your time with this, but I've been trying to solve this problem for a couple of days now.

I downloaded the new NS3.27 version using bake.py and I was trying to modify some functions of LR-WPAN. When regenerating the Python bindings (using the ./waf --apiscan=lr-wpan --no32bits-scan), castxml complained of an error.

"castxml: /usr/lib/llvm-3.7/include/clang/AST/Decl.h:169: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed."

At first, I thought that the problem was my modification; however, after returning to the original NS3.27-LrWpan code and trying to rebuild the python bindings, I got the same error again, which makes me conclude that the problem was probably not with my modification but with my installation instead.

The error that CastXml is giving (in the original NS3.27-LrWpan code) relates to a "Name is not a simple identifier"; as pasted below

bjfonseca@acerFonseca:~/source/ns-3.27$ ./waf --apiscan=lr-wpan --no32bit-scan
Waf: Entering directory `/home/bjfonseca/source/ns-3.27/build'
Modules to scan:  ['lr-wpan']
api-scan-gcc_LP64
<ns3modulegen_core_customizations.SmartPointerTransformation object at 0x7ffa16649350>
INFO Parsing source file "/home/bjfonseca/source/ns-3.27/build/ns3/lr-wpan-module.h" ...
castxml: /usr/lib/llvm-3.7/include/clang/AST/Decl.h:169: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed.
Aborted (core dumped)
Traceback (most recent call last):
  File "/home/bjfonseca/source/ns-3.27/bindings/python/ns3modulescan-modular.py", line 283, in <module>
    ns3_module_scan(sys.argv[1], sys.argv[2], eval(sys.argv[3]), sys.argv[4], sys.argv[5])
  File "/home/bjfonseca/source/ns-3.27/bindings/python/ns3modulescan-modular.py", line 263, in ns3_module_scan
    castxml_options=castxml_options)
  File "/home/bjfonseca/source/pybindgen/pybindgen/castxmlparser.py", line 767, in parse_init
    self.declarations = parser.parse(header_files, self.castxml_config)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/parser/__init__.py", line 51, in parse
    declarations = parser.read_files(files, compilation_mode)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/parser/project_reader.py", line 264, in read_files
    return self.__parse_file_by_file(files)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/parser/project_reader.py", line 292, in __parse_file_by_file
    decls = reader.read_file(header)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/parser/source_reader.py", line 356, in read_file
    return self.read_cpp_source_file(source_file)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/parser/source_reader.py", line 375, in read_cpp_source_file
    xml_file = self.create_xml_file(ffname)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/parser/source_reader.py", line 324, in create_xml_file
    ": %s status:%s" % (gccxml_msg, exit_status))
RuntimeError: Error occurred while running CASTXML:  status:134
Waf: Leaving directory `/home/bjfonseca/source/ns-3.27/build'
Build failed
 -> task in '' failed (exit status 1):
    {task 139836981326160: apiscan_task lr-wpan-module.h -> modulegen__gcc_LP64.py}
''

I've been working in a Ubuntu 16.04 machine and below is the output of ./waf configure --enable-tests --enable-examples --build-profile=debug

bjfonseca@acerFonseca:~/source/ns-3.27$ ./waf configure --enable-tests --enable-examples --build-profile=debug
Setting top to                           : /home/bjfonseca/source/ns-3.27
Setting out to                           : /home/bjfonseca/source/ns-3.27/build
Checking for 'gcc' (C compiler)          : /usr/bin/gcc
Checking for cc version                  : 5.4.0
Checking for 'g++' (C++ compiler)        : /usr/bin/g++
Checking for compilation flag -Wl,--soname=foo support : ok
Checking for program 'python'                          : /usr/bin/python
Checking for python version                            : (2, 7, 12, 'final', 0)
python-config                                          : /usr/bin/python-config
Asking python-config for pyembed '--cflags --libs --ldflags' flags : yes
Testing pyembed configuration                                      : yes
Asking python-config for pyext '--cflags --libs --ldflags' flags   : yes
Testing pyext configuration                                        : yes
Checking for compilation flag -fvisibility=hidden support          : ok
Checking for compilation flag -Wno-array-bounds support            : ok
Checking for pybindgen location                                    : ../pybindgen (guessed)
Checking for python module 'pybindgen'                             : 0.18.0.post3+g3eade76
Checking for pybindgen version                                     : 0.18.0.post3+g3eade76
Checking for code snippet                                          : yes
Checking for types uint64_t and unsigned long equivalence          : no
Checking for code snippet                                          : no
Checking for types uint64_t and unsigned long long equivalence     : yes
Checking for the apidefs that can be used for Python bindings      : gcc-LP64
Checking for internal GCC cxxabi                                   : complete
Checking for python module 'pygccxml'                              : 1.9.0
Checking for pygccxml version                                      : 1.9.0
Checking for program 'castxml'                                     : /usr/bin/castxml
Checking for castxml version                                       : 0.1
Checking boost includes                                            : 1_58
Checking boost libs                                                : ok
Checking for boost linkage                                         : ok
Checking for BRITE location                                        : ../BRITE (guessed)
Checking for library dl                                            : yes
Checking for library brite                                         : yes
Checking for click location                                        : ../../build (guessed)
Checking for library dl                                            : yes
Checking for library nsclick                                       : yes
Checking for program 'pkg-config'                                  : /usr/bin/pkg-config
Checking for 'gtk+-2.0' >= 2.12                                    : yes
Checking for 'libxml-2.0' >= 2.7                                   : yes
Checking for type uint128_t                                        : not found
Checking for type __uint128_t                                      : yes
Checking high precision implementation                             : 128-bit integer (default)
Checking for header stdint.h                                       : yes
Checking for header inttypes.h                                     : yes
Checking for header sys/inttypes.h                                 : not found
Checking for header sys/types.h                                    : yes
Checking for header sys/stat.h                                     : yes
Checking for header dirent.h                                       : yes
Checking for header stdlib.h                                       : yes
Checking for header signal.h                                       : yes
Checking for header pthread.h                                      : yes
Checking for header stdint.h                                       : yes
Checking for header inttypes.h                                     : yes
Checking for header sys/inttypes.h                                 : not found
Checking for library rt                                            : yes
Checking for header sys/ioctl.h                                    : yes
Checking for header net/if.h                                       : yes
Checking for header net/ethernet.h                                 : yes
Checking for header linux/if_tun.h                                 : yes
Checking for header netpacket/packet.h                             : yes
Checking for NSC location                                          : ../../build (guessed)
Checking for library dl                                            : yes
Checking for NSC supported architecture x86_64                     : ok
Checking for OpenFlow location                                     : ../../build (guessed)
Checking for library dl                                            : yes
Checking for library xml2                                          : yes
Checking for library openflow                                      : yes
Checking for 'sqlite3'                                             : yes
Checking for header linux/if_tun.h                                 : yes
Checking for python module 'gtk'                                   : ok
Checking for python module 'goocanvas'                             : 0.14.1
Checking for python module 'pygraphviz'                            : 1.3.1
Checking boost includes                                            : 1_58
Checking for program 'sudo'                                        : /usr/bin/sudo
Checking for program 'valgrind'                                    : /usr/bin/valgrind
Checking for 'gsl'                                                 : yes
python-config                                                      : not found
Checking for compilation flag -Wno-error=deprecated-d... support   : ok
Checking for compilation flag -Wno-error=deprecated-d... support   : ok
Checking for compilation flag -fstrict-aliasing support            : ok
Checking for compilation flag -fstrict-aliasing support            : ok
Checking for compilation flag -Wstrict-aliasing support            : ok
Checking for compilation flag -Wstrict-aliasing support            : ok
Checking for program 'doxygen'                                     : /usr/bin/doxygen
---- Summary of optional NS-3 features:
Build profile                 : debug
Build directory               :
BRITE Integration             : enabled
DES Metrics event collection  : not enabled (defaults to disabled)
Emulation FdNetDevice         : enabled
Examples                      : enabled
File descriptor NetDevice     : enabled
GNU Scientific Library (GSL)  : enabled
Gcrypt library                : not enabled (libgcrypt not found: you can use libgcrypt-config to find its location.)
GtkConfigStore                : enabled
MPI Support                   : not enabled (option --enable-mpi not selected)
NS-3 Click Integration        : enabled
NS-3 OpenFlow Integration     : enabled
Network Simulation Cradle     : enabled
PlanetLab FdNetDevice         : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
PyViz visualizer              : enabled
Python API Scanning Support   : enabled
Python Bindings               : enabled
Real Time Simulator           : enabled
SQlite stats data output      : enabled
Tap Bridge                    : enabled
Tap FdNetDevice               : enabled
Tests                         : enabled
Threading Primitives          : enabled
Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
XmlIo                         : enabled
'configure' finished successfully (3.714s)

Has anyone seen a similar problem before ? Would you suggest any fix for this problem?

I really appreciate any pointers that can help me with this,
B Fonseca

Tom Henderson

unread,
Nov 28, 2017, 12:36:12 PM11/28/17
to ns-3-...@googlegroups.com
On 11/28/2017 09:33 AM, bjfons...@gmail.com wrote:
> Hello,
>
> I'm sorry for taking your time with this, but I've been trying to
> solve this problem for a couple of days now.

No need to apologize, I understand that this is difficult to use at the
moment (we are working on this).  Thanks for a careful report; I will
try to reproduce it today and get back to you.

- Tom


Tom Henderson

unread,
Nov 29, 2017, 11:03:30 AM11/29/17
to ns-3-...@googlegroups.com, bjfons...@gmail.com
On 11/28/2017 09:33 AM, bjfons...@gmail.com wrote:
> Hello,
>
> I'm sorry for taking your time with this, but I've been trying to
> solve this problem for a couple of days now.
>
> I downloaded the new NS3.27 version using bake.py and I was trying to
> modify some functions of LR-WPAN. When regenerating the Python
> bindings (using the ./waf --apiscan=lr-wpan --no32bits-scan), castxml
> complained of an error.
>
> "castxml: /usr/lib/llvm-3.7/include/clang/AST/Decl.h:169:
> llvm::StringRef clang::NamedDecl::getName() const: Assertion
> `Name.isIdentifier() && "Name is not a simple identifier"' failed."

Hello, I was not able to reproduce your problem on a Ubuntu 16.04 64-bit
machine.  I was using libclang-3.8 but I removed it in place of
libclang-3.7 but it still worked for me.  Let's try to resolve it off
list and report back the summary at a later date.

- Tom

bjfons...@gmail.com

unread,
Nov 30, 2017, 8:08:27 PM11/30/17
to ns-3-users
After Tom's invaluable help, this problem is solved.

Tom pointed out that the solution is to issue the following commands:
(as per the 'workaround' in the first comment of https://github.com/iovisor/bcc/issues/492 )

sudo apt-get install -y llvm-3.8-dev libclang-3.8-dev

sudo mkdir -p /usr/lib/llvm-3.8/share/llvm

sudo ln -s /usr/share/llvm-3.8/cmake /usr/lib/llvm-3.8/share/llvm/cmake

sudo sed -i -e '/get_filename_component(LLVM_INSTALL_PREFIX/ {s|^|#|}' -e '/^# Compute the installation prefix/i set(LLVM_INSTALL_PREFIX "/usr/lib/llvm-3.8")' /usr/lib/llvm-3.8/share/llvm/cmake/LLVMConfig.cmake

sudo sed -i '/_IMPORT_CHECK_TARGETS Polly/ {s|^|#|}' /usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports-relwithdebinfo.cmake

sudo sed -i '/_IMPORT_CHECK_TARGETS sancov/ {s|^|#|}' /usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports-relwithdebinfo.cmake

sudo ln -s /usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1 /usr/lib/llvm-3.8/lib/

After this, I reinstalled NS3.27 using bake.py (following the instructions of the manual)
https://www.nsnam.org/docs/manual/html/python.html#working-with-python-bindings

When running ./bake.py build, make sure to check that CastXml was built "OK".

Then run ./waf configure

IMPORTANT: make sure that waf finds the castxml that you've built. In other words, you may have an old version of castxml in your /usr/bin/ directory. I.e., you should see something like
Checking for program 'castxml'                                     : ~/ns-allinone-3.27/build/bin/castxml

To make sure waf finds the castxml that you just built, do the following: go to the build/bin directory and issue the following commands:

cd ~/ns-allinone-3.27/bake/build/bin
export PATH=`pwd`:$PATH

then run ./waf configure again.

After that, I was able to run

./waf --apiscan=lr-wpan --no32bit-scan

and the python bindings were generated.

Thanks again to Tom's help.

B Fonseca

Reply all
Reply to author
Forward
0 new messages