classification
Title: Header dependent _uuid build failure on Fedora 27
Type: compile error Stage: resolved
Components: Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: adam@NetBSD.org, christian.heimes, fthommen, miss-islington, ncoghlan, ned.deily, vstinner
Priority: low Keywords: patch, patch, patch, patch

Created on 2018-01-23 01:54 by ncoghlan, last changed 2019-07-02 22:34 by ned.deily. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11751 merged python-dev, 2019-02-03 10:02
PR 11751 merged python-dev, 2019-02-03 10:02
PR 11751 merged python-dev, 2019-02-03 10:02
PR 11751 merged python-dev, 2019-02-03 10:02
PR 14347 merged miss-islington, 2019-06-24 18:00
PR 14348 merged miss-islington, 2019-06-24 18:00
Messages (9)
msg310459 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-01-23 01:54
I'm hitting a build failure relating to the new _uuid module on Fedora 27:

==============
building '_uuid' extension
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include -I. -I/usr/local/include -I/home/ncoghlan/devel/cpython/Include -I/home/ncoghlan/devel/cpython -c /home/ncoghlan/devel/cpython/Modules/_uuidmodule.c -o build/temp.linux-x86_64-3.7/home/ncoghlan/devel/cpython/Modules/_uuidmodule.o
In file included from /home/ncoghlan/devel/cpython/Modules/_uuidmodule.c:8:0:
/usr/include/uuid.h:94:24: error: conflicting types for ‘uuid_t’
 typedef struct uuid_st uuid_t;
                        ^~~~~~
In file included from /home/ncoghlan/devel/cpython/Modules/_uuidmodule.c:5:0:
/usr/include/uuid/uuid.h:44:23: note: previous declaration of ‘uuid_t’ was here
 typedef unsigned char uuid_t[16];
                       ^~~~~~
In file included from /home/ncoghlan/devel/cpython/Modules/_uuidmodule.c:8:0:
/usr/include/uuid.h:107:22: error: conflicting types for ‘uuid_compare’
 extern uuid_rc_t     uuid_compare  (const uuid_t  *_uuid, const uuid_t *_uuid2, int *_result);
                      ^~~~~~~~~~~~
In file included from /home/ncoghlan/devel/cpython/Modules/_uuidmodule.c:5:0:
/usr/include/uuid/uuid.h:73:12: note: previous declaration of ‘uuid_compare’ was here
 extern int uuid_compare(const uuid_t uu1, const uuid_t uu2);
            ^~~~~~~~~~~~
/home/ncoghlan/devel/cpython/Modules/_uuidmodule.c: In function ‘py_uuid_generate_time_safe’:
/home/ncoghlan/devel/cpython/Modules/_uuidmodule.c:15:12: error: storage size of ‘uuid’ isn’t known
     uuid_t uuid;
            ^~~~
/home/ncoghlan/devel/cpython/Modules/_uuidmodule.c:15:12: warning: unused variable ‘uuid’ [-Wunused-variable]
/home/ncoghlan/devel/cpython/Modules/_uuidmodule.c:29:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
==============

From my initial investigation, I think the issue may be related to my previous attempt to fix this in https://github.com/python/cpython/commit/53efbf3977a44e382397e7994a2524b4f8c9d053#diff-2eeaed663bd0d25b7e608891384b7298 and the fact that there are *two* "uuid.h" headers available in the Fedora repos:

* /usr/include/uuid.h (provided by uuid-devel)
* /usr/include/uuid/uuid.h (provided by libuuid-devel)

Right now, the build works if you have "libuuid-devel" installed, but do *not* have "uuid-devel" installed.

With both installed, neither installed, or only uuid-devel installed, the build will fail, but the exact errors reported will vary. (There's also a distinct set of compile errors you can get if you forget to rerun configure after installing the additional headers)

Reverting my previous commit (and replacing it with a comment saying we're specifically looking for "uuid/uuid.h", not "uuid.h") may be enough to handle the case where both are installed.
msg310460 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-01-23 02:03
Reverting my previous commit doesn't fix the problem: if both uuid-devel and libuuid-devel are installed, then it reports that the necessary bits to build _uuid weren't found, without even attempting to compile it at all.
msg310465 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-01-23 03:09
(Reducing priority since "sudo dnf remove uuid-devel" is a straightforward workaround)
msg316255 - (view) Author: Adam (adam@NetBSD.org) Date: 2018-05-07 08:54
Some systems might have both uuid.h and uuid/uuid.h. For example, NetBSD provides /usr/include/uuid.h, and one might also install libuuid from a package, and the latter has uuid/uuid.h.

To fix this, do not include both files, when both have been detected.

Here is a patch:

--- Modules/_uuidmodule.c.orig
+++ Modules/_uuidmodule.c
@@ -3,8 +3,7 @@
 #include "Python.h"
 #ifdef HAVE_UUID_UUID_H
 #include <uuid/uuid.h>
-#endif
-#ifdef HAVE_UUID_H
+#elif defined(HAVE_UUID_H)
 #include <uuid.h>
 #endif
msg346423 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-06-24 17:59
New changeset 6ffd9b05dfade9e3a101fe039157856eb855f82e by Ned Deily (ziheng) in branch 'master':
bpo-32627: Fix compile error when conflicting `_uuid` headers included (GH-11751)
https://github.com/python/cpython/commit/6ffd9b05dfade9e3a101fe039157856eb855f82e
msg346426 - (view) Author: miss-islington (miss-islington) Date: 2019-06-24 18:18
New changeset 742b16edd692f58a06e0d55bedfffb77a112b205 by Miss Islington (bot) in branch '3.7':
bpo-32627: Fix compile error when conflicting `_uuid` headers included (GH-11751)
https://github.com/python/cpython/commit/742b16edd692f58a06e0d55bedfffb77a112b205
msg346428 - (view) Author: miss-islington (miss-islington) Date: 2019-06-24 18:28
New changeset 76b72f6ea26de4280279a01863f30fccd2dde8f3 by Miss Islington (bot) in branch '3.8':
bpo-32627: Fix compile error when conflicting `_uuid` headers included (GH-11751)
https://github.com/python/cpython/commit/76b72f6ea26de4280279a01863f30fccd2dde8f3
msg346430 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-06-24 18:32
Thanks, @adam, for the analysis and thanks, zihengCat, for the PR.
msg347164 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-07-02 22:34
New changeset e90815b3b16ab196c10f3a4dd91402cdc2e07d06 by Ned Deily (Miss Islington (bot)) in branch '3.7':
bpo-32627: Fix compile error when conflicting `_uuid` headers included (GH-11751)
https://github.com/python/cpython/commit/e90815b3b16ab196c10f3a4dd91402cdc2e07d06
History
Date User Action Args
2019-07-02 22:34:03ned.deilysetmessages: + msg347164
2019-06-24 18:32:24ned.deilysetstatus: open -> closed
versions: + Python 3.9
messages: + msg346430

keywords: patch, patch, patch, patch
resolution: fixed
stage: patch review -> resolved
2019-06-24 18:28:03miss-islingtonsetmessages: + msg346428
2019-06-24 18:18:27miss-islingtonsetnosy: + miss-islington
messages: + msg346426
2019-06-24 18:00:28miss-islingtonsetpull_requests: + pull_request14167
2019-06-24 18:00:22miss-islingtonsetpull_requests: + pull_request14166
2019-06-24 17:59:57ned.deilysetnosy: + ned.deily
messages: + msg346423
2019-06-24 17:57:39ned.deilylinkissue37384 superseder
2019-02-03 10:03:18python-devsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request11685
2019-02-03 10:03:06python-devsetkeywords: + patch
stage: needs patch -> needs patch
pull_requests: + pull_request11684
2019-02-03 10:02:56python-devsetkeywords: + patch
stage: needs patch -> needs patch
pull_requests: + pull_request11683
2019-02-03 10:02:45python-devsetkeywords: + patch
stage: needs patch -> needs patch
pull_requests: + pull_request11682
2018-07-20 15:56:38fthommensetnosy: + fthommen
2018-05-07 08:54:18adam@NetBSD.orgsetnosy: + adam@NetBSD.org
messages: + msg316255
2018-01-23 03:09:14ncoghlansetpriority: normal -> low

messages: + msg310465
2018-01-23 02:03:13ncoghlansetmessages: + msg310460
2018-01-23 01:54:03ncoghlancreate