Skip to content

mbedtls: redefinition of DIV_ROUND_UP with CONFIG_POSIX_API=y #78906

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

Closed
JordanYates opened this issue Sep 24, 2024 · 3 comments
Closed

mbedtls: redefinition of DIV_ROUND_UP with CONFIG_POSIX_API=y #78906

JordanYates opened this issue Sep 24, 2024 · 3 comments
Assignees
Labels
area: mbedTLS / PSA Crypto bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale

Comments

@JordanYates
Copy link
Collaborator

Describe the bug

Enabling the following configuration options with ECP curve448 results in build warnings:

  • CONFIG_MBEDTLS_HAVE_TIME_DATE=y
  • CONFIG_POSIX_API=y

This is particularly an issue with WIFI_NM_WPA_SUPPLICANT, which force enables the posix API:

config WIFI_NM_WPA_SUPPLICANT
bool "WPA Suplicant from hostap project [EXPERIMENTAL]"
select POSIX_TIMERS
select POSIX_SIGNALS
select POSIX_API

To Reproduce

west build -p -b nrf52840dk/nrf52840 zephyr/tests/benchmarks/mbedtls/ -- -DCONFIG_MBEDTLS_HAVE_TIME_DATE=y -DCONFIG_POSIX_API=y

Expected behavior

No build warnings

Logs and console output

[3/277] Generating include/generated/zephyr/version.h
-- Zephyr version: 3.7.99 (/home/jordan/code/zephyr/zephyr), build: v3.7.0-3338-g810f978bed4f
[166/277] Building C object modules/mbedtls/CMakeFiles/mbedT.../code/zephyr/modules/crypto/mbedtls/library/ecp_curves.c.obj
/home/jordan/code/zephyr/modules/crypto/mbedtls/library/ecp_curves.c:5231: warning: "DIV_ROUND_UP" redefined
 5231 | #define DIV_ROUND_UP(X, Y) (((X) + (Y) -1) / (Y))
      |
In file included from /home/jordan/code/zephyr/zephyr/include/zephyr/sys/atomic.h:18,
                 from /home/jordan/code/zephyr/zephyr/include/zephyr/kernel_includes.h:25,
                 from /home/jordan/code/zephyr/zephyr/include/zephyr/kernel.h:17,
                 from /home/jordan/code/zephyr/zephyr/include/zephyr/posix/time.h:59,
                 from /home/jordan/code/zephyr/modules/crypto/mbedtls/include/mbedtls/platform_time.h:26,
                 from /home/jordan/code/zephyr/modules/crypto/mbedtls/include/mbedtls/platform_util.h:18,
                 from /home/jordan/code/zephyr/modules/crypto/mbedtls/include/mbedtls/ecp.h:27,
                 from /home/jordan/code/zephyr/modules/crypto/mbedtls/library/ecp_curves.c:14:
/home/jordan/code/zephyr/zephyr/include/zephyr/sys/util.h:359: note: this is the location of the previous definition
  359 | #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
      |
[277/277] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:      154076 B         1 MB     14.69%
             RAM:       92672 B       256 KB     35.35%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /home/jordan/code/zephyr/build/zephyr/zephyr.elf for board: nrf52840dk
@JordanYates JordanYates added bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug area: mbedTLS / PSA Crypto labels Sep 24, 2024
@ceolin
Copy link
Member

ceolin commented Oct 3, 2024

Yep, that is a major / generic problem, without proper namespaces our macros can collide with other projects.
And it is hard to know the inclusion order to conditionally define, not to mention that these macros can have different behavior.

@JordanYates
Copy link
Collaborator Author

Yep, that is a major / generic problem, without proper namespaces our macros can collide with other projects. And it is hard to know the inclusion order to conditionally define, not to mention that these macros can have different behavior.

I think this is more an issue with the MbedTLS unconditionally defining a common macro name in the .c file. I can't see anything we can do in the Zephyr headers to prevent this apart from namespacing.

Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Dec 29, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: mbedTLS / PSA Crypto bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale
Projects
None yet
Development

No branches or pull requests

3 participants