Bug 2247016 - opae fails to build with Python 3.13: Missing <unistd.h> declaration
Summary: opae fails to build with Python 3.13: Missing <unistd.h> declaration
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: opae
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Peter Colberg
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2023-10-30 12:01 UTC by Karolina Surma
Modified: 2024-03-04 21:51 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-02-26 23:20:49 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2023-10-30 12:01:36 UTC
opae fails to build with Python 3.13.0a1.

main.h:158:18: error: ‘pread’ was not declared in this scope; did you mean ‘fread’?
  158 |     bytes = pread(v_->device.device_fd,
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
  159 |                   &value,
      |                   ~~~~~~~
  160 |                   sizeof(T),
      |                   ~~~~~~~~~~
  161 |                   v_->device.device_config_offset + offset);
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.h: In instantiation of ‘void vfio_device::config_write(uint64_t, T) [with T = unsigned int; uint64_t = long unsigned int]’:
vfiobindings.cpp:50:15:   required from here
main.h:170:19: error: ‘pwrite’ was not declared in this scope; did you mean ‘fwrite’?
  170 |     bytes = pwrite(v_->device.device_fd,
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
  171 |                    &value,
      |                    ~~~~~~~
  172 |                    sizeof(T),
      |                    ~~~~~~~~~~
  173 |                    v_->device.device_config_offset + offset);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

According to https://docs.python.org/3.13/whatsnew/3.13.html:

Python.h no longer includes the <unistd.h> standard header file.
If needed, it should now be included explicitly.
For example, it provides the functions: read(), write(), close(), isatty(), lseek(), getpid(), getcwd(), sysconf() and getpagesize().
As a consequence, _POSIX_SEMAPHORES and _POSIX_THREADS macros are no longer defined by Python.h.
The HAVE_UNISTD_H and HAVE_PTHREAD_H macros defined by Python.h can be used to decide if <unistd.h> and <pthread.h> header files can be included.
(Contributed by Victor Stinner in gh-108765.)


https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06578874-opae/

For all our attempts to build opae with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/opae/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Aoife Moloney 2024-02-15 23:02:45 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle.
Changing version to 40.

Comment 2 Peter Colberg 2024-02-26 23:15:28 UTC
I am unable to reproduce the build failure against Python 3.13; neither using the latest committed version in rawhide, commit b08d098 ("Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild"), nor using commit 3fa6257 ("Update to OPAE SDK 2.12.0-4") from https://src.fedoraproject.org/rpms/opae/pull-request/8. Since nothing changed in opae between commit 6642045 ("Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild") and commit b08d098, has Python 3.13 been updated to resolve the issue?

> cat ~/.config/mock/fedora-rawhide-python313.cfg 
include('/etc/mock/fedora-rawhide-x86_64.cfg')

config_opts['root'] = 'fedora-rawhide-python313'

config_opts[f'{config_opts.package_manager}.conf'] += """

[python313]
name=Copr repo for python3.13 owned by @python
baseurl=https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-$basearch/
type=rpm-md
skip_if_unavailable=False
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
priority=9
"""

> mock -r fedora-rawhide-python313 --enablerepo=local rpmbuild/SRPMS/opae-2.2.0-1.1.fc39.8.src.rpm 

Wrote: /builddir/build/RPMS/opae-devel-2.2.0-1.1.fc41.8.x86_64.rpm
Wrote: /builddir/build/RPMS/opae-2.2.0-1.1.fc41.8.x86_64.rpm
Wrote: /builddir/build/RPMS/opae-debugsource-2.2.0-1.1.fc41.8.x86_64.rpm
Wrote: /builddir/build/RPMS/opae-extra-tools-2.2.0-1.1.fc41.8.x86_64.rpm
Wrote: /builddir/build/RPMS/opae-debuginfo-2.2.0-1.1.fc41.8.x86_64.rpm
Wrote: /builddir/build/RPMS/opae-devel-debuginfo-2.2.0-1.1.fc41.8.x86_64.rpm
Wrote: /builddir/build/RPMS/opae-extra-tools-debuginfo-2.2.0-1.1.fc41.8.x86_64.rpm
Finish: rpmbuild opae-2.2.0-1.1.fc39.8.src.rpm
Finish: build phase for opae-2.2.0-1.1.fc39.8.src.rpm
INFO: Done(rpmbuild/SRPMS/opae-2.2.0-1.1.fc39.8.src.rpm) Config(fedora-rawhide-python313) 3 minutes 29 seconds
INFO: Results and/or logs in: /var/lib/mock/fedora-rawhide-python313/result
Finish: run

Comment 3 Miro Hrončok 2024-02-26 23:20:49 UTC
The *Python.h no longer includes the <unistd.h> standard header file* change was reverted in Python 3.13.

Note that the code should still include it when it uses pwrite() and should not assume Python includes it.

Comment 4 Peter Colberg 2024-02-26 23:22:10 UTC
According to https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/opae/, the first successful build of opae against python3.13 was https://copr.fedorainfracloud.org/coprs/g/python/python3.13/build/6687691/ on 2023-11-24.

The latest successful build was https://copr.fedorainfracloud.org/coprs/g/python/python3.13/build/7062707/ on 2024-02-26, which was triggered by https://src.fedoraproject.org/rpms/opae/pull-request/8.

Comment 5 Peter Colberg 2024-02-26 23:27:25 UTC
Thanks @mhroncok, I will submit the corresponding change upstream.

Comment 6 Peter Colberg 2024-03-04 21:51:47 UTC
Submitted upstream as https://github.com/OFS/opae-sdk/pull/3112


Note You need to log in before you can comment on or make changes to this bug.