Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python/cffi_example: use a specific tag when recompiling with bare CC
There are issues when using CC='clang -m32' with PyPy-3.7 python ./cffi_example.py getuid() = 1001 getgid() = 121 getpid() = 22233 Traceback (most recent call last): File "./cffi_example.py", line 37, in <module> libv = ffi.verify('const size_t LONG_SIZE = sizeof(long);') File "/opt/hostedtoolcache/PyPy/3.7.10/x64/lib_pypy/cffi/api.py", line 468, in verify lib = self.verifier.load_library() File "/opt/hostedtoolcache/PyPy/3.7.10/x64/lib_pypy/cffi/verifier.py", line 106, in load_library return self._load_library() File "/opt/hostedtoolcache/PyPy/3.7.10/x64/lib_pypy/cffi/verifier.py", line 217, in _load_library return self._vengine.load_library() File "/opt/hostedtoolcache/PyPy/3.7.10/x64/lib_pypy/cffi/vengine_gen.py", line 70, in load_library module = backend.load_library(filename, flags) OSError: Cannot load library /home/runner/work/shared/shared/python/__pycache__/_cffi__g2731a638xb51bc5c3.pypy37-pp73-x86_64-linux-gnu.so: /home/runner/work/shared/shared/python/__pycache__/_cffi__g2731a638xb51bc5c3.pypy37-pp73-x86_64-linux-gnu.so: wrong ELF class: ELFCLASS32 This is caused by the "retry without $CC" logic using the same cached filename (here _cffi__g2731a638xb51bc5c3.pypy37-pp73-x86_64-linux-gnu.so). Instead, define a custom tag which is included in the file name: https://foss.heptapod.net/pypy/pypy/-/blob/release-pypy3.7-v7.3.3/lib_pypy/cffi/verifier.py#L62 NB. Use a tag with an underscore, as it is used to name some functions of the C module, in CPython 3.5: __pycache__/_cffi_empty-cc_xfda08e47xb51bc5c3.c:303:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token PyInit__cffi_empty-cc_xfda08e47xb51bc5c3(void) ^ __pycache__/_cffi_empty-cc_xfda08e47xb51bc5c3.c:293:27: warning: ‘_cffi_module_def’ defined but not used [-Wunused-variable] static struct PyModuleDef _cffi_module_def = { ^~~~~~~~~~~~~~~~
- Loading branch information