Bug 273736 - Find a better way to handle byteswap.h in libmagic
Summary: Find a better way to handle byteswap.h in libmagic
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Xin LI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-12 06:43 UTC by Xin LI
Modified: 2025-01-13 04:26 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xin LI freebsd_committer freebsd_triage 2023-09-12 06:43:36 UTC
In 90474518912f we are pretending that byteswap.h does not exist on FreeBSD.

Ideally we should be testing if __FreeBSD_version is greater than or equal to 1400079 (the bump after byteswap.h introduction) and derive the HAVE_BYTESWAP from that.
Comment 1 Xin LI freebsd_committer freebsd_triage 2025-01-06 17:18:26 UTC
Philip reports that builds are failing on an old 13.x based jail at cluster.

Potentially we could do something like:

```
#include <osreldate.h>

[...]

#ifndef __APPLE__
#if __FreeBSD_version >= 1400079 || (__FreeBSD_version < 1400000 && __FreeBSD_version >= 1302500)
#define HAVE_BYTESWAP_H 1
#endif
#endif
```
Comment 2 Warner Losh freebsd_committer freebsd_triage 2025-01-06 20:11:09 UTC
seems good to me. libmagic likely is kinda broken if this dance is needed, but it's maybe the best way forward.
Comment 3 Philip Paeps freebsd_committer freebsd_triage 2025-01-08 00:17:21 UTC
Cluster builds are working again.  I only had to put a newer base.txz in the correct place.  Thanks for the hint. :)

I believe we formally support building on any earlier revision of the same branch, so we should have a bridge like this.

Thank you!  This looks good to me.
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-01-08 04:43:19 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7f8f120439b77e60a1070d87f4dc6cb9a43d0335

commit 7f8f120439b77e60a1070d87f4dc6cb9a43d0335
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2025-01-08 04:42:16 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2025-01-08 04:42:16 +0000

    libmagic: Unbreak for older FreeBSD releases.

    byteswap.h is introduced in FreeBSD 13.2 but was not available in
    earlier versions.  In order to support upgrading from an earlier
    FreeBSD release we would need to tell the build system that fact.

    PR:             bin/273736
    Reported by:    philip
    MFC after:      3 days

 lib/libmagic/config.h | 5 +++++
 1 file changed, 5 insertions(+)
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-01-13 04:25:05 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e6de39be80e2283517f3c51d3d238d851435898e

commit e6de39be80e2283517f3c51d3d238d851435898e
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2025-01-08 04:42:16 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2025-01-13 04:24:19 +0000

    MFC: libmagic: Unbreak for older FreeBSD releases.

    PR:             bin/273736
    Reported by:    philip

    (cherry picked from commit 7f8f120439b77e60a1070d87f4dc6cb9a43d0335)

 lib/libmagic/config.h | 5 +++++
 1 file changed, 5 insertions(+)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-01-13 04:26:07 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=163951959866377ebf6d9af84a412dd22b1a8983

commit 163951959866377ebf6d9af84a412dd22b1a8983
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2025-01-13 04:25:29 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2025-01-13 04:25:29 +0000

    MFC: libmagic: Unbreak for older FreeBSD releases.

    PR:             bin/273736
    Reported by:    philip

    (cherry picked from commit 7f8f120439b77e60a1070d87f4dc6cb9a43d0335)

 lib/libmagic/config.h | 5 +++++
 1 file changed, 5 insertions(+)