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

build failure with musl libc due to struct shm_info.used_ids #1147

Closed
ncopa opened this issue Jul 16, 2015 · 3 comments
Closed

build failure with musl libc due to struct shm_info.used_ids #1147

ncopa opened this issue Jul 16, 2015 · 3 comments
Labels
build An issue with the build

Comments

@ncopa
Copy link
Contributor

ncopa commented Jul 16, 2015

With musl libc it fails to build with the error:

ipc.c:154:49: error: 'struct shm_info' has no member named 'used_ids'
   ipc_submit_g("shm", "segments", NULL, shm_info.used_ids);
                                                 ^

You need to define _GNU_SOURCE on musl libc for the member 'used_ids', probably due to it is not required in POSIX.

I have two different suggestions on how to fix it:

diff --git a/configure.ac b/configure.ac
index 6ee6e9a..a0e35b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,7 @@ AC_PROG_LEX
 AC_PROG_YACC
 PKG_PROG_PKG_CONFIG

+AC_GNU_SOURCE
 AC_CHECK_PROG([have_protoc_c], [protoc-c], [yes], [no])
 AC_CHECK_HEADERS([google/protobuf-c/protobuf-c.h],
                  [have_protobuf_c_h="yes"],

or:

diff --git a/src/ipc.c b/src/ipc.c
index 3763f24..b403847 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -32,6 +32,9 @@
 #include "configfile.h"

 #if KERNEL_LINUX
+  /* _GNU_SOURCE is needed for struct shm_info.used_ids on musl libc */
+# define _GNU_SOURCE
+
   /* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
   /* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */
   /* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */

I can prepare a signed-off patch that you can git am if you tell me which way you prefer.

@mfournier mfournier added the build An issue with the build label Aug 1, 2015
@rubenk
Copy link
Contributor

rubenk commented Aug 4, 2015

I can confirm that this fixes the build on musl.
Can you also #define _DEFAULT_SOURCE? Not sure about musl, but glibc is deprecating _GNU_SOURCE.

If you could send a pull request that would be great.

@ncopa
Copy link
Contributor Author

ncopa commented Aug 5, 2015

Not sure about musl, but glibc is deprecating _GNU_SOURCE.

Where did you get that from? I can not see anything in documentation that indicates that _GNU_SOURCE is deprecated.

Are you sure you don't mean _BSD_SOURCE?

I can #define _DEFAULT_SOURCE too if you want but I can not see why that would be needed on any system, so I don't know how to explain that in the commit message.

On musl the only effect it has is that it enables _BSD_SOURCE in addition:

#if defined(_DEFAULT_SOURCE) && !defined(_BSD_SOURCE)
#define _BSD_SOURCE 1
#endif

@rubenk
Copy link
Contributor

rubenk commented Aug 5, 2015

Ah yes you're right, I confused _GNU_SOURCE with _BSD_SOURCE.
If you define _BSD_SOURCE and not _DEFAULT_SOURCE, you'll get warnings with glibc (60124c7), but that doesn't apply here.

ncopa added a commit to ncopa/collectd that referenced this issue Aug 5, 2015
This fixes compile the compile error:

> ipc.c:154:49: error: 'struct shm_info' has no member named 'used_ids'
>    ipc_submit_g("shm", "segments", NULL, shm_info.used_ids);
>                                                   ^

Fixes collectd#1147
mfournier pushed a commit that referenced this issue Aug 5, 2015
This fixes compile the compile error:

> ipc.c:154:49: error: 'struct shm_info' has no member named 'used_ids'
>    ipc_submit_g("shm", "segments", NULL, shm_info.used_ids);
>                                                   ^

Fixes #1147
buildroot-auto-update pushed a commit to buildroot/buildroot that referenced this issue Nov 26, 2015
src/ipc.c uses shm_info.used_ids which musl only provides when
_GNU_SOURCE is defined.

The issue has been fixed upstream, but the fix is not in their
latest 5.5.0 release. Adding their patch as a temporary fix
to be removed on the next version bump.

collectd/collectd#1147
collectd/collectd@3e38483

Fixes
http://autobuild.buildroot.net/results/e981c08f01d2916246a17b1dc112e8b3e8c628e2/

Signed-off-by: Alex Suykov <alex.suykov@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build An issue with the build
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants