python / python/cpython

failure building Python 3.15.0a3 on Alpine

Đang mở
#143,632 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

build OS-unsupported type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

When building Python 3.15.0a3 - 3.15.0rc2 on Alpine Linux 3.23 (musl libc) on certain architectures, the build fails with error: redefinition of 'struct prctl_mm_map' (full error below).

This is related to the changes added in https://github.com/python/cpython/pull/142079. TL;DR: in musl libc, some kernel structs are redefined in the musl-provided headers. In this case sys/prctl.h redefines a struct in linux/prctl.h; see also https://wiki.musl-libc.org/faq.html#Q:-Why-am-I-getting-.

Configure setup:

gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"
./configure \
	--build="$gnuArch" \
	--enable-loadable-sqlite-extensions \
	--enable-option-checking=fatal \
	--enable-shared \
	--with-lto \
	--with-ensurepip

# --with-lto is not used on riscv64

Make lines, per architecture:

# nproc is used for the number of jobs, so it varies by system
# amd64 and arm64v8
make -j 8 'EXTRA_CFLAGS=-DTHREAD_STACK_SIZE=0x100000 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer' 'LDFLAGS=-Wl,--strip-all'
# i386 (x86)
make -j 8 'EXTRA_CFLAGS=-DTHREAD_STACK_SIZE=0x100000' 'LDFLAGS=-Wl,--strip-all'
# arm32v6, arm32v7, ppc64le, riscv64, s390x
make -j 8 'EXTRA_CFLAGS=-DTHREAD_STACK_SIZE=0x100000 -fno-omit-frame-pointer' 'LDFLAGS=-Wl,--strip-all' 

When building on arm32v6, arm32v7, i386, and ppc64le, the configure check for PR_SET_VMA_ANON_NAME succeeds and so it is attempted to be used during build, but during build, it fails with the following error:

$ # configure line:
checking whether PR_SET_VMA_ANON_NAME is declared... yes
$ # build error during "make"
In file included from ./Include/internal/pycore_mmap.h:25,
                 from Objects/obmalloc.c:5:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
   88 | struct prctl_mm_map {
      |        ^~~~~~~~~~~~
In file included from ./Include/internal/pycore_mmap.h:24:
/usr/include/linux/prctl.h:134:8: note: originally defined here
  134 | struct prctl_mm_map {
      |        ^~~~~~~~~~~~

But on amd64, arm64v8, riscv64, and s390x (or any arch on Alpine 3.22), the same error is encountered during the configure check, so the feature is disabled, and it doesn't cause a build error.

$ # configure.log
configure:23951: checking whether PR_SET_VMA_ANON_NAME is declared
configure:23951: gcc -c    conftest.c >&5
In file included from conftest.c:415:
/usr/include/sys/prctl.h:103:1: error: redefinition of struct or union 'struct prctl_mm_map'
  103 | };
      | ^
In file included from conftest.c:414:
/usr/include/linux/prctl.h:134:8: note: originally defined here
  134 | struct prctl_mm_map {
      |        ^~~~~~~~~~~~
configure:23951: $? = 1

So, what is weird to me, is that the AC_CHECK_DECLS([PR_SET_VMA_ANON_NAME], succeeded on some architectures and then the same set of includes failed when in Include/internal/pycore_mmap.h. But also, this new feature is silently disabled (even if available in the kernel headers) because the configure check fails on Alpine because of the redefined struct in musl libc.

I think an #ifdef __GLIBC__ or similar could be used to only include both headers when using glibc, but maybe it is more complex than that.


Full build setup: https://github.com/docker-library/python/blob/ac65a0ec34172eb865a8cef47fed3dc71a38d419/3.15-rc/alpine3.23/Dockerfile
Full build log: https://doi-janky.infosiftr.net/job/meta/view/builds/job/arm32v7/job/build/88902/console

Linked PRs
  • gh-143730
  • gh-143839
  • gh-148771

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với Include/internal/pycore_mmap.h, kiểm tra AC_CHECK_DECLS cho PR_SET_VMA_ANON_NAME và lỗi trong Objects/obmalloc.c. Tái hiện bản build trên Alpine Linux 3.23 bằng Dockerfile được liên kết và so sánh các kiến trúc cùng các log configure. Hoàn tất khi các bản build Alpine bị ảnh hưởng không còn thất bại do struct được định nghĩa lại và việc kiểm tra tính năng hoạt động nhất quán.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c, linux, python
Lĩnh vực
build-system, operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.