Skip to content

This re-enables build on macOS.#3013

Merged
karelzak merged 1 commit intoutil-linux:masterfrom
gershnik:fix-2873
Apr 15, 2025
Merged

This re-enables build on macOS.#3013
karelzak merged 1 commit intoutil-linux:masterfrom
gershnik:fix-2873

Conversation

@gershnik
Copy link
Contributor

@gershnik gershnik commented May 6, 2024

Weak aliases are not supported by clang on Darwin. Instead this fix uses inline asm to make _uuid_time and alias to ___uuid_time

Fixes #2873

@chenrui333
Copy link

can we add a macos CI per this change?

@alyssais
Copy link
Contributor

alyssais commented Oct 9, 2024

@karelzak we've been holding off updating to util-linux 2.40 in Nixpkgs for a long time because of this issue. Could you please take a look?

@karelzak
Copy link
Collaborator

Looks good to me; @t-8ch, any comments?

@t-8ch
Copy link
Member

t-8ch commented Oct 14, 2024

The commit subject is really not great.

A comment why there is no problem time ABI problem on macOS.
I guess macOS has been 64-bit only for some time.

g2p added a commit to g2p/bcachefs-tools that referenced this pull request Oct 28, 2024
2.40.1 is still a soft requirement as format will refuse
to run without a flag.

nixpkgs requiring macOS compatibility of util-linux is a questionable
choice.

See:
- NixOS/nixpkgs#333467
- util-linux/util-linux#3013

Rationale for picking blkid 2.39.3:
https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.39/v2.39.3-ReleaseNotes
@iskarian
Copy link

iskarian commented Nov 6, 2024

It seems that the motivation for uuid_time64 is to enable use of 64-bit time on 32-bit platforms. On 64-bit platforms, uuid_time is 64-bit. I believe the check for glibc is because 64-bit time on 32-bit systems is supported by glibc (and maybe musl?) but not libc++.

I have no idea if Darwin supports it.

Sources:

The symbol uuid_time64 is conditionally defined. It only exists on
32-bit platforms that use the glibc library and enable support for
the 64-bit time_t type.

#3037

The pull that added uuid_time64:
#2610

@gershnik
Copy link
Contributor Author

@iskarian thank you for the background research!

@t-8ch
macOS supported 64-bit and aggressively pushed developers to build only for 64 bit since version 10.7, released in July 20111. It has been 64-bit only since version 10.15, released in October 2019. Which, however you look at it, is a very, very long time on that platform. Neither myself, nor anybody I know has access to an Apple toolchain that can build for 32-bit and hasn't for a very long time2.

From looking at system headers, as they exist now, I see the following in /usr/include/i386/_types.h:

#if defined (__i386__) || defined (__x86_64__)
...
typedef long                    __darwin_time_t;
...
#endif

where __darwin_time_t eventually becomes time_t and is also used directly in timeval. Which indicates that whole time API is 32 bit on 32 bit platforms and 64 bit on 64 bit ones. Which, in turn, seems to indicate that uuid_time64 shenanigans are unnecessary on that platform and uuid_time should unconditionally be an alias to __uuid_time there.

This is all conjectural, however, since, as I mentioned I don't have an ability to actually build and check what happens on 32-bit3.

To remind you, right now the situation is that libuuid doesn't build on macOS at all, 64-bit or 32, and it has been the case for many months.

I am going to add a short summary of the above to the commit message in the hope that this will finally get the fix merged and the issue resolved.

Footnotes

  1. https://en.wikipedia.org/wiki/MacOS_version_history

  2. Perhaps it is still possible via some compiler/linker switches but this is not something that is generally known or supported by Apple.

  3. I guess I could set it all up in a VM but I am nowhere near motivated enough for such an adventure

@t-8ch
Copy link
Member

t-8ch commented Nov 24, 2024

Please also change the commit subject to something matching the common style.

libuuid: fix uuid_time on macOS without attribute((alias)).

And also add some newlines to the commit message.

In general it would be great if somebody could contribute CI configurations for macOS (and Windows for that matter).
That way any breakage can be recognized before it hits a release or the master branch.

Weak aliases are not supported by clang on Darwin.
Instead this fix uses inline asm to make `_uuid_time` an alias to
`___uuid_time`

It appears that on macOS the time API is purely 32 or 64 bit depending
on the build type. There is no ABI issue on that platform and `uuid_time`
can be unconditionally aliased to `_uuid_time`. This is all conjectural,
however, since I have no ability to make 32-bit builds for macOS - the
Apple toolchain doesn't support this since 2019.

Fixes util-linux#2873
@gershnik
Copy link
Contributor Author

@t-8ch Commit message amended as requested.

@gershnik
Copy link
Contributor Author

@karelzak not sure what the process is in this project, so can this be merged now or there is something else that needs to be done?

Thank you!

g2p added a commit to g2p/bcachefs-tools that referenced this pull request Mar 17, 2025
2.40.1 is still a soft requirement as format will refuse
to run without a flag.

nixpkgs requiring macOS compatibility of util-linux is a questionable
choice.

See:
- NixOS/nixpkgs#333467
- util-linux/util-linux#3013

Rationale for picking blkid 2.39.3:
https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.39/v2.39.3-ReleaseNotes
g2p added a commit to g2p/bcachefs-tools that referenced this pull request Mar 17, 2025
2.40.1 is still a soft requirement as format will refuse
to run without a flag.

nixpkgs requiring macOS compatibility of util-linux is a questionable
choice.

See:
- NixOS/nixpkgs#333467
- util-linux/util-linux#3013

Rationale for picking blkid 2.39.3:
https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.39/v2.39.3-ReleaseNotes

Signed-off-by: Gabriel de Perthuis <[email protected]>
@t-8ch
Copy link
Member

t-8ch commented Apr 15, 2025

@karelzak This should be ready.

@karelzak karelzak merged commit bbfbd64 into util-linux:master Apr 15, 2025
@karelzak
Copy link
Collaborator

Ah, I forgot this for release v2.41. Sorry.

@chenrui333
Copy link

@karelzak I think this did not make to 2.41.2 release?

@karelzak
Copy link
Collaborator

The commit f59b47d is within stable/v2.41 branch and should be released in v2.41.2.

@karelzak
Copy link
Collaborator

Note that if you want something included in the next stable release, it's fine to create a pull request against the relevant stable/vX.Y branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2.40 build failure

6 participants