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

2.14.1: Compilation issue on NetBSD #2310

Closed
0-wiz-0 opened this issue Dec 21, 2018 · 4 comments · Fixed by #3422
Closed

2.14.1: Compilation issue on NetBSD #2310

0-wiz-0 opened this issue Dec 21, 2018 · 4 comments · Fixed by #3422
Labels
bug component-platform Portability layer and build scripts

Comments

@0-wiz-0
Copy link

0-wiz-0 commented Dec 21, 2018

When compiling on NetBSD (8.99.27/amd64) the build stops because sockaddr_storage is not defined.

The problem is that in library/net_sockets.c, the symbol _POSIX_C_SOURCE is defined to 200112L. In contrast to Linux, NetBSD removes symbols from the namespace when particular namespaces are requested.

(I think this might also be a problem on Solaris because it also likes to removes symbols.)
Workaround:

--- library/net_sockets.c.orig  2018-12-02 13:20:52.000000000 +0000
+++ library/net_sockets.c
@@ -22,7 +22,7 @@
 /* Enable definition of getaddrinfo() even when compiling with -std=c99. Must
  * be set before config.h, which pulls in glibc's features.h indirectly.
  * Harmless on other platforms. */
-#define _POSIX_C_SOURCE 200112L
+//#define _POSIX_C_SOURCE 200112L
 
 #if !defined(MBEDTLS_CONFIG_FILE)
 #include "mbedtls/config.h"

Please note the comment is incorrect ;)

@hanno-becker hanno-becker added bug component-platform Portability layer and build scripts tracking labels Dec 21, 2018
@ciarmcom
Copy link

ARM Internal Ref: IOTSSL-2677

@gilles-peskine-arm
Copy link
Contributor

struct sockaddr_storage is in SUSv3 with no note that it's an extension to POSIX.1-2001, so #define _POSIX_C_SOURCE 200112L should bring it in. What does it take to get struct sockaddr_storage on NetBSD?

@gilles-peskine-arm
Copy link
Contributor

We don't have NetBSD on our CI. A patch would be welcome, but of course it mustn't break other platforms. Commenting out #define _POSIX_C_SOURCE 200112L breaks glibc according to this comment so that's out. Note that Mbed TLS runs on many platforms that only implement a subset of POSIX, so sometimes strict conformance to POSIX isn't enough.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Jun 11, 2020

AFAIK, both Solaris and NetBSD hide symbols when particular requirements are defined using e.g. _POSIX_C_SOURCE.
The simple solutions IMO are:
1.

#ifndef __NetBSD__
#define _POSIX_C_SOURCE 200112L
#endif

or
2. (in my eyes preferred) just define the symbol on the platform(s) that need it. I don't know the defines for that, sorry.

alarixnia added a commit to alarixnia/mbedtls that referenced this issue Jun 11, 2020
@alarixnia alarixnia mentioned this issue Jun 11, 2020
2 tasks
alarixnia added a commit to alarixnia/mbedtls that referenced this issue Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-platform Portability layer and build scripts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants