python / python/cpython

Compiling `--with-lto` results in `test_embed` failures on Darwin

Đang mở
#153,285 1 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-mac 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ả

Bug report

Bug description:

On Darwin, configure.ac:1998 sets:

LTOFLAGS="-flto=thin -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"

Which gets expanded too early in Makefile.pre.in:130 into "".lto (notice the :=):

PY_CORE_EXE_LDFLAGS:= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) $(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS))

Linking results in:

gcc    -flto=thin -Wl,-export_dynamic -Wl,-object_path_lto,"".lto -g  ...

Which happens to link Programs/_testembed as the interpreter, so that launching it results in:

$ ./Programs/_testembed           
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
WARN: Could not find the standard library directory! sys.prefix is set to /usr/local, is this correct?
Python 3.16.0a0 (heads/main:4f39efc47de, Jul  7 2026, 17:34:29) [Clang 21.0.0 (clang-2100.1.1.101)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

And related tests in the test_embed suite fail:

$ ./python.exe -m test -v test_embed
== CPython 3.16.0a0 (heads/main:4f39efc47de, Jul 7 2026, 17:34:29) [Clang 21.0.0 (clang-2100.1.1.101)]
== macOS-26.5.1-arm64-arm-64bit-Mach-O little-endian
== Python build: release ThinLTO
== cwd: ***
== CPU count: 16
== encodings: locale=UTF-8 FS=utf-8
== resources: all test resources are disabled, use -u option to unskip tests

Using random seed: 2037373937
0:00:00 load avg: 2.73 mem: 31.0 MiB Run 1 test sequentially in a single process
0:00:00 load avg: 2.73 mem: 31.0 MiB [1/1] test_embed
test_audit (test.test_embed.AuditingTests.test_audit) ... --- ['***/cpython/Programs/_testembed', 'test_audit'] failed ---
stdout:

stderr:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
WARN: Could not find the standard library directory! sys.prefix is set to /usr/local, is this correct?
***/Programs/_testembed: can't open file '***/test_audit': [Errno 2] No such file or directory

------
FAIL

It seems to me this was introduced by 4e45c9c.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-153532

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 bằng cách so sánh configure.ac:1998 với Makefile.pre.in:130, tập trung vào cách LTOFLAGS được mở rộng trong quá trình build Darwin. Tái tạo build ThinLTO và chạy ./python.exe -m test -v test_embed. Hoàn tất có nghĩa là _testembed khởi chạy chính xác và bộ test test_embed vượt qua; PR được liên kết gh-153532 cho thấy công việc có thể đã được tiến hành.

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

Đánh giá

Công nghệ
macos, python
Lĩnh vực
build-system, testing-qa
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 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
35/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.