python / python/cpython

Building against libuuid without pkgconfig fails if OSSP uuid is installed

未關閉
#147,977 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

build extension-modules type-bug
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

When building Python on a system where:

  • libuuid is installed without pkgconfig
  • OSSP uuid is installed (uuid-devel on RHEL/Rocky/Alma)
  • OSSP uuid's uuid.h is installed as /usr/include/uuid.h (the case on RHEL/Rocky/Alma)

the build fails with the following error:

./Modules/_uuidmodule.c: In function ‘py_uuid_generate_time_safe’:
./Modules/_uuidmodule.c:31:12: error: storage size of ‘uuid’ isn’t known
   31 |     uuid_t uuid;
      |            ^~~~
./Modules/_uuidmodule.c:35:11: error: implicit declaration of function ‘uuid_generate_time_safe’; did you mean ‘py_uuid_generate_time_safe’? [-Werror=implicit-function-declaration]
   35 |     res = uuid_generate_time_safe(uuid);
      |           ^~~~~~~~~~~~~~~~~~~~~~~
      |           py_uuid_generate_time_safe

This is because on such a system, both HAVE_UUID_H and HAVE_UUID_UUID_H become set:

$ grep 'HAVE_UUID.*_H' pyconfig.h
#define HAVE_UUID_H 1
#define HAVE_UUID_UUID_H 1

-I/usr/include/uuid does not get added to CFLAGS:

$ grep ^MODULE__UUID_CFLAGS Makefile
MODULE__UUID_CFLAGS=

and Modules/_uuidmodule.c currently checks HAVE_UUID_H before HAVE_UUID_UUID_H:

#if defined(HAVE_UUID_H)
  // AIX, FreeBSD, libuuid with pkgconf
  #include <uuid.h>
#elif defined(HAVE_UUID_UUID_H)
  // libuuid without pkgconf
  #include <uuid/uuid.h>
#endif

This causes the wrong uuid.h to be included.

The order in which HAVE_UUID_H and HAVE_UUID_UUID_H are checked was inverted in commit 8af6481f6b7d43646c47d8fa6cc6d5eb465e2b0f, but neither the commit itself or the related issue documents why the order was changed.

Building Python on a system with the properties described in this issue did work as expected in Python 3.10 (3.11 was the first release to include the reordering mentioned above).

Reproducer

docker run --rm -it almalinux:9

dnf install -y 'dnf-command(builddep)'
dnf --enablerepo=crb builddep -y python3
dnf --enablerepo=crb install -y uuid-devel

rm -f /usr/lib64/pkgconfig/uuid.pc

curl -O https://www.python.org/ftp/python/3.14.3/Python-3.14.3.tgz
tar -xf Python-3.14.3.tgz
cd Python-3.14.3

./configure
make -j$(nproc)
CPython versions tested on:

3.14

Operating systems tested on:

Linux

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Modules/_uuidmodule.c 開始,檢查 configure 如何在 pyconfig.h 和 Makefile 中產生 HAVE_UUID_H、HAVE_UUID_UUID_H 和 MODULE__UUID_CFLAGS。在 AlmaLinux 9 上使用 issue 中的命令重現該失敗,然後驗證在不使用 pkgconfig 且已安裝 OSSP uuid 的情況下建置能夠成功,並包含預期的 libuuid 標頭檔。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
build-system
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
描述清楚
新手友好度
70/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。