Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

POSIX/GNU compliance macros fixes for uClibc support #2493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pcercuei
Copy link

Hi,

These two patches allow me to build wlroots with uClibc.

  • _XOPEN_SOURCE is required for strdup to become available. Since it defines _POSIX_C_SOURCE (see man feature_test_macros(7)), remove all inline defines of these two macros, and have meson provide only the former.
  • F_DUPFD_CLOEXEC seems to be a GNU-only thing, and will be provided by <fcntl.h> only when _GNU_SOURCE is defined on uClibc.

@emersion
Copy link
Member

emersion commented Nov 23, 2020

meson: define _XOPEN_SOURCE globally

Nack, we record what POSIX revision each source file needs, just like we record which header files it requires.

render/dmabuf: define _GNU_SOURCE for F_DUPFD_CLOEXEC

Nack, this is POSIX: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html

In general we only use POSIX functions, apart from where it's really not possible to do otherwise (e.g. session handling).

@pcercuei
Copy link
Author

Well, it needs _XOPEN_SOURCE defined everywhere strdup() is used, and _GNU_SOURCE for F_DUPFD_CLOEXEC (even though these are POSIX) to compile on uClibc.

@emersion
Copy link
Member

uClibc is wrong here. strdup is POSIX, and so is F_DUPFD_CLOEXEC, so only _POSIX_C_SOURCE should be required. Please report a uClibc bug.

@pcercuei
Copy link
Author

uClibc is wrong here, but so is glibc. strdup() conforms to POSIX.1-2001 (according to its man page), so half of your code base could probably use _POSIX_C_SOURCE=200112L, but doesn't just so that it compiles with a broken library (glibc only exports strdup when _POSIX_C_SOURCE=200809L).

I'll try to send a patch to uClibc without too much hope (they probably have reasons why this has been broken for 20 years) but that won't change the fact that wlroots cannot be compiled with the current uClibc-based toolchains.

@emersion
Copy link
Member

glibc only exports strdup when _POSIX_C_SOURCE=200809L

Then report the bug to glibc.

These source files use "struct timespec", which is POSIX 1993.09.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
@pcercuei
Copy link
Author

I forced-push to a new commit that adds some feature macros in order for struct timespec to be visible on uClibc. The commit is based on 0.12.0, I will need to try with the latest master too.

@emersion
Copy link
Member

emersion commented Nov 1, 2021

wlroots has migrated to gitlab.freedesktop.org. This pull request has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/2493

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants