Open Louw123 opened 5 months ago
Sounds like 'cpp' is misbehaving on your system, or the binaryen header files are somehow totally messed up compared to what I have on my (linux) box.
The code runs cpp -nostdinc -E -P /usr/include/binaryen-c.h
(or on /usr/local/include/binaryen-c.h if that one doesn't exist). It looks like this results in something weird "struct Binaryen##Module { };" on your system, whereas the code expects a stripped header file with binaryens function prototypes...
What is the result when you run this command manually?
Can you try replacing "cpp" with "gcc", "-E" in the binaryen.py file and see what happens?
Traceback (most recent call last): File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/cffi/cparser.py", line 336, in _parse ast = _get_parser().parse(fullcsource) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/pycparser/c_parser.py", line 147, in parse return self.cparser.parse( ^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/pycparser/ply/yacc.py", line 331, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/pycparser/ply/yacc.py", line 1199, in parseopt_notrack tok = call_errorfunc(self.errorfunc, errtoken, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/pycparser/ply/yacc.py", line 193, in call_errorfunc r = errorfunc(token) ^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/pycparser/c_parser.py", line 1931, in p_error self._parse_error( File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/pycparser/plyparser.py", line 67, in _parse_error raise ParseError("%s: %s" % (coord, msg)) pycparser.plyparser.ParseError: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:76:27: before: __darwin_va_list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/louismcmaster/PycharmProjects/pythonProject/.venv/lib/python3.12/site-packages/binaryen.py", line 78, in
I don't know what's the problem. It works fine on Linux. Someone knowledgeable with Mac OS programming has to step in here.
you mignt need to change the code https://github.com/python-cffi/cffi/issues/68#issuecomment-1962270913 https://github.com/python-cffi/cffi/issues/68#issuecomment-1962271759
so the other person is reasoning that the c preprocessor on Mac is leaving stuff in the output file (that is fed into cffi) that shouldn't be there?
Not much I can do about that.
have you alreadt tried replacing cpp with gcc in the binaryen.py file to see if that makes a difference?
any update on this? have you tried the suggestion?
Traceback (most recent call last): File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/cffi/cparser.py", line 336, in _parse ast = _get_parser().parse(fullcsource) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/pycparser/c_parser.py", line 147, in parse return self.cparser.parse( ^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/pycparser/ply/yacc.py", line 331, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/pycparser/ply/yacc.py", line 1199, in parseopt_notrack tok = call_errorfunc(self.errorfunc, errtoken, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/pycparser/ply/yacc.py", line 193, in call_errorfunc r = errorfunc(token) ^^^^^^^^^^^^^^^^ File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/pycparser/c_parser.py", line 1931, in p_error self._parse_error( File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/pycparser/plyparser.py", line 67, in _parse_error raise ParseError("%s: %s" % (coord, msg)) pycparser.plyparser.ParseError::1:16: before: #
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/louismcmaster/PycharmProjects/pythonProject1/btest.py", line 1, in
import binaryen
File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/binaryen.py", line 78, in
ffi.cdef(parse_header_file())
File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/cffi/api.py", line 112, in cdef
self._cdef(csource, override=override, packed=packed, pack=pack)
File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/cffi/api.py", line 126, in _cdef
self._parser.parse(csource, override=override, **options)
File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/cffi/cparser.py", line 389, in parse
self._internal_parse(csource)
File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/cffi/cparser.py", line 394, in _internal_parse
ast, macros, csource = self._parse(csource)
^^^^^^^^^^^^^^^^^^^^
File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/cffi/cparser.py", line 338, in _parse
self.convert_pycparser_error(e, csource)
File "/Users/louismcmaster/PycharmProjects/pythonProject1/.venv/lib/python3.11/site-packages/cffi/cparser.py", line 367, in convert_pycparser_error
raise CDefError(msg)
cffi.CDefError: cannot parse "struct Binaryen##Module { };"