./a.out
To configure autoconf-based program to compile and link against musl,
-you may wish to use:
+set the CC variable to musl-gcc when running configure, as in:
-CC="musl-gcc -D_GNU_SOURCE" ./configure ...
-
-Correctly-written build systems should not need -D_GNU_SOURCE as part
-of $CC, but many programs do not use feature-test macros correctly and
-simply assume the compiler will automatically give them the kitchen
-sink, so the above command is an easy workaround.
+CC=musl-gcc ./configure ...
You will probably also want to use --prefix when building libraries to
ensure that they are installed under the musl prefix and not in the
you're using static linking only, you might instead check the symbols
and look for anything suspicious that would indicate your old glibc or
uClibc was used.
-
-When building programs against musl, you may still want to ensure the
-appropriate feature test macros get defined, as in:
-
-CC="gcc -D_GNU_SOURCE" ./configure ...
-
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
+#include <features.h>
#include <signal.h>
#include <time.h>
-#undef assert
+#include <features.h>
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#undef assert
#ifdef NDEBUG
#define assert(x) (void)0
extern "C" {
#endif
+#include <features.h>
+
int isalnum(int);
int isalpha(int);
int isblank(int);
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#define __NEED_ino_t
#define __NEED_off_t
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#define RTLD_LAZY 1
#define RTLD_NOW 2
#ifndef _ENDIAN_H
#define _ENDIAN_H
-#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
-#define __inline inline
-#endif
+#include <features.h>
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_off_t
#define __NEED_pid_t
#define __NEED_mode_t
-#warning "features.h is bogus"
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
+ && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
+ && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
+#define _BSD_SOURCE 1
+#define _XOPEN_SOURCE 700
+#endif
+
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
+#define __inline inline
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#elif defined(__GNUC__)
+#define _Noreturn __attribute__((__noreturn__))
+#else
+#define _Noreturn
+#endif
+
+#endif
extern "C" {
#endif
+#include <features.h>
+
#define FNM_PATHNAME 0x1
#define FNM_NOESCAPE 0x2
#define FNM_PERIOD 0x4
extern "C" {
#endif
+#include <features.h>
+
/* Normally we do not nest header includes. However useless bloat
* like ftw may be treated as a special case. Otherwise we would
* have to deal with duplicating all the stat.h mess. */
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#define __NEED_size_t
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_size_t
#define __NEED_gid_t
#ifndef _LIMITS_H
#define _LIMITS_H
+#include <features.h>
+
/* Most limits are system-specific */
#include <bits/limits.h>
extern "C" {
#endif
+#include <features.h>
+
#undef NULL
#ifdef __cplusplus
#define NULL 0
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
-#define __inline inline
-#endif
+#include <features.h>
#define __NEED_float_t
#define __NEED_double_t
extern "C" {
#endif
+#include <features.h>
+
#define IF_NAMESIZE 16
struct if_nameindex
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define __NEED_size_t
#ifndef _NETINET_TCP_H
#define _NETINET_TCP_H
+#include <features.h>
+
#define TCP_NODELAY 1
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#include <sys/types.h>
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_size_t
#define __NEED_uid_t
#define __NEED_gid_t
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_struct_timespec
#define __NEED_pid_t
#define __NEED_time_t
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
+#include <features.h>
#define __NEED_size_t
#include <bits/alltypes.h>
extern "C" {
#endif
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#include <features.h>
#include <bits/setjmp.h>
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#define __NEED_FILE
#define __NEED_va_list
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#include <features.h>
#undef NULL
#ifdef __cplusplus
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#undef NULL
#ifdef __cplusplus
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_uid_t
#define __NEED_gid_t
#define __NEED_mode_t
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_mode_t
#define __NEED_size_t
#define __NEED_off_t
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_id_t
#define __NEED_time_t
#define __NEED_struct_timeval
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_size_t
#define __NEED_pid_t
#define __NEED_time_t
extern "C" {
#endif
+#include <features.h>
#include <unistd.h>
ssize_t sendfile(int, int, off_t *, size_t);
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_time_t
#define __NEED_size_t
#define __NEED_pid_t
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#define __NEED_dev_t
#define __NEED_ino_t
extern "C" {
#endif
+#include <features.h>
+
#include <sys/statvfs.h>
typedef struct {
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#define __NEED_fsblkcnt_t
#define __NEED_fsfilcnt_t
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#include <sys/select.h>
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_ino_t
#define __NEED_dev_t
#define __NEED_uid_t
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_size_t
#define __NEED_ssize_t
#define __NEED_struct_iovec
extern "C" {
#endif
+#include <features.h>
+
struct utsname
{
char sysname[65];
extern "C" {
#endif
+#include <features.h>
+
#include <signal.h>
#define __NEED_pid_t
extern "C" {
#endif
+#include <features.h>
+
#define LOG_EMERG 0
#define LOG_ALERT 1
#define LOG_CRIT 2
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_pid_t
#include <bits/alltypes.h>
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#undef NULL
#ifdef __cplusplus
extern "C" {
#endif
+#include <features.h>
+
#include <signal.h>
#ifdef _GNU_SOURCE
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
-
-#if __STDC_VERSION__ >= 201112L
-#elif defined(__GNUC__)
-#define _Noreturn __attribute__((__noreturn__))
-#else
-#define _Noreturn
-#endif
+#include <features.h>
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
extern "C" {
#endif
-#if __STDC_VERSION__ >= 199901L
-#define __restrict restrict
-#elif !defined(__GNUC__)
-#define __restrict
-#endif
+#include <features.h>
#define __NEED_FILE
#define __NEED_va_list
extern "C" {
#endif
+#include <features.h>
+
#define __NEED_wint_t
#define __NEED_wctrans_t
#define __NEED_wctype_t