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

musl compat #314

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

musl compat #314

wants to merge 4 commits into from

Conversation

matttbe
Copy link
Member

@matttbe matttbe commented Nov 20, 2024

Here are a few small patches needed to be able to compile mptcpd with musl, e.g. on AlpineLinux

Some libc like musl don't support them.

Let's simply define them if they are not defined.

From GNU C Library, bits/byteswap.h, under LGPL.

Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
Some libc like musl don't support it.

It is easy enough to define a simple version for our need.

Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
The current version taking an unlimited number of args, and with
multiple levels of helpers doesn't seem to be supported on some embedded
environments, e.g. Alpine Linux:

  configuration.c: In function 'mptcpd_config_create':
  configuration.c:54:47: error: pasting "l_log_set_" and "(" does not give a valid preprocessing token
     54 | #define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER)
        |                                               ^~~~~~~~~~
  configuration.c:42:36: note: in definition of macro 'MPTCPD_CONCAT_IMPL'
     42 | #define MPTCPD_CONCAT_IMPL(x, ...) x ## __VA_ARGS__
        |                                    ^
  configuration.c:54:33: note: in expansion of macro 'MPTCPD_CONCAT'
     54 | #define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER)
        |                                 ^~~~~~~~~~~~~
  configuration.c:802:9: note: in expansion of macro 'MPTCPD_SET_LOG_FUNCTION'
    802 |         MPTCPD_SET_LOG_FUNCTION();  // For early logging.
        |         ^~~~~~~~~~~~~~~~~~~~~~~
  configuration.c:54:47: error: implicit declaration of function 'l_log_set_'; did you mean 'l_log_set_null'? [-Werror=implicit-function-declaration]
     54 | #define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER)
        |                                               ^~~~~~~~~~
  configuration.c:42:36: note: in definition of macro 'MPTCPD_CONCAT_IMPL'
     42 | #define MPTCPD_CONCAT_IMPL(x, ...) x ## __VA_ARGS__
        |                                    ^
  configuration.c:54:33: note: in expansion of macro 'MPTCPD_CONCAT'
     54 | #define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER)
        |                                 ^~~~~~~~~~~~~
  configuration.c:802:9: note: in expansion of macro 'MPTCPD_SET_LOG_FUNCTION'
    802 |         MPTCPD_SET_LOG_FUNCTION();  // For early logging.
        |         ^~~~~~~~~~~~~~~~~~~~~~~
  configuration.c:54:47: error: called object is not a function or function pointer
     54 | #define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER)
        |                                               ^~~~~~~~~~
  configuration.c:42:36: note: in definition of macro 'MPTCPD_CONCAT_IMPL'
     42 | #define MPTCPD_CONCAT_IMPL(x, ...) x ## __VA_ARGS__
        |                                    ^
  configuration.c:54:33: note: in expansion of macro 'MPTCPD_CONCAT'
     54 | #define MPTCPD_SET_LOG_FUNCTION MPTCPD_CONCAT(l_log_set_, MPTCPD_LOGGER)
        |                                 ^~~~~~~~~~~~~
  configuration.c:802:9: note: in expansion of macro 'MPTCPD_SET_LOG_FUNCTION'
    802 |         MPTCPD_SET_LOG_FUNCTION();  // For early logging.
        |         ^~~~~~~~~~~~~~~~~~~~~~~

It is not clear to me why it is failing, and simplifying the
concatenation to two items, plus modifying the main helper to take the
prefix in argument don't seem to help . A simple workaround is to have a
special case for the default value, and do the concatenation only with
the other cases.

Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
Busybox's stat doesn't understand the long options:

  stat: unrecognized option: dereference

But it does support '-L'.

Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11936299435

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 64.075%

Totals Coverage Status
Change from base Build 11930597849: 0.0%
Covered Lines: 1409
Relevant Lines: 2199

💛 - Coveralls

@@ -26,6 +26,16 @@
*/
///@{
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* These 2 helpers come from GNU C Library, under LGPL */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a macro, I guess it is fine to copy it.

If not, we only use it in one place, with one address in lib, and multiple ones in the tests.

Maybe that's enough to hardcode the address in lib. The tests need further modifications to support musl I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants