-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
POSIX sysconf breaks builds for many STM32 targets #74623
Labels
area: POSIX
POSIX API Library
bug
The issue is a bug, or the PR is fixing a bug
platform: STM32
ST Micro STM32
Comments
besmarsh
added a commit
to besmarsh/zephyr
that referenced
this issue
Jun 20, 2024
The POSIX sysconf() option _SC_PAGESIZE was defined as PAGESIZE, which was defined as PAGE_SIZE (coming from CONFIG_POSIX_PAGE_SIZE) IF not already defined. The STM32 HAL defines PAGESIZE for flash pages as FLASH_PAGE_SIZE, which is only defined in the HAL for some STM32 families. This caused build failures for many STM32 targets. See issue zephyrproject-rtos#74623 for full description. In addition, the POSIX sysconf() options _SC_PAGE_SIZE and _SC_PAGESIZE should be synonymous, but the existing definition could result in them differing when PAGESIZE is already defined elsewhere. This commit removes the conditional definition of PAGESIZE and uses PAGE_SIZE (set from CONFIG_POSIX_PAGE_SIZE) for both _SC_PAGE_SIZE and _SC_PAGESIZE. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
@erwango - I think we can close this. The other pr is less of a bug fix and more of a stability improvement, I would say. |
besmarsh
added a commit
to besmarsh/zephyr
that referenced
this issue
Jun 25, 2024
The POSIX macros ATEXIT_MAX, PAGE_SIZE, and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. This commit defines ATEXIT_MAX, PAGE_SIZE, and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
besmarsh
added a commit
to besmarsh/zephyr
that referenced
this issue
Jul 8, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE, and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
besmarsh
added a commit
to besmarsh/zephyr
that referenced
this issue
Jul 8, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
aescolar
pushed a commit
that referenced
this issue
Jul 10, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See #74623 and #74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
AlienSarlak
pushed a commit
to AlienSarlak/zephyr
that referenced
this issue
Jul 13, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
CZKikin
pushed a commit
to nxp-upstream/zephyr
that referenced
this issue
Jul 18, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
Devansh0210
pushed a commit
to Devansh0210/zephyr
that referenced
this issue
Jul 20, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
Thalley
pushed a commit
to Thalley/zephyr
that referenced
this issue
Aug 1, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE and PAGESIZE unconditionally. Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
Chenhongren
pushed a commit
to Chenhongren/zephyr
that referenced
this issue
Aug 26, 2024
The POSIX macros PAGE_SIZE and PAGESIZE (queriable through sysconf()) were conditionally defined only if an existing definition did not already exist. These should be defined unconditionally in their header to ensure they get the correct values. If these macros are defined elsewhere with a different meaning, that's a problem. There was an issue where PAGESIZE was already defined with a different meaning. See zephyrproject-rtos#74623 and zephyrproject-rtos#74428. The POSIX macro ATEXIT_MAX is also conditionally defined and should be unconditionally defined, but there is currently a definition in picolibc (picolibc/newlib/libc/include/stdlib.h) so this change will be done separately. This commit defines PAGE_SIZE and PAGESIZE unconditionally. (cherry picked from commit 8c0d3de) Original-Signed-off-by: Ben Marsh <ben.marsh@helvar.com> GitOrigin-RevId: 8c0d3de Change-Id: Icb9ff7549525906d976333b9327e3b7dd42975b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5692888 Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com> Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: POSIX
POSIX API Library
bug
The issue is a bug, or the PR is fixing a bug
platform: STM32
ST Micro STM32
Describe the bug
Zephyr v3.6 added a compile-time
sysconf()
implementation to the POSIX API, enabled with the Kconfig optionCONFIG_POSIX_SYSCONF
. One of the options that can be queried isPAGESIZE
/PAGE_SIZE
(_SC_PAGESIZE
/_SC_PAGE_SIZE
). EnablingCONFIG_POSIX_SYSCONF
and callingsysconf(_SC_PAGESIZE)
fails to compile for many STM32 targets. This is obviously an issue for applications wishing to callsysconf(_SC_PAGESIZE)
on an affected target.Zephyr v3.7 added a runtime
sysconf()
implementation, deprecatedCONFIG_POSIX_SYSCONF
, and addedCONFIG_POSIX_SYSCONF_IMPL_MACRO
andCONFIG_POSIX_SYSCONF_IMPL_FULL
to select between the compile-time and runtimesysconf()
implementations. WhenCONFIG_POSIX_SYSCONF_IMPL_MACRO=y
, the behaviour is the same as in v3.6. WhenCONFIG_POSIX_SYSCONF_IMPL_FULL=y
, the problem is worse as applications will fail to compile even if they don't callsysconf()
at all. Even worse,CONFIG_POSIX_SYSCONF_IMPL_FULL
is the default whenCONFIG_POSIX_API=y
andCONFIG_CPP=y
, meaning that even applications not using sysconf at all will fail to compile if they enable the POSIX API (now needed for POSIX net socket names after the deprecation ofCONFIG_NET_SOCKETS_POSIX_NAMES
) and C++ support.The bug is caused by:
__z_posix_sysconf*
macros (defined inunistd.h
in v3.6, andsysconf.h
in v3.7)__z_posix_sysconf_SC_PAGE_SIZE
is defined asPAGE_SIZE
, which comes fromCONFIG_POSIX_PAGE_SIZE_BITS
in v3.6 andCONFIG_POSIX_PAGE_SIZE
in v3.7__z_posix_sysconf_SC_PAGESIZE
is defined asPAGESIZE
, which is defined asPAGE_SIZE
(as above), IFPAGESIZE
is not already definedPAGESIZE
is defined in the STM32 HAL filestm32_hal_legacy.h
, which eventually gets included fromunistd.h
, asFLASH_PAGE_SIZE
FLASH_PAGE_SIZE
is defined in the STM32 HAL filestm32**xx_hal_flash.h
for some but not all STM32 familiesApplications targeting STM32 families that have
FLASH_PAGE_SIZE
defined in theirstm32**xx_hal_flash.h
will compile, whereas applications targeting STM32 families withoutFLASH_PAGE_SIZE
defined will not.This raises another issue - for those STM32 families with
FLASH_PAGE_SIZE
defined where applications usingsysconf()
do compile, the results ofsysconf(_SC_PAGESIZE)
andsysconf(_SC_PAGE_SIZE)
may be different, despite the documentation forsysconf
describingPAGE_SIZE
/_SC_PAGE_SIZE
as "a synonym forPAGESIZE
/_SC_PAGESIZE
.Please also mention any information which could help others to understand
the problem you're facing:
specific commit?
sysconf()
was not implementedsysconf()
sysconf()
, and applications not usingsysconf()
but using POSIX API and C++To Reproduce
Steps to reproduce the behavior:
cd zephyrproject
cmake -b stm32h735g_disco -d build_sysconf_bug zephyr/samples/hello_world -- -DCONFIG_POSIX_API=y -DCONFIG_CPP=y
Expected behavior
A clear and concise description of what you expected to happen.
sysconf
should compilesysconf
should compilesysconf(_SC_PAGESIZE)
andsysconf(_SC_PAGE_SIZE)
should yield the same resultImpact
What impact does this issue have on your progress (e.g., annoyance, showstopper)
For affected targets:
CONFIG_POSIX_SYSCONF_IMPL_MACRO=y
to avoid the issue, but it takes some investigation to discover this workaround_SC_PAGE_SIZE
rather than_SC_PAGESIZE
Logs and console output
Environment (please complete the following information):
main
at time of investigation (7f0f0a4
)The text was updated successfully, but these errors were encountered: