Skip to content

Compilation Error: _tkinter.c incompatible pointer types with Tcl 9.0 (LoongArch64) #948

@wojiushixiaobai

Description

@wojiushixiaobai

Building CPython 3.10 on loongarch64-linux-gnu fails during the compilation of Modules/_tkinter.c. The error is caused by a type mismatch between int * and Tcl_Size * (which is long int * on this architecture) when calling Tcl API functions.

cpython-3.10> sed -e "s,@EXENAME@,/install/bin/python3.10d," < ./Misc/python-config.in >python-config.py
cpython-3.10> LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/python-config.sh >python-config
cpython-3.10> /usr/bin/loongarch64-linux-gnu-gcc -pthread -shared -L/tools/deps/lib -Wl,--exclude-libs,ALL     Modules/_cryptmodule.o  -lcrypt  -o Modules/_crypt.cpython-310d-loongarch64-linux-gnu.so
cpython-3.10> ./Modules/_tkinter.c:136:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
cpython-3.10>   136 | _get_tcl_lib_path()
cpython-3.10>       | ^~~~~~~~~~~~~~~~~
cpython-3.10> ./Modules/_tkinter.c: In function 'Split':
cpython-3.10> ./Modules/_tkinter.c:559:49: error: passing argument 3 of 'Tcl_SplitList' from incompatible pointer type [-Wincompatible-pointer-types]
cpython-3.10>   559 |     if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
cpython-3.10>       |                                                 ^~~~~
cpython-3.10>       |                                                 |
cpython-3.10>       |                                                 int *
cpython-3.10> In file included from /tools/deps/include/tcl.h:2431,
cpython-3.10>                  from ./Modules/_tkinter.c:45:
cpython-3.10> /tools/deps/include/tclDecls.h:1799:64: note: expected 'Tcl_Size *' {aka 'long int *'} but argument is of type 'int *'
cpython-3.10>  1799 |                                 const char *listStr, Tcl_Size *argcPtr,
cpython-3.10>       |                                                      ~~~~~~~~~~^~~~~~~
cpython-3.10> ./Modules/_tkinter.c: In function 'SplitObj':
cpython-3.10> ./Modules/_tkinter.c:658:53: error: passing argument 3 of 'Tcl_SplitList' from incompatible pointer type [-Wincompatible-pointer-types]
cpython-3.10>   658 |             Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
cpython-3.10>       |                                                     ^~~~~
cpython-3.10>       |                                                     |
cpython-3.10>       |                                                     int *
cpython-3.10> /tools/deps/include/tclDecls.h:1799:64: note: expected 'Tcl_Size *' {aka 'long int *'} but argument is of type 'int *'
cpython-3.10>  1799 |                                 const char *listStr, Tcl_Size *argcPtr,
cpython-3.10>       |                                                      ~~~~~~~~~~^~~~~~~
cpython-3.10> ./Modules/_tkinter.c:672:61: error: passing argument 3 of 'Tcl_SplitList' from incompatible pointer type [-Wincompatible-pointer-types]
cpython-3.10>   672 |         if (Tcl_SplitList((Tcl_Interp *)NULL, (char *)list, &argc, &argv) != TCL_OK) {
cpython-3.10>       |                                                             ^~~~~
cpython-3.10>       |                                                             |
cpython-3.10>       |                                                             int *
cpython-3.10> /tools/deps/include/tclDecls.h:1799:64: note: expected 'Tcl_Size *' {aka 'long int *'} but argument is of type 'int *'
cpython-3.10>  1799 |                                 const char *listStr, Tcl_Size *argcPtr,
cpython-3.10>       |                                                      ~~~~~~~~~~^~~~~~~
cpython-3.10> /usr/bin/loongarch64-linux-gnu-gcc -pthread -shared -L/tools/deps/lib -Wl,--exclude-libs,ALL     Modules/_ctypes_test.o  -lm  -o Modules/_ctypes_test.cpython-310d-loongarch64-linux-gnu.so
cpython-3.10> ./Modules/_tkinter.c: In function '_tkinter_tkapp_split':
cpython-3.10> ./Modules/_tkinter.c:2458:36: error: passing argument 3 of 'Tcl_ListObjGetElements' from incompatible pointer type [-Wincompatible-pointer-types]
cpython-3.10>  2458 |                                    &objc, &objv) == TCL_ERROR) {
cpython-3.10>       |                                    ^~~~~
cpython-3.10>       |                                    |
cpython-3.10>       |                                    int *
cpython-3.10> /tools/deps/include/tclDecls.h:1789:61: note: expected 'Tcl_Size *' {aka 'long int *'} but argument is of type 'int *'
cpython-3.10>  1789 |                                 Tcl_Obj *listPtr, Tcl_Size *objcPtr,
cpython-3.10>       |                                                   ~~~~~~~~~~^~~~~~~
cpython-3.10> ./Modules/_tkinter.c: In function 'PyInit__tkinter':
cpython-3.10> ./Modules/_tkinter.c:3728:26: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
cpython-3.10>  3728 |                     path = PyUnicode_AsUTF8(str_path);
cpython-3.10>       |                          ^
cpython-3.10> /usr/bin/loongarch64-linux-gnu-gcc -pthread -shared -L/tools/deps/lib -Wl,--exclude-libs,ALL     Modules/_dbmmodule.o  -ldb  -o Modules/_dbm.cpython-310d-loongarch64-linux-gnu.so
cpython-3.10> make: *** [Makefile:2077: Modules/_tkinter.o] Error 1
cpython-3.10> make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "/home/runner/work/python-build-standalone/python-build-standalone/cpython-unix/build.py", line 1295, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/runner/work/python-build-standalone/python-build-standalone/cpython-unix/build.py", line 1277, in main
    build_cpython(
    ~~~~~~~~~~~~~^
        settings,
        ^^^^^^^^^
    ...<7 lines>...
        python_source=python_source,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/runner/work/python-build-standalone/python-build-standalone/cpython-unix/build.py", line 839, in build_cpython
    build_env.run("build-cpython.sh", environment=env)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/python-build-standalone/python-build-standalone/pythonbuild/buildenv.py", line 98, in run
    container_exec(self.container, program, user=user, environment=environment)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/python-build-standalone/python-build-standalone/pythonbuild/docker.py", line 150, in container_exec
    raise Exception("exit code %d from %s" % (inspect_res["ExitCode"], command))
Exception: exit code 2 from /build/build-cpython.sh
make: *** [Makefile:289: /home/runner/work/python-build-standalone/python-build-standalone/build/cpython-3.10.19-loongarch64-unknown-linux-gnu-debug.tar] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions