[PATCH 5/5] mtd-utils: add GNU_SOURCE define to c files
Rosen Penev
rosenp at gmail.com
Fri Nov 28 12:50:32 PST 2025
On Fri, Nov 28, 2025 at 12:43 PM David Oberhollenzer
<david.oberhollenzer at sigma-star.at> wrote:
>
> Hi,
>
> your _GNU_SOURCE commit breaks the build (you removed limits.h
> from libmtd_legacy.c). Besides that, I'm reluctant to remove
> the global _GNU_SOURCE define, we might have a number of implicit
> users across the source and the extensions we use are generally
> useful.
Yeah this was not correct.
>
> While I think it's a valuable goal to be compatible with non-GNU
> libc implementations like Musl, or klibc. Libraries like Musl
> implement a good chunk anyway and for stuff that's really missing,
> we have a libmissing.a.
Some of these header removals are for compatibility with macOS, like
with features.h.
>
> Regarding the Linux header inclusions across the code, those
> parts (e.g. rb-tree) have probably been lifted directly from
> the Linux kernel tree. I don't think we should try to intentionally
> try to diverge from the upstream version.
It's a patch carried by OpenWrt to get compilation on macOS working.
I'll see what I can do about this.
>
> Also, what would we gain from portability here? Portability to
> non-Linux based, non-GNU, Unix-like systems? What use would those
> have for mtd-utils?
Some OpenWrt developers develop on macOS. That's about it.
>
>
> Anyway, I cherry-picked and applied the _POSIX_C_SOURCE patch to
> mtd-utils.git master.
Interestingly enough I found this issue while trying to remove
_GNU_SOURCE. Maybe there are some more.
>
> Thanks,
>
> David
>
More information about the linux-mtd
mailing list