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

More control over the xml_generator command ? #96

Open
teto opened this issue Dec 12, 2017 · 1 comment
Open

More control over the xml_generator command ? #96

teto opened this issue Dec 12, 2017 · 1 comment

Comments

@teto
Copy link

teto commented Dec 12, 2017

I am trying to parse the libC library, I had it working on Ubuntu. I've now switched to nixos but the working castxml command doesn't seem to be built from pygccxml.

My current python code has:

xml_generator_config = parser.xml_generator_configuration_t(
            xml_generator_path=generator_path,
            xml_generator=generator_name,
            include_paths=[
                "/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include",
                "/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include",
            ],
            cflags=" ",
            castxml_epic_version=1,
            )

with pygccxml 1.9.1 and castxml

castxml -v                                                                                                                                                                                                                                                     
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: 
Found candidate GCC installation: /nix/store/052l3p8a4m9iabs1smf1myj3g2w6rlij-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0
Found candidate GCC installation: /nix/store/052l3p8a4m9iabs1smf1myj3g2w6rlij-gcc-6.4.0/lib64/gcc/x86_64-unknown-linux-gnu/6.4.0
Selected GCC installation: /nix/store/052l3p8a4m9iabs1smf1myj3g2w6rlij-gcc-6.4.0/lib64/gcc/x86_64-unknown-linux-gnu/6.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

pygccxml generates and calls the following command (which fails):

/nix/store/bgsr6clnq2ivppapayqdbzklkmqbd75b-CastXML-20171003/bin/castxml  -nostdinc -I/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include -I/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include   -I"." -I"/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include" -c -x c++ --castxml-cc-gnu /home/teto/.nix-profile/bin/clang++ --castxml-output=1 -o /run/user/1000/tmp6d6aac0v.xml test.h
/nix/store/bgsr6clnq2ivppapayqdbzklkmqbd75b-CastXML-20171003/bin/castxml  -nostdinc -I/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include -I/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include   -I"." -I"/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include"  -x c++ --castxml-cc-gnu /home/teto/.nix-profile/bin/clang++ --castxml-output=1 -o /run/user/1000/tmp6d6aac0v.xml test.h
In file included from test.h:3:
In file included from /nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/stdio.h:862:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:360:7: warning: use of logical '&&' with constant
      operand [-Wconstant-logical-operand]
      && __builtin_constant_p (__n)
      ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:360:7: note: use '&' for a bitwise operation
      && __builtin_constant_p (__n)
      ^~
      &
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:360:7: note: remove constant to silence this warning
      && __builtin_constant_p (__n)
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:43:8: error: redefinition of a 'extern inline'
      function 'vsprintf' is not supported in C++
__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
       ^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:43:8: note: previous definition is here
__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
       ^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:74:8: error: redefinition of a 'extern inline'
      function 'vsnprintf' is not supported in C++
__NTH (vsnprintf (char *__restrict __s, size_t __n,
       ^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:74:8: note: previous definition is here
__NTH (vsnprintf (char *__restrict __s, size_t __n,
       ^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:114:1: error: redefinition of a 'extern inline'
      function 'vprintf' is not supported in C++
vprintf (const char *__restrict __fmt, _G_va_list __ap)
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:114:1: note: previous definition is here
vprintf (const char *__restrict __fmt, _G_va_list __ap)
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:124:1: error: redefinition of a 'extern inline'
      function 'vfprintf' is not supported in C++
vfprintf (FILE *__restrict __stream,
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:124:1: note: previous definition is here
vfprintf (FILE *__restrict __stream,
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:150:1: error: redefinition of a 'extern inline'
      function 'vdprintf' is not supported in C++
vdprintf (int __fd, const char *__restrict __fmt, _G_va_list __ap)
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:150:1: note: previous definition is here
vdprintf (int __fd, const char *__restrict __fmt, _G_va_list __ap)
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:207:8: error: redefinition of a 'extern inline'
      function 'vasprintf' is not supported in C++
__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
       ^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:207:8: note: previous definition is here
__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
       ^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:214:8: error: redefinition of a 'extern inline'
      function 'obstack_vprintf' is not supported in C++
__NTH (obstack_vprintf (struct obstack *__restrict __obstack,
       ^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:214:8: note: previous definition is here
__NTH (obstack_vprintf (struct obstack *__restrict __obstack,
       ^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:232:1: error: redefinition of a 'extern inline'
      function 'gets' is not supported in C++
gets (char *__str)
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:232:1: note: previous definition is here
gets (char *__str)
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:252:1: error: redefinition of a 'extern inline'
      function 'fgets' is not supported in C++
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:252:1: note: previous definition is here
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:281:1: error: redefinition of a 'extern inline'
      function 'fread' is not supported in C++
fread (void *__restrict __ptr, size_t __size, size_t __n,
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:281:1: note: previous definition is here
fread (void *__restrict __ptr, size_t __size, size_t __n,
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:310:1: error: redefinition of a 'extern inline'
      function 'fgets_unlocked' is not supported in C++
fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:310:1: note: previous definition is here
fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:342:1: error: redefinition of a 'extern inline'
      function 'fread_unlocked' is not supported in C++
fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
^
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:342:1: note: previous definition is here
fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
^
In file included from test.h:11:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:360:7: warning: use of logical '&&' with constant
      operand [-Wconstant-logical-operand]
      && __builtin_constant_p (__n)
      ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:360:7: note: use '&' for a bitwise operation
      && __builtin_constant_p (__n)
      ^~
      &
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/stdio2.h:360:7: note: remove constant to silence this warning
      && __builtin_constant_p (__n)
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from test.h:13:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/wchar.h:325:47: warning: comparison of unsigned expression >= 0 is
      always true [-Wtautological-compare]
{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
                                         ~~~~ ^  ~~~~~
In file included from test.h:70:
In file included from /nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/math.h:711:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/bits/mathinline.h:152:64: warning: use of GNU old-style field
      designator extension [-Wgnu-designator]
  __extension__ union { long double __l; int __i[3]; } __u = { __l: __x };
                                                               ^~~~
                                                               .__l = 
4 warnings and 12 errors generated.

If I edit the command manually aka remove the -c -x c++ --castxml-cc-gnu it seems to work better :

/nix/store/bgsr6clnq2ivppapayqdbzklkmqbd75b-CastXML-20171003/bin/castxml  -nostdinc -I/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include -I/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include   -I"." -I"/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include"   --castxml-cc-gnu /home/teto/.nix-profile/bin/clang++ --castxml-output=1 -o /run/user/1000/tmp6d6aac0v.xml test.h
/nix/store/bgsr6clnq2ivppapayqdbzklkmqbd75b-CastXML-20171003/bin/castxml  -nostdinc -I/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include -I/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include   -I"." -I"/nix/store/c30dlkmiyrjxxjv6nv63igjkzcj1fzxi-gcc-6.4.0/lib/gcc/x86_64-unknown-linux-gnu/6.4.0/include"    /home/teto/.nix-profile/bin/clang++ --castxml-output=1 -o /run/user/1000/tmp6d6aac0v.xml test.h
warning: /home/teto/.nix-profile/bin/clang++: 'linker' input unused [-Wunused-command-line-argument]
In file included from test.h:10:
/nix/store/mqalq0v2laqblw00dp7pwwckj2ra6jyh-glibc-2.26-75-dev/include/setjmp.h:54:12: warning: declaration of built-in function
      '__sigsetjmp' requires inclusion of the header <setjmp.h> [-Wbuiltin-requires-header]
extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;
           ^
1 warning generated.

Looking at the code, the --castxml-cc-gnu seems always added on linux so I wonder if there is a way around.

@iMichka
Copy link
Contributor

iMichka commented Dec 13, 2017

Hi. I’ll need to have a closer look to this.

One thing is that I would like to keep the cast mal command line setup as automatic as possible, so that a user does not have to fiddle too much with flags for castxml. This has always been like this in pygccxml, so I would like to keep that ease of use.

I thought that the —castxml-cc-gnu was needed for Linux. If I remember well it tells castxml that it will work with gcc. But I am unsure now. Maybe you could trace down what that flag does exactly in castxml.

Also, you may need to add a c++11 flag for gcc6, but I think it is not mandatory (but may help here)

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

2 participants