Skip to content

Prefix option does not allow POSIX default values when cross-compiling on Windows with Python 3.13 #14303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dominikbuenger opened this issue Feb 27, 2025 · 0 comments

Comments

@dominikbuenger
Copy link

Describe the bug
When cross-compiling on Windows for a Linux system, we need to pass a POSIX path like /usr to the built-in prefix option.

The behaviour has changed due to a bugfix in Python 3.13. Now, if you supply the prefix via the default_options argument to project(), that causes the following error output:

$ meson setup --cross-file crossfile.ini builddir
The Meson build system
Version: 1.7.0
Source dir: C:\Users\dbuenger\test\20250227_meson-prefix-bug
Build dir: C:\Users\dbuenger\test\20250227_meson-prefix-bug\builddir
Build type: cross build

meson.build:1:0: ERROR: prefix value '/usr' must be an absolute path

I did a little digging and found out that Meson calls os.path.isabs() do determine whether the default prefix value is valid. The behavior of that function has changed in Python 3.13. Previously, it returned True for paths starting with a single slash. However, this was considered a bug that was fixed in the most recent version. Here's the issue on the cpython repo: python/cpython#113829

A workaround is to pass the prefix via the CLI:

$ meson setup --cross-file crossfile.ini --prefix C:/usr builddir

(If you pass /usr instead of C:/usr, Meson will set the prefix to C:/Program Files/Git/usr. I don't know if this expansion is done by meson or by the Git Bash shell I'm using -- I'm assuming the latter.)

To Reproduce

Runmeson setup --cross-file crossfile.ini builddir with the following meson.build:

project(
    'hello_world', 'c',
    default_options : ['prefix=/usr'])

executable('hello_world', 'main.c', install : true)

The main.c can basically be empty. Here's my crossfile.ini:

[constants]
gcc_linux_path = 'C:/Xilinx/SDK/2018.3/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin'

[binaries]
c = gcc_linux_path / 'arm-linux-gnueabihf-gcc'
ar = gcc_linux_path / 'arm-linux-gnueabihf-ar'
strip = gcc_linux_path / 'arm-linux-gnueabihf-strip'
size = gcc_linux_path / 'arm-linux-gnueabihf-size'

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7'
endian = 'little'

[properties]
cc_path = gcc_linux_path

Expected behavior
When cross-compiling, Meson accepts an absolute POSIX path like /usr as the default value to the prefix option, even on Windows, without relying on the system-dependent os.path.isabs().

system parameters

  • Cross Build
  • Windows 11
  • Python 3.13.2
  • Meson 1.7.0
  • Ninja 1.11.1.git.kitware.jobserver-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants