New submission from Ziqiao Kong <ziqiaok...@gmail.com>:
Hello! Thanks for your contribution on porting python to native Apple Silicon. I have noticed that there is an issue https://bugs.python.org/issue41100 and corresponding Github PR https://github.com/python/cpython/pull/22855 stating that variadic functions ABI has been corrected. However, during our test, it still doesn't work on Apple Silicon with brew-installed python 3.9.1 and python 3..10.0a4 built from sources. The details are as follows: A x86_64 Mojave Macmini with python 3.8: ``` /tmp $ python3 --version Python 3.8.6 /tmp $ uname -a Darwin *** 18.7.0 Darwin Kernel Version 18.7.0: Mon Apr 27 20:09:39 PDT 2020; root:xnu-4903.278.35~1/RELEASE_X86_64 x86_64 /tmp $ cat main.c #include <stdarg.h> #include <stdio.h> #include <stdint.h> void test(uint64_t end, ...){ int a; va_list valist; va_start(valist, end); a = va_arg(valist, int); va_end(valist); printf("%d\n", a); return; } /tmp $ cc -shared -g main.c -o ./main.dylib /tmp $ cat test_main.py from ctypes import * d = CDLL("./main.dylib") d.test.restype = None d.test(c_uint64(12), c_int(34)) /tmp $ python3 test_main.py 34 /tmp $ ``` An M1 Macbook Pro with brew-installed python 3.9.1 ``` kabeor@kamino /tmp % python3 --version Python 3.9.1 kabeor@kamino /tmp % cat main.c #include <stdarg.h> #include <stdio.h> #include <stdint.h> void test(uint64_t end, ...){ int a; va_list valist; va_start(valist, end); a = va_arg(valist, int); va_end(valist); printf("%d\n", a); return; } kabeor@kamino /tmp % cc -shared -g main.c -o ./main.dylib kabeor@kamino /tmp % cat test_main.py from ctypes import * d = CDLL("./main.dylib") d.test.restype = None d.test(c_uint64(12), c_int(34)) kabeor@kamino /tmp % python3 test_main.py 48144104 kabeor@kamino /tmp % ``` An M1 Macbook Pro with python 3.10.0a4 built from Github release tarball ``` kabeor@kamino cpython-3.10.0a4 % ./python.exe --version Python 3.10.0a4 kabeor@kamino cpython-3.10.0a4 % cp /tmp/main.c ./ kabeor@kamino cpython-3.10.0a4 % cp /tmp/test_main.py ./ kabeor@kamino cpython-3.10.0a4 % ./python.exe --version Python 3.10.0a4 kabeor@kamino cpython-3.10.0a4 % cat ./main.c #include <stdarg.h> #include <stdio.h> #include <stdint.h> void test(uint64_t end, ...){ int a; va_list valist; va_start(valist, end); a = va_arg(valist, int); va_end(valist); printf("%d\n", a); return; } kabeor@kamino cpython-3.10.0a4 % cc -shared -g main.c -o ./main.dylib kabeor@kamino cpython-3.10.0a4 % cat test_main.py from ctypes import * d = CDLL("./main.dylib") d.test.restype = None d.test(c_uint64(12), c_int(34)) kabeor@kamino cpython-3.10.0a4 % ./python.exe test_main.py 3 kabeor@kamino cpython-3.10.0a4 % ``` Thanks in advance! ---------- components: ctypes messages: 384756 nosy: lawrence-danna-apple, lazymio priority: normal severity: normal status: open title: ctypes: variadic function call still doesn't work on Apple Silicon versions: Python 3.10, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42880> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com