Brendan Heading
2015-07-28 23:31:56 UTC
Hi guys,
There's a minor compilation issue when building bdwgc against musl. The
problem is observed on version 7.4.2. The compilation error is as follows :
=================
In file included from os_dep.c:44:0:
/home/peko/autobuild/instance-2/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/asm/sigcontext.h:9:8:
error: redefinition of 'struct sigcontext'
struct sigcontext {
^
In file included from
/home/peko/autobuild/instance-2/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/signal.h:243:0,
from ./include/private/../gc_pthread_redirects.h:42,
from ./include/private/../gc.h:1443,
from ./include/private/gc_priv.h:46,
from os_dep.c:17:
/home/peko/autobuild/instance-2/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/bits/signal.h:11:16:
note: originally defined here
typedef struct sigcontext
=================
The root cause is in the following excerpt from os_dep.c
=================
# if 2 <= __GLIBC__
# if 2 == __GLIBC__ && 0 == __GLIBC_MINOR__
/* glibc 2.1 no longer has sigcontext.h. But signal.h */
/* has the right declaration for glibc 2.1. */
# include <sigcontext.h>
# endif /* 0 == __GLIBC_MINOR__ */
# else /* __GLIBC__ < 2 */
/* libc5 doesn't have <sigcontext.h>: go directly with the kernel */
/* one. Check LINUX_VERSION_CODE to see which we should reference. */
# include <asm/sigcontext.h>
# endif /* __GLIBC__ < 2 */
=================
The logic here is intended to provide two special cases; one for
__GLIBC__ version 2.0, the other is a fall through case intended to be
reached if __GLIBC__ version is <2. However this fall through is also
reached if __GLIBC__ is undefined as is the case in musl. If the
__GLIBC__ version is 2.1 or greater no special action is taken.
musl, as a matter of policy, will never provide a macro to detect its
presence. Instead I propose that the above logic be wrapped in an
#ifdef __GLIBC__. I've tested that this allows the build to work on
musl, and should also work on uclibc and other C libraries.
I've attached a patch - I'm more than happy to update it if you feel
there is a better approach.
regards
Brendan
There's a minor compilation issue when building bdwgc against musl. The
problem is observed on version 7.4.2. The compilation error is as follows :
=================
In file included from os_dep.c:44:0:
/home/peko/autobuild/instance-2/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/asm/sigcontext.h:9:8:
error: redefinition of 'struct sigcontext'
struct sigcontext {
^
In file included from
/home/peko/autobuild/instance-2/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/signal.h:243:0,
from ./include/private/../gc_pthread_redirects.h:42,
from ./include/private/../gc.h:1443,
from ./include/private/gc_priv.h:46,
from os_dep.c:17:
/home/peko/autobuild/instance-2/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/bits/signal.h:11:16:
note: originally defined here
typedef struct sigcontext
=================
The root cause is in the following excerpt from os_dep.c
=================
# if 2 <= __GLIBC__
# if 2 == __GLIBC__ && 0 == __GLIBC_MINOR__
/* glibc 2.1 no longer has sigcontext.h. But signal.h */
/* has the right declaration for glibc 2.1. */
# include <sigcontext.h>
# endif /* 0 == __GLIBC_MINOR__ */
# else /* __GLIBC__ < 2 */
/* libc5 doesn't have <sigcontext.h>: go directly with the kernel */
/* one. Check LINUX_VERSION_CODE to see which we should reference. */
# include <asm/sigcontext.h>
# endif /* __GLIBC__ < 2 */
=================
The logic here is intended to provide two special cases; one for
__GLIBC__ version 2.0, the other is a fall through case intended to be
reached if __GLIBC__ version is <2. However this fall through is also
reached if __GLIBC__ is undefined as is the case in musl. If the
__GLIBC__ version is 2.1 or greater no special action is taken.
musl, as a matter of policy, will never provide a macro to detect its
presence. Instead I propose that the above logic be wrapped in an
#ifdef __GLIBC__. I've tested that this allows the build to work on
musl, and should also work on uclibc and other C libraries.
I've attached a patch - I'm more than happy to update it if you feel
there is a better approach.
regards
Brendan