Bug 373175 - _XOPEN_SOURCE needs to be defined when using -std=iso9899:1990
Summary: _XOPEN_SOURCE needs to be defined when using -std=iso9899:1990
Status: REOPENED
Alias: None
Product: extra-cmake-modules
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.38.0
Platform: Compiled Sources All
: NOR normal
Target Milestone: ---
Assignee: Alex Merry
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-02 07:49 UTC by A. Wilcox (awilfox)
Modified: 2023-01-22 23:47 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
KDECompilerSettings: Ensure POSIX correctness (1.20 KB, patch)
2016-12-02 07:49 UTC, A. Wilcox (awilfox)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description A. Wilcox (awilfox) 2016-12-02 07:49:07 UTC
Created attachment 102573 [details]
KDECompilerSettings: Ensure POSIX correctness

When building on non-glibc Unix platforms, such as Solaris, NetBSD, and Linux/musl or Linux/uclibc, multiple components of KF5 fail to build.  This is because -std=iso9899:1990 is specified (for strict C90 compliance) but _XOPEN_SOURCE is not defined, so none of the POSIX interfaces are exported.  I have seen this reported in at least:

* kscreenlocker
* plasma-workspace

The attached patch resolves this issue on all our build boxes; additionally, applying it to my glibc builder did not change the already working result.
Comment 1 A. Wilcox (awilfox) 2017-09-27 07:29:17 UTC
Just checked and this still applies cleanly to 5.38.0, and is still needed.
Comment 2 Christoph Feck 2017-10-10 23:29:25 UTC
Please submit patches via https://phabricator.kde.org/differential/diff/create/
Comment 3 Michael Pyne 2017-10-12 23:52:40 UTC
We have recently made changes to individual KF5 modules to allow them to build with musl (on Alpine).  So for KF5 at least this should no longer be necessary.  The patches were applied to each specific KF5 module rather than unconditionally requesting POSIX defines.

Have you tried this on FreeBSD?  That OS in particular gave us issues with those modifications, because FreeBSD will normally export symbols by default *except* for when you use one of those feature test macros; then it *disables everything* not in ISO C and then enables the features given by the macro you use.  For the KF5 modules that actually used symbols that were only in BSD, fixing the missing POSIX symbols had the effect of breaking the BSD symbols.
Comment 4 David Faure 2018-08-31 08:28:17 UTC
Git commit 6684cb99bdf408fc491e547393dbd7aac4d151f2 by David Faure, on behalf of A. Wilcox.
Committed on 31/08/2018 at 08:26.
Pushed by dfaure into branch 'master'.

Add _XOPEN_SOURCE to C definitions

When building on non-glibc Unix platforms, such as Solaris, NetBSD, and Linux/musl or Linux/uclibc, multiple components of KF5 fail to build. This is because -std=iso9899:1990 is specified (for strict C90 compliance) but _XOPEN_SOURCE is not defined, so none of the POSIX interfaces are exported. I have seen this reported in at least:

* kinit
* kscreenlocker
* plasma-workspace

The attached patch resolves this issue on all our build boxes; additionally, applying it to my glibc builder did not change the already working result.

Differential Revision: https://phabricator.kde.org/D8256

M  +3    -0    kde-modules/KDECompilerSettings.cmake

https://commits.kde.org/extra-cmake-modules/6684cb99bdf408fc491e547393dbd7aac4d151f2
Comment 5 David Faure 2018-09-02 20:08:42 UTC
Patch broke FreeBSD compilation, reverted.