Skip to content

Compilation error on MSYS2 UCRT64/Clang64: static_cast type mismatch for clang_getFileContents and clang_getFileTime #10

@markusfn

Description

@markusfn

environment: MSYS2 (ucrt64 and/or clang64), Python 3.12. The error seems to stem from long long vs. long type mismatches for size_t and time_t in the generated binding code. I updated MSYS2 and installed relevant mingw-w64--clang or mingw-w64--gcc packages.

error message: in ucrt64 (it persists in clang64)
$ pip install pybind11-weaver
Collecting pybind11-weaver
Using cached pybind11_weaver-0.1.3-py3-none-any.whl.metadata (8.5 kB)
Collecting pylibclang (from pybind11-weaver)
Using cached pylibclang-316.0.6.tar.gz (191 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting PyYAML (from pybind11-weaver)
Using cached pyyaml-6.0.2-cp312-cp312-mingw_x86_64_ucrt_gnu.whl
Collecting pybind11 (from pybind11-weaver)
Using cached pybind11-2.13.6-py3-none-any.whl.metadata (9.5 kB)
Collecting attrs (from pybind11-weaver)
Using cached attrs-25.3.0-py3-none-any.whl.metadata (10 kB)
Using cached pybind11_weaver-0.1.3-py3-none-any.whl (35 kB)
Using cached attrs-25.3.0-py3-none-any.whl (63 kB)
Using cached pybind11-2.13.6-py3-none-any.whl (243 kB)
Building wheels for collected packages: pylibclang
Building wheel for pylibclang (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for pylibclang (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [75 lines of output]
F:/msys64/tmp/pip-build-env-15gg08sn/overlay/lib/python3.12/site-packages/setuptools/config/_a
pply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: project.license as a TOML table is depreca
ted
!!

          ********************************************************************************
          Please use a simple string containing a SPDX expression for `project.license`. You can

also use project.license-files. (Both options available on setuptools>=77.0.0).

          By 2026-Feb-18, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.

          See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for

details.
********************************************************************************

  !!
    corresp(dist, value, root_dir)
  F:/msys64/tmp/pip-build-env-15gg08sn/overlay/lib/python3.12/site-packages/setuptools/config/_a

pply_pyprojecttoml.py:61: SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!

          ********************************************************************************
          Please consider removing the following classifiers in favor of a SPDX license expressi

on:

          License :: OSI Approved :: MIT License

          See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for

details.
********************************************************************************

  !!
    dist._finalize_license_expression()
  F:/msys64/tmp/pip-build-env-15gg08sn/overlay/lib/python3.12/site-packages/setuptools/dist.py:7

59: SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!

          ********************************************************************************
          Please consider removing the following classifiers in favor of a SPDX license expressi

on:

          License :: OSI Approved :: MIT License

          See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for

details.
********************************************************************************

  !!
    self._finalize_license_expression()
  running bdist_wheel
  running build
  running build_py
  creating build/lib.mingw_x86_64_ucrt_gnu-cpython-312/pylibclang
  copying pylibclang/cindex.py -> build/lib.mingw_x86_64_ucrt_gnu-cpython-312/pylibclang
  copying pylibclang/__init__.py -> build/lib.mingw_x86_64_ucrt_gnu-cpython-312/pylibclang
  running egg_info
  writing pylibclang.egg-info/PKG-INFO
  writing dependency_links to pylibclang.egg-info/dependency_links.txt
  writing top-level names to pylibclang.egg-info/top_level.txt
  reading manifest file 'pylibclang.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'pylibclang.egg-info/SOURCES.txt'
  running build_ext
  building 'pylibclang._C' extension
  creating build/temp.mingw_x86_64_ucrt_gnu-cpython-312/c_src
  g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -march=nocona -msahf -mtune=gene

ric -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wp,-D__USE_MINGW_ANSI_STDIO=1 -O3 -m
arch=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wp,-D_
_USE_MINGW_ANSI_STDIO=1 -O3 -Ic_src/include/clang/include -IF:/msys64/tmp/pip-build-env-15gg08sn/ove
rlay/lib/python3.12/site-packages/pybind11/include -IF:/msys64/home/Einfacher/venv312/include -IF:/m
sys64/ucrt64/include/python3.12 -c c_src/binding.cc -o build/temp.mingw_x86_64_ucrt_gnu-cpython-312/
c_src/binding.o -fvisibility=hidden -g0 -std=c++17 -Wno-deprecated-declarations
In file included from c_src/binding.cc:7:
c_src/_binding.cc.inc: In lambda function:
c_src/_binding.cc.inc:23398:15: error: invalid 'static_cast' from type 'const char* ()(CXTran
slationUnit, CXFile, size_t
)' {aka 'const char* ()(CXTranslationUnitImpl, void*, long long unsign
ed int*)'} to type 'pybind11_weaver::FnPtrT<void, const char*(CXTranslationUnitImpl*, void*, long un
signed int*)>::type' {aka 'const char* ()(CXTranslationUnitImpl, void*, long unsigned int*)'} [-Wt
emplate-body]
23398 | static_cast<pybind11_weaver::FnPtrT<
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23399 | void, const char (CXTranslationUnitImpl , void ,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23400 | unsigned long )>::type>(
| ~~~~~~~~~~~~~~~~~~~~~~~~~
23401 | &clang_getFileContents),
| ~~~~~~~~~~~~~~~~~~~~~~~
c_src/_binding.cc.inc: In lambda function:
c_src/_binding.cc.inc:23580:15: error: invalid 'static_cast' from type 'time_t (
)(CXFile)' {a
ka 'long long int (
)(void
)'} to type 'pybind11_weaver::FnPtrT<void, long int(void
)>::type' {aka '
long int ()(void)'} [-Wtemplate-body]
23580 | static_cast<pybind11_weaver::FnPtrT<void, long(void *)>::type>(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23581 | &clang_getFileTime),
| ~~~~~~~~~~~~~~~~~~~
error: command 'F:\msys64\ucrt64\bin/g++.EXE' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pylibclang
Failed to build pylibclang

[notice] A new release of pip is available: 25.0.1 -> 25.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip
ERROR: Failed to build installable wheels for some pyproject.toml based projects (pylibclang)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions