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

lib: newlib: Define _ANSI_SOURCE #52740

Merged
merged 1 commit into from
Dec 5, 2022

Conversation

stephanosio
Copy link
Member

@stephanosio stephanosio commented Dec 2, 2022

This commit updates the Newlib integration to define _ANSI_SOURCE
in order to prevent Newlib from defining POSIX primitives in its
headers when GNU dialect is used (-std=gnu*).

Newlib features.h defines _DEFAULT_SOURCE when __STRICT_ANSI__
is not defined by GCC (i.e. when -std=gnu*), which results in the
Newlib headers defining POSIX primitives that are in conflict with the
POSIX primitives defined by Zephyr.

Newlib must not define POSIX primitives unless the feature test macros
such as _POSIX_SOURCE, _GNU_SOURCE and _DEFAULT_SOURCE are
explicitly defined.

Note that -std=gnu does not imply _GNU_SOURCE or _DEFAULT_SOURCE
because it is only supposed to instruct the compiler to use the GNU C
language dialect (i.e. GNU C language extensions).

Refer to the GitHub issue #52739 for more details.


Fixes #52739

This commit updates the Newlib integration to define `_ANSI_SOURCE`
in order to prevent Newlib from defining POSIX primitives in its
headers when GNU dialect is used (`-std=gnu*`).

Newlib `features.h` defines `_DEFAULT_SOURCE` when `__STRICT_ANSI__`
is not defined by GCC (i.e. when `-std=gnu*`), which results in the
Newlib headers defining POSIX primitives that are in conflict with the
POSIX primitives defined by Zephyr.

Newlib must not define POSIX primitives unless the feature test macros
such as `_POSIX_SOURCE`, `_GNU_SOURCE` and `_DEFAULT_SOURCE` are
explicitly defined.

Note that `-std=gnu` does not imply `_GNU_SOURCE` or `_DEFAULT_SOURCE`
because it is only supposed to instruct the compiler to use the GNU C
language dialect (i.e. GNU C language extensions).

Refer to the GitHub issue zephyrproject-rtos#52739 for more details.

Signed-off-by: Stephanos Ioannidis <[email protected]>
@stephanosio stephanosio marked this pull request as ready for review December 2, 2022 09:23
@stephanosio stephanosio requested a review from nashif as a code owner December 2, 2022 09:23
@zephyrbot zephyrbot added the area: C Library C Standard Library label Dec 2, 2022
stephanosio added a commit to stephanosio/nrfconnect-sdk-zephyr that referenced this pull request Dec 2, 2022
This commit updates the Newlib integration to define `_ANSI_SOURCE`
in order to prevent Newlib from defining POSIX primitives in its
headers when GNU dialect is used (`-std=gnu*`).

Newlib `features.h` defines `_DEFAULT_SOURCE` when `__STRICT_ANSI__`
is not defined by GCC (i.e. when `-std=gnu*`), which results in the
Newlib headers defining POSIX primitives that are in conflict with the
POSIX primitives defined by Zephyr.

Newlib must not define POSIX primitives unless the feature test macros
such as `_POSIX_SOURCE`, `_GNU_SOURCE` and `_DEFAULT_SOURCE` are
explicitly defined.

Note that `-std=gnu` does not imply `_GNU_SOURCE` or `_DEFAULT_SOURCE`
because it is only supposed to instruct the compiler to use the GNU C
language dialect (i.e. GNU C language extensions).

Refer to the GitHub issue #52739 for more details.

Upstream PR: zephyrproject-rtos/zephyr#52740

Signed-off-by: Stephanos Ioannidis <[email protected]>
stephanosio added a commit to nrfconnect/sdk-zephyr that referenced this pull request Dec 2, 2022
This commit updates the Newlib integration to define `_ANSI_SOURCE`
in order to prevent Newlib from defining POSIX primitives in its
headers when GNU dialect is used (`-std=gnu*`).

Newlib `features.h` defines `_DEFAULT_SOURCE` when `__STRICT_ANSI__`
is not defined by GCC (i.e. when `-std=gnu*`), which results in the
Newlib headers defining POSIX primitives that are in conflict with the
POSIX primitives defined by Zephyr.

Newlib must not define POSIX primitives unless the feature test macros
such as `_POSIX_SOURCE`, `_GNU_SOURCE` and `_DEFAULT_SOURCE` are
explicitly defined.

Note that `-std=gnu` does not imply `_GNU_SOURCE` or `_DEFAULT_SOURCE`
because it is only supposed to instruct the compiler to use the GNU C
language dialect (i.e. GNU C language extensions).

Refer to the GitHub issue #52739 for more details.

Upstream PR: zephyrproject-rtos/zephyr#52740

Signed-off-by: Stephanos Ioannidis <[email protected]>
@carlescufi carlescufi merged commit 82a902e into zephyrproject-rtos:main Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: C Library C Standard Library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Newlib defines POSIX primitives when -std=gnu
4 participants