Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable _LARGEFILE64_SOURCE when _GNU_SOURCE is defined #20123

Merged
merged 1 commit into from Aug 30, 2023

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Aug 24, 2023

When we updated to the latest version of musl it broke some codebases that were using LFS functions (e.g. stat64) and assuming those functions would be defined when _GNU_SOURCE is defined.

See bminor/musl@25e6fee

This change effectively reverts the above one by defining _LARGEFILE64_SOURCE whenever _GNU_SOURCE is defined.

This is what glibc does:

https://github.com/lattera/glibc/blob/895ef79e04a953cac1493863bcae29ad85657ee1/include/features.h#L206

@kleisauke
Copy link
Collaborator

According to https://musl.libc.org/releases.html this was done on purpose and codebases that depend on these legacy LFS64 glibc-ABI-compat symbols should be fixed instead:

On the API level, the legacy "LFS64" ("large file support") interfaces, which were provided by macros remapping them to their standard names (#define stat64 stat and similar) have been deprecated and are no longer provided under the _GNU_SOURCE feature profile, only under explicit _LARGEFILE64_SOURCE. The latter will also be removed in a future version. Builds broken by this change can be fixed short-term by adding -D_LARGEFILE64_SOURCE to CFLAGS, but should be fixed to use the standard interfaces.

However, I'm aware that Rust builds are currently broken due to this, I submitted a PR for this at rust-lang/libc#3308 last month. For the same reason, Alpine has not shipped this in the v3.18.x cycle, see commits:
https://git.alpinelinux.org/aports/commit/?id=5fb59dcff01ea8dacd86d08216636794ad08ddd1
https://git.alpinelinux.org/aports/commit/?id=cab9b787b39387f0b3d30d218b0739c3e21aefb8

@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 25, 2023

According to https://musl.libc.org/releases.html this was done on purpose and codebases that depend on these legacy LFS64 glibc-ABI-compat symbols should be fixed instead:

On the API level, the legacy "LFS64" ("large file support") interfaces, which were provided by macros remapping them to their standard names (#define stat64 stat and similar) have been deprecated and are no longer provided under the _GNU_SOURCE feature profile, only under explicit _LARGEFILE64_SOURCE. The latter will also be removed in a future version. Builds broken by this change can be fixed short-term by adding -D_LARGEFILE64_SOURCE to CFLAGS, but should be fixed to use the standard interfaces.

However, I'm aware that Rust builds are currently broken due to this, I submitted a PR for this at rust-lang/libc#3308 last month. For the same reason, Alpine has not shipped this in the v3.18.x cycle, see commits: https://git.alpinelinux.org/aports/commit/?id=5fb59dcff01ea8dacd86d08216636794ad08ddd1 https://git.alpinelinux.org/aports/commit/?id=cab9b787b39387f0b3d30d218b0739c3e21aefb8

I think going with that glibc does and being a little more friendly to legacy software is good course of action for emscripten in this case. Its fine for upstream musl to be more strict than us

@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 30, 2023

OK to land this?

@sbc100 sbc100 closed this Aug 30, 2023
@sbc100 sbc100 reopened this Aug 30, 2023
@sbc100 sbc100 requested a review from kripken August 30, 2023 00:05
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm to land quickly if this is blocking something.

When we updated to the latest version of musl it broke some codebases
that were using LFS functions (e.g. `stat64`) and assuming those
functions would be defined when `_GNU_SOURCE` is defined.

See bminor/musl@25e6fee

This change effectively reverts the above one by defining
_LARGEFILE64_SOURCE whenever _GNU_SOURCE is defined.

This is what glibc does:

https://github.com/lattera/glibc/blob/895ef79e04a953cac1493863bcae29ad85657ee1/include/features.h#L206
@sbc100 sbc100 force-pushed the largefilesupport_by_default branch from 22e7dcb to 8045c65 Compare August 30, 2023 00:27
@sbc100 sbc100 merged commit c47ab8d into main Aug 30, 2023
26 checks passed
@sbc100 sbc100 deleted the largefilesupport_by_default branch August 30, 2023 01:45
@dschuff
Copy link
Member

dschuff commented Aug 30, 2023

According to https://musl.libc.org/releases.html this was done on purpose and codebases that depend on these legacy LFS64 glibc-ABI-compat symbols should be fixed instead:

On the API level, the legacy "LFS64" ("large file support") interfaces, which were provided by macros remapping them to their standard names (#define stat64 stat and similar) have been deprecated and are no longer provided under the _GNU_SOURCE feature profile, only under explicit _LARGEFILE64_SOURCE. The latter will also be removed in a future version. Builds broken by this change can be fixed short-term by adding -D_LARGEFILE64_SOURCE to CFLAGS, but should be fixed to use the standard interfaces.

However, I'm aware that Rust builds are currently broken due to this, I submitted a PR for this at rust-lang/libc#3308 last month. For the same reason, Alpine has not shipped this in the v3.18.x cycle, see commits: https://git.alpinelinux.org/aports/commit/?id=5fb59dcff01ea8dacd86d08216636794ad08ddd1 https://git.alpinelinux.org/aports/commit/?id=cab9b787b39387f0b3d30d218b0739c3e21aefb8

I think going with that glibc does and being a little more friendly to legacy software is good course of action for emscripten in this case. Its fine for upstream musl to be more strict than us

Doing this in the short term seems fine to unblock users, but I'm not convinced this will work in the longer term. As mentioned, LARGEFILE_64_SOURCE is going away upstream in the next release, and I'm not sure we want to maintain downstream patches for this (especially not integrated into various headers the way these are, as that would be an invasive change to maintain). We should probably try to figure out whether we can keep this compatibility in a more easily-maintainable way, or maybe we can help our users fix their code.

@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 6, 2023

I think punting for now is fine. "The latter will also be removed in a future version" isn't necessarily the next release.. and musl releases a few and far between. I think we can pick the best option for dealing with that event once it happens.

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.

None yet

4 participants