# HG changeset patch # User Pascal Bellard # Date 1371389177 -7200 # Node ID fc08361a0da7b96cc5238ef45b45c09919c565c1 # Parent 92f66e45cea708ab830981a385d7d5e37455d708 busybox: add musl & dietlibc patchs diff -r 92f66e45cea7 -r fc08361a0da7 busybox/receipt --- a/busybox/receipt Sat Jun 15 15:28:50 2013 +0200 +++ b/busybox/receipt Sun Jun 16 15:26:17 2013 +0200 @@ -12,7 +12,8 @@ HOST_ARCH="i486 arm" DEPENDS="slitaz-base-files glibc-base ncurses-common" -BUILD_DEPENDS="bzip2 pam pam-dev uclibc-cross-compiler-i486" +BUILD_DEPENDS="bzip2 pam pam-dev uclibc-cross-compiler-i486 \ +musl-libc-dev dietlibc" CONFIG_FILES="/etc/dnsd.conf /etc/inetd.conf /etc/udhcpd.conf \ /etc/resolv.conf /etc/httpd.conf" @@ -42,6 +43,8 @@ diff.u nfs-segfault.u xz.u +musl.u +diet.u EOT cp $stuff/$PACKAGE-${VERSION%.*}.config .config } @@ -72,9 +75,28 @@ mv busybox busybox-pam # prepare busybox-static package - cp $stuff/$PACKAGE-${VERSION%.*}.config-static .config - make oldconfig && make || return 1 - mv busybox busybox-static + if [ -x /usr/bin/uclibc-i486-gcc ]; then + cp $stuff/$PACKAGE-${VERSION%.*}.config-static .config + make oldconfig && make || return 1 + cp busybox busybox-static + mv busybox busybox-uclibc + fi + + if [ -x /usr/bin/musl-gcc ]; then + # prepare busybox-musl package + cp $stuff/$PACKAGE-${VERSION%.*}.config-static .config + sed -i 's|uclibc-i486-||;s|CFLAGS="|&-D__musl__ |' .config + make oldconfig && make CC=musl-gcc || return 1 + mv busybox busybox-musl + fi + + if [ -x /usr/lib/diet/bin/diet ]; then + # prepare busybox-diet package + cp $stuff/$PACKAGE-${VERSION%.*}.config-static .config + sed -i 's|uclibc-i486-||;s|CFLAGS="|&-D_BSD_SOURCE |;s|LDFLAGS="|&-Wl,--allow-multiple-definition |;s|LDLIBS="|&compat rpc |' .config + make oldconfig && make CC="/usr/lib/diet/bin/diet -Os gcc" || return 1 + mv busybox busybox-diet + fi # prepare ssfs-busybox package rootfs=$src/ssfs-busybox/usr/share/ssfs/rootfs diff -r 92f66e45cea7 -r fc08361a0da7 busybox/stuff/busybox-1.21-diet.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.21-diet.u Sun Jun 16 15:26:17 2013 +0200 @@ -0,0 +1,110 @@ +--- busybox-1.21.0/include/platform.h ++++ busybox-1.21.0/include/platform.h +@@ -460,6 +460,20 @@ + # include + #endif + ++#if defined(__dietlibc__) ++# define __aligned_u64 __u64 __attribute__((aligned(8))) ++# define LOOP_SET_STATUS64 0x4C04 ++# define LOOP_GET_STATUS64 0x4C05 ++# define MAXSYMLINKS 20 ++# define S_TYPEISMQ(x) 0 ++# define S_TYPEISSEM(x) 0 ++# define S_TYPEISSHM(x) 0 ++# undef HAVE_STRVERSCMP ++# undef HAVE_DPRINTF ++# undef HAVE_STRCASESTR ++# define ttyname_r(a,b,c) (strlcpy(b, ttyname(a), c) == 0) ++#endif ++ + /* + * Now, define prototypes for all the functions defined in platform.c + * These must come after all the HAVE_* macros are defined (or not) +--- busybox-1.21.0/networking/ping.c ++++ busybox-1.21.0/networking/ping.c +@@ -29,6 +29,84 @@ + #include + #include "libbb.h" + ++#ifdef __dietlibc__ ++/* Dietlibc is missing the BSD definition 'struct icmp' */ ++/* ++ * Internal of an ICMP Router Advertisement ++ */ ++struct icmp_ra_addr ++{ ++ uint32_t ira_addr; ++ uint32_t ira_preference; ++}; ++ ++struct icmp ++{ ++ uint8_t icmp_type; /* type of message, see below */ ++ uint8_t icmp_code; /* type sub code */ ++ uint16_t icmp_cksum; /* ones complement checksum of struct */ ++ union ++ { ++ uint8_t ih_pptr; /* ICMP_PARAMPROB */ ++ struct in_addr ih_gwaddr; /* gateway address */ ++ struct ih_idseq /* echo datagram */ ++ { ++ uint16_t icd_id; ++ uint16_t icd_seq; ++ } ih_idseq; ++ uint32_t ih_void; ++ ++ /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ ++ struct ih_pmtu ++ { ++ uint16_t ipm_void; ++ uint16_t ipm_nextmtu; ++ } ih_pmtu; ++ ++ struct ih_rtradv ++ { ++ uint8_t irt_num_addrs; ++ uint8_t irt_wpa; ++ uint16_t irt_lifetime; ++ } ih_rtradv; ++ } icmp_hun; ++#define icmp_pptr icmp_hun.ih_pptr ++#define icmp_gwaddr icmp_hun.ih_gwaddr ++#define icmp_id icmp_hun.ih_idseq.icd_id ++#define icmp_seq icmp_hun.ih_idseq.icd_seq ++#define icmp_void icmp_hun.ih_void ++#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void ++#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu ++#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs ++#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa ++#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime ++ union ++ { ++ struct ++ { ++ uint32_t its_otime; ++ uint32_t its_rtime; ++ uint32_t its_ttime; ++ } id_ts; ++ struct ++ { ++ struct ip idi_ip; ++ /* options and then 64 bits of data */ ++ } id_ip; ++ struct icmp_ra_addr id_radv; ++ uint32_t id_mask; ++ uint8_t id_data[1]; ++ } icmp_dun; ++#define icmp_otime icmp_dun.id_ts.its_otime ++#define icmp_rtime icmp_dun.id_ts.its_rtime ++#define icmp_ttime icmp_dun.id_ts.its_ttime ++#define icmp_ip icmp_dun.id_ip.idi_ip ++#define icmp_radv icmp_dun.id_radv ++#define icmp_mask icmp_dun.id_mask ++#define icmp_data icmp_dun.id_data ++}; ++#endif /* __dietlibc__ */ ++ + #ifdef __BIONIC__ + /* should be in netinet/ip_icmp.h */ + # define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ diff -r 92f66e45cea7 -r fc08361a0da7 busybox/stuff/busybox-1.21-musl.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/busybox/stuff/busybox-1.21-musl.u Sun Jun 16 15:26:17 2013 +0200 @@ -0,0 +1,40 @@ +--- busybox-1.21.0/include/platform.h ++++ busybox-1.21.0/include/platform.h +@@ -453,6 +453,13 @@ + # undef HAVE_NET_ETHERNET_H + #endif + ++#if defined(__musl__) ++# undef HAVE_SETBIT ++# include ++# include ++# include ++#endif ++ + /* + * Now, define prototypes for all the functions defined in platform.c + * These must come after all the HAVE_* macros are defined (or not) +--- busybox-1.21.0/include/libbb.h ++++ busybox-1.21.0/include/libbb.h +@@ -210,6 +210,13 @@ + * (in today's world - signed 64bit). For full support of large files, + * we need a few helper #defines (below) and careful use of off_t + * instead of int/ssize_t. No lseek64(), O_LARGEFILE etc necessary */ ++#if defined(__musl__) ++typedef unsigned long long uoff_t; ++# define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX) ++# define BB_STRTOOFF bb_strtoull ++# define STRTOOFF strtoull ++# define OFF_FMT "ll" ++#else + #if ENABLE_LFS + /* CONFIG_LFS is on */ + # if ULONG_MAX > 0xffffffff +@@ -246,6 +253,7 @@ + # define STRTOOFF strtol + # define OFF_FMT "l" + # endif ++#endif + #endif + /* scary. better ideas? (but do *test* them first!) */ + #define OFF_T_MAX ((off_t)~((off_t)1 << (sizeof(off_t)*8-1)))