Modify

Opened 5 years ago

Closed 3 years ago

#12651 closed defect (fixed)

Error when building with musl

Reported by: Halo2 Owned by: florian
Priority: normal Milestone: Chaos Calmer 15.05
Component: base system Version: Trunk
Keywords: Cc:

Description

Building with musl stops

after

install -d -m0755 /home/sa/backfire/wzr/test/build-trunk-2/trunk/build_dir/target-mips_r2_musl-0.9.8/toolchain/ipkg-ar71xx/libpthread/lib

cp -fpR /home/sa/backfire/wzr/test/build-trunk-2/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/libpthread.so.* /home/sa/backfire/wzr/test/build-trunk-2/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/libpthread-0.9.8.so /home/sa/backfire/wzr/test/build-trunk-2/trunk/build_dir/target-mips_r2_musl-0.9.8/toolchain/ipkg-ar71xx/libpthread/lib/

with

cp: cannot stat `/home/sa/backfire/wzr/test/build-trunk-2/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/libpthread.so.*': No such file or directory
cp: cannot stat `/home/sa/backfire/wzr/test/build-trunk-2/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/libpthread-0.9.8.so': No such file or directory

Which is right, there is only the small libpthread.a (which is intended if I remember right).

Didn't find much documentation, so can this be fixed, or how to work around?

Attachments (6)

200-musl.patch (24.7 KB) - added by anonymous 3 years ago.
updated patch for gcc-4.8-linaro musl build
001-musl-symlink-fix.patch (444 bytes) - added by scottvalen@… 3 years ago.
simple patch to fix musl build issue
gcc-4.8.0-200-musl.patch (11.7 KB) - added by scottvalen@… 3 years ago.
updated patch for gcc-4.8-0 (not linaro) musl build
gcc-4.8.0-200-musl.v2.patch (24.7 KB) - added by scottvalen@… 3 years ago.
ignore previous, this is the correct patch
gcc-4.8.0-musl.patch-v3 (24.9 KB) - added by scottvalen@… 3 years ago.
updated patch for gcc-4.8-0 musl build, fixes sh and mips soft-float targets
gcc-4.8-linaro-musl.patch-v2 (24.8 KB) - added by scottvalen@… 3 years ago.
updated patch for gcc-4.8-linaro musl build, fixes sh and mips soft-float targets

Download all attachments as: .zip

Change History (44)

comment:1 Changed 5 years ago by florian

  • Owner changed from developers to florian
  • Status changed from new to accepted

comment:2 Changed 5 years ago by florian

  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed with r35069.

comment:3 Changed 5 years ago by Halo2

  • Resolution fixed deleted
  • Status changed from closed to reopened

Now it stops because:

make[4]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/uboot-envtools-2012.04.01'
mips-openwrt-linux-musl-gcc -Wall -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float  -I/space/build-trunk/trunk/staging_dir/target-mips_r2_musl-0.9.8/usr/include -I/space/build-trunk/trunk/staging_dir/target-mips_r2_musl-0.9.8/include -I/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/usr/include -I/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/include  crc32.c fw_env.c fw_env_main.c -o fw_printenv
fw_env.c:643:55: error: unknown type name 'loff_t'
fw_env.c: In function 'flash_read_buf':
fw_env.c:680:2: error: unknown type name 'loff_t'
fw_env.c:713:3: warning: implicit declaration of function 'flash_bad_block' [-Wimplicit-function-declaration]
fw_env.c: In function 'flash_write_buf':
fw_env.c:777:2: error: unknown type name 'loff_t'
make[4]: *** [fw_printenv] Error 1
make[4]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/uboot-envtools-2012.04.01'

if INSTALL_LIBSTDCPP is enabled even before with:

make[8]: Entering directory `/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include'
mkdir -p ./mips-openwrt-linux-musl/bits/stdc++.h.gch
/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/./gcc/xgcc -shared-libgcc -B/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/./gcc -nostdinc++ -L/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/src -L/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/src/.libs -B/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/mips-openwrt-linux-musl/bin/ -B/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/mips-openwrt-linux-musl/lib/ -isystem /space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/mips-openwrt-linux-musl/include -isystem /space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/mips-openwrt-linux-musl/sys-include    -x c++-header -nostdinc++ -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/mips-openwrt-linux-musl -I/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include -I/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11/libstdc++-v3/libsupc++ -O2 -g -std=gnu++0x /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11/libstdc++-v3/include/precompiled/stdc++.h \
	-o mips-openwrt-linux-musl/bits/stdc++.h.gch/O2ggnu++0x.gch
In file included from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/bits/postypes.h:42:0,
                 from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/iosfwd:42,
                 from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/ios:39,
                 from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/istream:40,
                 from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/sstream:39,
                 from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/complex:47,
                 from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/ccomplex:42,
                 from /space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11/libstdc++-v3/include/precompiled/stdc++.h:53:
/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include/cwchar:60:5: error: conflicting declaration 'typedef struct mbstate_t mbstate_t'
/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/./gcc/include-fixed/wchar.h:51:3: error: 'mbstate_t' has a previous declaration as 'typedef struct mbstate_t mbstate_t'
make[8]: *** [mips-openwrt-linux-musl/bits/stdc++.h.gch/O2ggnu++0x.gch] Error 1
make[8]: Leaving directory `/space/build-trunk/trunk/build_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/gcc-linaro-4.6-2012.11-final/mips-openwrt-linux-musl/libstdc++-v3/include'

and when tried with current trunk its:

make[6]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17'
Scanning dependencies of target netifd
make[6]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17'
make[6]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17'
[  5%] Building C object CMakeFiles/netifd.dir/main.c.o
[ 11%] Building C object CMakeFiles/netifd.dir/utils.c.o
[ 17%] Building C object CMakeFiles/netifd.dir/system.c.o
[ 23%] Building C object CMakeFiles/netifd.dir/tunnel.c.o
[ 29%] Building C object CMakeFiles/netifd.dir/interface.c.o
[ 35%] Building C object CMakeFiles/netifd.dir/interface-ip.c.o
/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17/interface-ip.c: In function 'interface_ip_set_ula_prefix':
/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17/interface-ip.c:646:2: error: suggest parentheses around arithmetic in operand of '|' [-Werror=parentheses]
/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17/interface-ip.c:646:2: error: suggest parentheses around arithmetic in operand of '|' [-Werror=parentheses]
/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17/interface-ip.c:646:2: error: suggest parentheses around arithmetic in operand of '|' [-Werror=parentheses]
cc1: all warnings being treated as errors
make[6]: *** [CMakeFiles/netifd.dir/interface-ip.c.o] Error 1
make[6]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/netifd-2013-01-17'

comment:4 Changed 5 years ago by florian

libstdc++ cannot be built with musl yet, which is why INSTALL_LIBSTDCPP is default n if MUSL. The netifd warnings are unrelated.

comment:5 Changed 5 years ago by Halo2

But netifd compiles as long as uClibc is used.
(And it also did some releases ago with musl.)
So is it dirty code in interface_ip_set_ula_prefix function of interface-ip.c . Or bad musl.
At least I think that cannot be called unrelated?

comment:6 Changed 5 years ago by Halo2

I've created a separate ticket for netifd's new code which makes problems.

So what to do with:

linux/include/linux/types.h:

#if defined(__GNUC__)
typedef __kernel_loff_t         loff_t;
#endif

and

linux/include/asm-generic/posix_types.h:

typedef long long       __kernel_loff_t;

but

arch/arm/include/asm/posix_types.h:
arch/x86/include/asm/posix_types_32.h:
arch/x86/include/asm/posix_types_64.h:

#ifdef __GNUC__
typedef long long               __kernel_loff_t;
#endif

An if musl typedef long long loff_t wouldn't be the generic fix I think...

comment:7 Changed 5 years ago by Halo2

As of ticket #12871 it seems that
http://git.musl-libc.org/cgit/musl/tree/include/netinet/in.h#n148
leads to the problem of netifd not getting compiled.
I will communicate with the musl team for that as next step.

comment:8 Changed 5 years ago by Halo2

To get netifd compiled i wanted to add --disable-werror. But i didn't get this to work with the package Makefile.

So i removed -Werror from
ADD_DEFINITIONS(-Os -Wall --std=gnu99 -Wmissing-declarations)
in CMakeLists.txt of the build_dir.

How would a practicable solution look like?

comment:9 Changed 5 years ago by Halo2

To the unknown type loff_t error Rich Felker responded:

Where is loff_t being used? It's probably the wrong type to use. The
only APIs loff_t is to be used with are under _GNU_SOURCE, so if you
don't need -D_GNU_SOURCE to get the functions, it's doubtful that
loff_t should be used. These functions are in fcntl.h, and it will
#define loff_t off_t when _GNU_SOURCE is defined, so either
-D_GNU_SOURCE or -Dloff_t=off_t would be a workaround, but I think the
issue should be investigated to determine if there's code that needs
to be fixed or if there are other circumstances under which loff_t
should be exposed by musl.

And he was absolutely right with his workaround.
I added CFLAGS += -D_GNU_SOURCE to uboot-envtools Makefile (again in build_dir) and after that it compiles.

But after that..

mips-openwrt-linux-musl-gcc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -Dtarget_ar71xx=1 -Wall -DFIS_SUPPORT=1 -I/space/build-trunk/trunk/staging_dir/target-mips_r2_musl-0.9.8/usr/include -I/space/build-trunk/trunk/staging_dir/target-mips_r2_musl-0.9.8/include -I/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/usr/include -I/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/include -Wall -c -o fis.o fis.c
fis.c: In function 'fis_open':
fis.c:80:64: error: 'MAP_LOCKED' undeclared (first use in this function)
fis.c:80:64: note: each undeclared identifier is reported only once for each function it appears in

So I wonder why uClibc? seems to include these things?

comment:10 Changed 5 years ago by Halo2

mman.h got more defines with the following commits
http://git.musl-libc.org/cgit/musl/commit/?id=0e10f740069c2d805d3199a8079b73e828c7d8d9
http://git.musl-libc.org/cgit/musl/commit/?id=7e0d4fce41ac95adc080bffa88ee0f51c1cf2837
http://git.musl-libc.org/cgit/musl/commit/?id=000806cde6416f51f783d2dc487d49b47d297e4e
so MAP_LOCKED works in the next musl version.

Now I'm stuck at:

make[6]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/pptp'
mips-openwrt-linux-musl-gcc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I. -I../.. -I../../../include -fPIC -DPPPD_VERSION=\"2.4.5\" -c -o dirutil.o dirutil.c
mips-openwrt-linux-musl-gcc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I. -I../.. -I../../../include -fPIC -DPPPD_VERSION=\"2.4.5\" -c -o orckit_quirks.o orckit_quirks.c
mips-openwrt-linux-musl-gcc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I. -I../.. -I../../../include -fPIC -DPPPD_VERSION=\"2.4.5\" -c -o pptp.o pptp.c
In file included from /space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/gcc/mips-openwrt-linux-musl/4.6.4/../../../../mips-openwrt-linux-musl/sys-include/linux/if_pppox.h:24:0,
                 from pptp.c:52:
/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/gcc/mips-openwrt-linux-musl/4.6.4/../../../../mips-openwrt-linux-musl/sys-include/linux/if_ether.h:128:8: error: redefinition of 'struct ethhdr'
/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/gcc/mips-openwrt-linux-musl/4.6.4/../../../../mips-openwrt-linux-musl/sys-include/netinet/if_ether.h:75:8: note: originally defined here
make[6]: *** [pptp.o] Error 1
make[6]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/pptp'
make[6]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/radius'
mips-openwrt-linux-musl-gcc -I. -I../.. -I../../../include -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -fPIC -DRC_LOG_FACILITY=LOG_DAEMON -DCHAPMS=1 -DMPPE=1 -DMAXOCTETS=1   -c -o radius.o radius.c
mips-openwrt-linux-musl-gcc -I. -I../.. -I../../../include -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -fPIC -DRC_LOG_FACILITY=LOG_DAEMON -DCHAPMS=1 -DMPPE=1 -DMAXOCTETS=1   -c -o avpair.o avpair.c
In file included from ./includes.h:50:0,
                 from avpair.c:17:
../../magic.h:45:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__P'
../../magic.h:46:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__P'
../../magic.h:49:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__P'
make[6]: *** [avpair.o] Error 1
make[6]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/radius'

comment:11 Changed 5 years ago by Halo2

magic.h:

void magic_init __P((void));	/* Initialize the magic number generator */
u_int32_t magic __P((void));	/* Returns the next magic number */

/* Fill buffer with random bytes */
void random_bytes __P((unsigned char *buf, int len));

No clue what P does, but just removing it and the () continued to:

make[5]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/rp-pppoe'
mips-openwrt-linux-musl-gcc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I../../../include '-DRP_VERSION="3.8p"' -I../../.. -c -o plugin.o -fPIC plugin.c
In file included from plugin.c:29:0:
pppoe.h:43:23: fatal error: sys/cdefs.h: No such file or directory
compilation terminated.
make[5]: *** [plugin.o] Error 1
make[5]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/rp-pppoe'

make[5]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/pptp'
mips-openwrt-linux-musl-gcc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I. -I../.. -I../../../include -fPIC -DPPPD_VERSION=\"2.4.5\" -c -o pptp.o pptp.c
In file included from /space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/gcc/mips-openwrt-linux-musl/4.6.4/../../../../mips-openwrt-linux-musl/sys-include/linux/if_pppox.h:24:0,
                 from pptp.c:52:
/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/gcc/mips-openwrt-linux-musl/4.6.4/../../../../mips-openwrt-linux-musl/sys-include/linux/if_ether.h:128:8: error: redefinition of 'struct ethhdr'
/space/build-trunk/trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_musl-0.9.8/lib/gcc/mips-openwrt-linux-musl/4.6.4/../../../../mips-openwrt-linux-musl/sys-include/netinet/if_ether.h:75:8: note: originally defined here
make[5]: *** [pptp.o] Error 1
make[5]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd/plugins/pptp'

make[4]: Entering directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd'
mips-openwrt-linux-musl-gcc -Os -pipe -mips32r2 -mtune=mips32r2 -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -DHAVE_PATHS_H -DHAVE_MMAP -I../include '-DDESTDIR="/usr"' -DCHAPMS=1 -DMPPE=1 -DHAVE_CRYPT_H=1 -DUSE_CRYPT=1 -DPLUGIN -DPPP_FILTER -DPPP_PRECOMPILED_FILTER -I/space/build-trunk/trunk/staging_dir/target-mips_r2_musl-0.9.8/usr/include -DINET6=1 -DMAXOCTETS   -c -o sys-linux.o sys-linux.c
sys-linux.c:76:23: fatal error: sys/errno.h: No such file or directory
compilation terminated.
make[4]: *** [sys-linux.o] Error 1
make[4]: Leaving directory `/space/build-trunk/trunk/build_dir/target-mips_r2_musl-0.9.8/ppp-default/ppp-2.4.5/pppd'

How did you compile it through florian?
Do you think the missing .h's are really missing on musl's side?

comment:12 Changed 5 years ago by anonymous

including sys/cdefs.h is a bug in the program, this is a completely non-standard header for glibc internal usage; it was never intended to be used by apps

comment:13 Changed 5 years ago by anonymous

when looking at all these portability issues which apparently where added in the latest release of this piece of SW, which used to compile against musl just fine, one could get the impression that they added these bugs *by purpose*

comment:14 Changed 5 years ago by florian

The netifd issue is now fixed with r35404. I will add the possibility for an user to select a particular git revision to use for musl so you can experiment with it as they update it. There is still the building of libtsdc++ to be fixed.

comment:15 Changed 5 years ago by anonymous

Building with musl on x86 still fails:

make[3]: Entering directory `/home/apache/openwrt/package/toolchain'
mkdir -p /home/apache/openwrt/bin/x86-musl/packages /home/apache/openwrt/build_dir/target-i386_musl-0.9.8/toolchain/ipkg-x86/libc/CONTROL /home/apache/openwrt/staging_dir/target-i386_musl-0.9.8/pkginfo
install -d -m0755 /home/apache/openwrt/build_dir/target-i386_musl-0.9.8/toolchain/ipkg-x86/libc/lib
cp -fpR /home/apache/openwrt/staging_dir/toolchain-i386_gcc-4.6-linaro_musl-0.9.8/lib/ld-musl-*.so* /home/apache/openwrt/build_dir/target-i386_musl-0.9.8/toolchain/ipkg-x86/libc/lib/
cp: cannot stat `/home/apache/openwrt/staging_dir/toolchain-i386_gcc-4.6-linaro_musl-0.9.8/lib/ld-musl-*.so*': No such file or directory
make[3]: *** [/home/apache/openwrt/bin/x86-musl/packages/libc_0.9.8-1_x86.ipk] Error 1

Probably ld-musl.so (=ld-linux.so) just isn't needed with musl.

comment:16 Changed 5 years ago by anonymous

Fdisk won't compile with musl-0.9.9

Making all in fdisk
make[6]: Entering directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.9/util-linux-2.21.2/fdisk'
i486-openwrt-linux-musl-gcc -DHAVE_CONFIG_H -I. -I..  -include ../config.h -I../include -DLOCALEDIR=\"/usr/share/locale\" -I/home/apache/openwrt/staging_dir/target-i386_musl-0.9.9/usr/include -I/home/apache/openwrt/staging_dir/target-i386_musl-0.9.9/include -I/home/apache/openwrt/staging_dir/toolchain-i386_gcc-4.6-linaro_musl-0.9.9/usr/include -I/home/apache/openwrt/staging_dir/toolchain-i386_gcc-4.6-linaro_musl-0.9.9/include  -fsigned-char -I../libblkid/src -O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -fpic  -MT cfdisk-cfdisk.o -MD -MP -MF .deps/cfdisk-cfdisk.Tpo -c -o cfdisk-cfdisk.o `test -f 'cfdisk.c' || echo './'`cfdisk.c
cfdisk.c:319:1: error: unknown type name '__sighandler_t'
cfdisk.c: In function 'die_x':
cfdisk.c:585:5: warning: passing argument 2 of 'signal' makes pointer from integer without a cast [enabled by default]
/home/apache/openwrt/staging_dir/toolchain-i386_gcc-4.6-linaro_musl-0.9.9/lib/gcc/i486-openwrt-linux-musl/4.6.4/../../../../i486-openwrt-linux-musl/sys-include/signal.h:238:8: note: expected 'void (*)(int)' but argument is of type 'int'
cfdisk.c:586:5: warning: passing argument 2 of 'signal' makes pointer from integer without a cast [enabled by default]
/home/apache/openwrt/staging_dir/toolchain-i386_gcc-4.6-linaro_musl-0.9.9/lib/gcc/i486-openwrt-linux-musl/4.6.4/../../../../i486-openwrt-linux-musl/sys-include/signal.h:238:8: note: expected 'void (*)(int)' but argument is of type 'int'
cfdisk.c: In function 'do_curses_fdisk':
cfdisk.c:2582:16: warning: assignment makes integer from pointer without a cast [enabled by default]
cfdisk.c:2583:17: warning: assignment makes integer from pointer without a cast [enabled by default]
make[6]: *** [cfdisk-cfdisk.o] Error 1
make[6]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.9/util-linux-2.21.2/fdisk' 

Quick patch helps:

diff -urN musl-0.9.9/include/signal.h musl-0.9.9.new/include/signal.h
--- musl-0.9.9/include/signal.h	2013-04-14 01:04:27.000000000 +0300
+++ musl-0.9.9.new/include/signal.h	2013-04-14 13:02:41.000000000 +0300
@@ -218,6 +218,7 @@
 
 #ifdef _GNU_SOURCE
 typedef void (*sighandler_t)(int);
+typedef void (*__sighandler_t)(int);
 void (*bsd_signal(int, void (*)(int)))(int);
 int sigisemptyset(const sigset_t *);
 int sigorset (sigset_t *, sigset_t *, sigset_t *); 

comment:17 Changed 5 years ago by anonymous

Again problem with building utils:

  CC     rename.o
  CCLD   rename
  CC     uuidd-uuidd.o
uuidd.c: In function 'usage':
uuidd.c:56:30: error: 'program_invocation_short_name' undeclared (first use in this function)
uuidd.c:56:30: note: each undeclared identifier is reported only once for each function it appears in
uuidd.c: In function 'main':
uuidd.c:506:11: error: 'program_invocation_short_name' undeclared (first use in this function)
make[6]: *** [uuidd-uuidd.o] Error 1
make[6]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.9/util-linux-2.21.2/misc-utils'

Already fixed in musl-0.9.10, but this version is not added to toolchain yet.

comment:18 Changed 5 years ago by anonymous

And now in term-utils:

Making all in term-utils
make[6]: Entering directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
  CC     agetty.o
agetty.c: In function 'termio_init':
agetty.c:1070:25: error: 'TTYDEF_SPEED' undeclared (first use in this function)
agetty.c:1070:25: note: each undeclared identifier is reported only once for each function it appears in
agetty.c: In function 'reset_vc':
agetty.c:1148:17: error: 'TTYDEF_IFLAG' undeclared (first use in this function)
agetty.c:1149:17: error: 'TTYDEF_OFLAG' undeclared (first use in this function)
agetty.c:1150:17: error: 'TTYDEF_LFLAG' undeclared (first use in this function)
agetty.c:1156:28: error: 'TTYDEF_CFLAG' undeclared (first use in this function)
agetty.c:1192:23: error: 'CINTR' undeclared (first use in this function)
agetty.c:1193:23: error: 'CQUIT' undeclared (first use in this function)
agetty.c:1194:23: error: 'CERASE' undeclared (first use in this function)
agetty.c:1195:23: error: 'CKILL' undeclared (first use in this function)
agetty.c:1196:23: error: 'CEOF' undeclared (first use in this function)
agetty.c:1202:23: error: 'CSTART' undeclared (first use in this function)
agetty.c:1203:23: error: 'CSTOP' undeclared (first use in this function)
agetty.c:1204:23: error: 'CSUSP' undeclared (first use in this function)
agetty.c:1206:23: error: 'CREPRINT' undeclared (first use in this function)
agetty.c:1207:23: error: 'CDISCARD' undeclared (first use in this function)
agetty.c:1208:23: error: 'CWERASE' undeclared (first use in this function)
agetty.c:1209:23: error: 'CLNEXT' undeclared (first use in this function)
make[6]: *** [agetty.o] Error 1
make[6]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[3]: *** [/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/.built] Error 2 

Because unix/sysv/linux/sys/ttydefaults.h is gone in musl.

comment:19 Changed 5 years ago by anonymous

One more in term-utils:

Making all in term-utils
make[6]: Entering directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
  CC     agetty.o
  CCLD   agetty
  CC     script.o
  CCLD   script
  CC     scriptreplay.o
  CCLD   scriptreplay
  CC     setterm.o
setterm.c:129:16: error: unknown type name 'klogctl'
setterm.c:129:30: error: unknown type name 'type'
setterm.c:129:43: error: unknown type name 'buf'
setterm.c:129:53: error: unknown type name 'len'
make[6]: *** [setterm.o] Error 1
make[6]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[3]: *** [/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/.built] Error 2 

Fixing by commenting out conditionals in
term-utils/setterm.c

//#if __GNU_LIBRARY__ < 5
//#ifndef __alpha__
//# include <linux/unistd.h>
//#define __NR_klogctl __NR_syslog
//_syscall3(int, klogctl, int, type, char*, buf, int, len);
//#else /* __alpha__ */
//#define klogctl syslog
//#endif
//#endif
extern int klogctl(int type, char *buf, int len);

comment:20 Changed 5 years ago by anonymous

ttymsg.c

Making all in term-utils
make[6]: Entering directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
  CC     agetty.o
  CCLD   agetty
  CC     setterm.o
  CCLD   setterm
  CC     wall-wall.o
  CC     wall-ttymsg.o
ttymsg.c: In function 'ttymsg':
ttymsg.c:68:21: error: 'MAXNAMLEN' undeclared (first use in this function)
ttymsg.c:68:21: note: each undeclared identifier is reported only once for each function it appears in
make[6]: *** [wall-ttymsg.o] Error 1
make[6]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[3]: *** [/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/.built] Error 2 

Just adding one more include to term-utils/ttymsg.c

 #include <sys/types.h>
 #include <sys/uio.h>
+#include <sys/param.h>

comment:21 Changed 5 years ago by anonymous

Yet another in 'more'

Making all in term-utils
make[6]: Entering directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
  CC     setterm.o
  CCLD   setterm
make[6]: Warning: File `ttymsg.c' has modification time 20 s in the future
  CC     wall-ttymsg.o
  CC     wall-strutils.o
  CCLD   wall
make[6]: warning:  Clock skew detected.  Your build may be incomplete.
make[6]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/term-utils'
Making all in text-utils
make[6]: Entering directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/text-utils'
  CC     more.o
more.c: In function 'search':
more.c:1591:12: warning: assignment makes pointer from integer without a cast [enabled by default]
  CCLD   more
more.o: In function `search':
more.c:(.text+0x2ce6): undefined reference to `re_comp'
more.c:(.text+0x2d4d): undefined reference to `re_exec'
collect2: ld returned 1 exit status
make[6]: *** [more] Error 1
make[6]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/text-utils'
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2'
make[3]: *** [/home/apache/openwrt/build_dir/target-i386_musl-0.9.10/util-linux-2.21.2/.built] Error 2 

BSD-style 're_comp' and 're_exec' are used.
Should be 'regcomp' and 'regexec' if following POSIX...

Giving up, it's hard to fix quickly.

comment:22 Changed 5 years ago by Anton van Bohemen <avbohemen@…>

I'm also trying to build OpenWRT using musl. After setting INSTALL_LIBSTDCPP to n and updating to musl 0.9.10, I get the following error trying to compile 'taskset'

mips-openwrt-linux-musl-gcc -DHAVE_CONFIG_H -I. -I..  -include ../config.h -I../include -DLOCALEDIR=\"/usr/share/locale\" -I/home/anton/openwrt/ar71xx/trunk/staging_dir/target-mips_musl-0.9.10/usr/include -I/home/anton/openwrt/ar71xx/trunk/staging_dir/target-mips_musl-0.9.10/include -I/home/anton/openwrt/ar71xx/trunk/staging_dir/toolchain-mips_gcc-4.6-linaro_musl-0.9.10/usr/include -I/home/anton/openwrt/ar71xx/trunk/staging_dir/toolchain-mips_gcc-4.6-linaro_musl-0.9.10/include  -fsigned-char -Os -pipe -march=24kc -mtune=24kc -fno-caller-saves -mno-branch-likely -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -fpic  -MT taskset.o -MD -MP -MF .deps/taskset.Tpo -c -o taskset.o taskset.c
In file included from taskset.c:31:0:
../include/cpuset.h:51:1: error: unknown type name 'cpu_set_t'
../include/cpuset.h:70:48: error: unknown type name 'cpu_set_t'
../include/cpuset.h:86:1: error: unknown type name 'cpu_set_t'
../include/cpuset.h:87:25: error: unknown type name 'cpu_set_t'
../include/cpuset.h:89:52: error: unknown type name 'cpu_set_t'
../include/cpuset.h:90:43: error: unknown type name 'cpu_set_t'
../include/cpuset.h:92:52: error: unknown type name 'cpu_set_t'
../include/cpuset.h:93:43: error: unknown type name 'cpu_set_t'
taskset.c:40:2: error: unknown type name 'cpu_set_t'
taskset.c: In function 'print_affinity':
taskset.c:85:7: warning: assignment makes pointer from integer without a cast [enabled by default]
taskset.c:89:7: warning: assignment makes pointer from integer without a cast [enabled by default]
taskset.c: At top level:
taskset.c:101:60: error: unknown type name 'cpu_set_t'
taskset.c: In function 'main':
taskset.c:130:2: error: unknown type name 'cpu_set_t'
make[6]: *** [taskset.o] Error 1
make[6]: Leaving directory `/home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_musl-0.9.10/util-linux-2.21.2/schedutils'
make[6]: Entering directory `/home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_musl-0.9.10/util-linux-2.21.2'
make[6]: Leaving directory `/home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_musl-0.9.10/util-linux-2.21.2'
make[5]: *** [all-recursive] Error 1
make[5]: Leaving directory `/home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_musl-0.9.10/util-linux-2.21.2'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_musl-0.9.10/util-linux-2.21.2'
make[3]: *** [/home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_musl-0.9.10/util-linux-2.21.2/.built] Error 2
make[3]: Leaving directory `/home/anton/openwrt/ar71xx/trunk/package/util-linux'
make[2]: *** [package/util-linux/compile] Error 2

Looks somewhat similar to the problems above, but I'm not a developer, so no clue where to look...

comment:23 Changed 5 years ago by raver@…

Environment: brcm47xx trunk r36636

Build now stops with the following error:

make[3]: Entering directory `/home/OpenWrt/trunk/package/toolchain'
mkdir -p /home/OpenWrt/trunk/bin/brcm47xx-musl/packages /home/OpenWrt/trunk/build_dir/target-mipsel_musl-0.9.10/toolchain/ipkg-brcm47xx/libc/CONTROL /home/OpenWrt/trunk/staging_dir/target-mipsel_musl-0.9.10/pkginfo
install -d -m0755 /home/OpenWrt/trunk/build_dir/target-mipsel_musl-0.9.10/toolchain/ipkg-brcm47xx/libc/lib
cp -fpR /home/OpenWrt/trunk/staging_dir/toolchain-mipsel_gcc-4.6-linaro_musl-0.9.10/lib/ld-musl-*.so* /home/OpenWrt/trunk/build_dir/target-mipsel_musl-0.9.10/toolchain/ipkg-brcm47xx/libc/lib/
cp: cannot stat '/home/OpenWrt/trunk/staging_dir/toolchain-mipsel_gcc-4.6-linaro_musl-0.9.10/lib/ld-musl-*.so*': No such file or directory
make[3]: *** [/home/OpenWrt/trunk/bin/brcm47xx-musl/packages/libc_0.9.10-1_brcm47xx.ipk] Error 1
make[3]: Leaving directory `/home/OpenWrt/trunk/package/toolchain'
make[2]: *** [package/toolchain/compile] Error 2
make[2]: Leaving directory `/home/OpenWrt/trunk'
make[1]: *** [/home/OpenWrt/trunk/staging_dir/target-mipsel_musl-0.9.10/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/OpenWrt/trunk'
make: *** [world] Error 2

Got the same error with gcc-4.8-linaro.

comment:24 Changed 5 years ago by Anton van Bohemen <avbohemen@…>

Still no change with musl 0.9.11, gcc-4.8-linaro, ar71xx trunk r37209. First I had to disable MIPS16, otherwise the toolchain would not even build. But then still the error when copying the .so files:

make[3]: Entering directory `/home/anton/openwrt/ar71xx/trunk/package/libs/toolchain'
mkdir -p /home/anton/openwrt/ar71xx/trunk/bin/ar71xx-musl/packages /home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_r2_musl-0.9.11/toolchain/ipkg-ar71xx/libc/CONTROL /home/anton/openwrt/ar71xx/trunk/staging_dir/target-mips_r2_musl-0.9.11/pkginfo
install -d -m0755 /home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_r2_musl-0.9.11/toolchain/ipkg-ar71xx/libc/lib
cp -fpR /home/anton/openwrt/ar71xx/trunk/staging_dir/toolchain-mips_r2_gcc-4.8-linaro_musl-0.9.11/lib/ld-musl-*.so* /home/anton/openwrt/ar71xx/trunk/build_dir/target-mips_r2_musl-0.9.11/toolchain/ipkg-ar71xx/libc/lib/
cp: cannot stat `/home/anton/openwrt/ar71xx/trunk/staging_dir/toolchain-mips_r2_gcc-4.8-linaro_musl-0.9.11/lib/ld-musl-*.so*': No such file or directory
make[3]: *** [/home/anton/openwrt/ar71xx/trunk/bin/ar71xx-musl/packages/libc_0.9.11-1_ar71xx.ipk] Error 1
make[3]: Leaving directory `/home/anton/openwrt/ar71xx/trunk/package/libs/toolchain'
make[2]: *** [package/libs/toolchain/compile] Error 2
make[2]: Leaving directory `/home/anton/openwrt/ar71xx/trunk'
make[1]: *** [/home/anton/openwrt/ar71xx/trunk/staging_dir/target-mips_r2_musl-0.9.11/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/anton/openwrt/ar71xx/trunk'
make: *** [world] Error 2

Has anyone ever succeeded in building OpenWRT using musl instead of uClibc?

comment:25 Changed 5 years ago by florian

  • Status changed from reopened to accepted

Yes I have built it for mips, x86 and ARM and it works just fine. There seems to be some kind of build issue in musl which results in the dynamic linker not to be always copied over the rootfs.

comment:26 Changed 5 years ago by anonymous

Environment: ar71xx trunk r37224

ln -sf /lib/libc.so ld-musl-mips.so.1

I passed the building with musl

but kernel panic in load procd

[ 2.450000] Freeing unused kernel memory: 268K (8031d000 - 80360000)
[ 3.150000] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[ 3.150000]

comment:27 Changed 4 years ago by ppvazquezfer@…

Trunk r37743, target BCM63xx, GCC 4.8-linaro and binutils 2.22.

make -C image compile TARGET_BUILD=
make[5]: Entering directory `/home/pepe/trunk/target/linux/brcm63xx/image'
make[5]: `compile' is up to date.
make[5]: Leaving directory `/home/pepe/trunk/target/linux/brcm63xx/image'
make[4]: Leaving directory `/home/pepe/trunk/target/linux/brcm63xx'
make[3]: Leaving directory `/home/pepe/trunk/target/linux'
make[2]: Leaving directory `/home/pepe/trunk'
make[2]: Entering directory `/home/pepe/trunk'
rm -rf /home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/root-brcm63xx
make[2]: Leaving directory `/home/pepe/trunk'
make[2]: Entering directory `/home/pepe/trunk'
make[3]: Entering directory `/home/pepe/trunk/package/libs/toolchain'
mkdir -p /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain
touch /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/.prepared_016374e9b4ec29fa5187f68dc140c49d
(cd /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/./; if [ -x ./configure ]; then /usr/bin/find /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ -name config.guess | xargs -r chmod u+w; /usr/bin/find /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ -name config.guess | xargs -r -n1 cp /home/pepe/trunk/scripts/config.guess; /usr/bin/find /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ -name config.sub | xargs -r chmod u+w; /usr/bin/find /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ -name config.sub | xargs -r -n1 cp /home/pepe/trunk/scripts/config.sub; AR=mips-openwrt-linux-musl-ar AS="mips-openwrt-linux-musl-gcc -c -Os -pipe -mips32 -mtune=mips32 -mno-branch-likely -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float " LD=mips-openwrt-linux-musl-ld NM=mips-openwrt-linux-musl-nm CC="mips-openwrt-linux-musl-gcc" GCC="mips-openwrt-linux-musl-gcc" CXX="mips-openwrt-linux-musl-g++" RANLIB=mips-openwrt-linux-musl-ranlib STRIP=mips-openwrt-linux-musl-strip OBJCOPY=mips-openwrt-linux-musl-objcopy OBJDUMP=mips-openwrt-linux-musl-objdump SIZE=mips-openwrt-linux-musl-size CFLAGS="-Os -pipe -mips32 -mtune=mips32 -mno-branch-likely -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float " CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -mno-branch-likely -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float " CPPFLAGS="-I/home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/usr/include -I/home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/include -I/home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/usr/include -I/home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/include " LDFLAGS="-L/home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/usr/lib -L/home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/lib -L/home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/usr/lib -L/home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/lib "   ./configure --target=mips-openwrt-linux --host=mips-openwrt-linux --build=i486-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls  --disable-ipv6 ; fi; )
rm -f /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/.configured_*
touch /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/.configured_
cp -fpR /home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/lib/libgcc_s.so.1 /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/
touch /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/.built
mkdir -p /home/pepe/trunk/bin/brcm63xx-musl/packages /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc/CONTROL /home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/pkginfo
install -d -m0755 /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc/lib
cp -fpR /home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/lib/libgcc_s.so.* /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc/lib/
find /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| xargs -r rm -rf
export CROSS="mips-openwrt-linux-musl-" NO_RENAME=1 ; NM="mips-openwrt-linux-musl-nm" STRIP="/home/pepe/trunk/staging_dir/host/bin/sstrip" STRIP_KMOD="/home/pepe/trunk/scripts/strip-kmod.sh" /home/pepe/trunk/scripts/rstrip.sh /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc
rstrip.sh: /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc/lib/libgcc_s.so.1:shared object
( echo "Package: libgcc"; echo "Version: 4.8-linaro-1"; DEPENDS=''; for depend in ; do DEPENDS=${DEPENDS:+$DEPENDS, }${depend##+}; done; [ -z "$DEPENDS" ] || echo "Depends: $DEPENDS";  echo "Source: package/libs/toolchain";     echo "Section: libs"; echo "Status: unknown hold not-installed";   echo "Essential: yes";  echo "Maintainer: Felix Fietkau <nbd@openwrt.org>";  echo "Architecture: brcm63xx"; echo "Installed-Size: 0"; echo -n "Description: "; . /home/pepe/trunk/include/shell.sh; getvar V_Package_libgcc_description | sed -e 's,^[[:space:]]*, ,g'; ) > /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc/CONTROL/control
chmod 644 /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc/CONTROL/control
. /home/pepe/trunk/include/shell.sh; (cd /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc/CONTROL;  )
ipkg-build -c -o 0 -g 0 /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc /home/pepe/trunk/bin/brcm63xx-musl/packages
Packaged contents of /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libgcc into /home/pepe/trunk/bin/brcm63xx-musl/packages/libgcc_4.8-linaro-1_brcm63xx.ipk
mkdir -p /home/pepe/trunk/bin/brcm63xx-musl/packages /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libc/CONTROL /home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/pkginfo
install -d -m0755 /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libc/lib
cp -fpR /home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/lib/ld-musl-*.so* /home/pepe/trunk/build_dir/target-mips_musl-0.9.10/toolchain/ipkg-brcm63xx/libc/lib/
cp: cannot stat `/home/pepe/trunk/staging_dir/toolchain-mips_gcc-4.8-linaro_musl-0.9.10/lib/ld-musl-*.so*': No such file or directory
make[3]: *** [/home/pepe/trunk/bin/brcm63xx-musl/packages/libc_0.9.10-1_brcm63xx.ipk] Error 1
make[3]: Leaving directory `/home/pepe/trunk/package/libs/toolchain'
make[2]: *** [package/libs/toolchain/compile] Error 2
make[2]: Leaving directory `/home/pepe/trunk'
make[1]: *** [/home/pepe/trunk/staging_dir/target-mips_musl-0.9.10/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/pepe/trunk'
make: *** [world] Error 2

Is there any recommended linux distribution to compile with musl? Or any needed or recommended?

comment:28 Changed 4 years ago by florian

This issue is known, there is no need in reporting it again and again, as I explained before there is some kind of race condition in the musl build system which prevents the generation of the ld-musl-*arch*.so symlink.

comment:29 Changed 4 years ago by nbd

  • Resolution set to wontfix
  • Status changed from accepted to closed

musl marked as broken in r37750
it probably needs some more time to stabilize and become usable for openwrt

Changed 3 years ago by anonymous

updated patch for gcc-4.8-linaro musl build

comment:30 Changed 3 years ago by scottvalen@…

  • Resolution wontfix deleted
  • Status changed from closed to reopened

here are two issues with the current musl package.

For the first issue (build), gcc-final is clobbering the symlink for ld-musl-*-.so.1 via ldconfig. Essentially, the link is broken on most build hosts because it uses an absolute path to "/lib/libc.so", so ldconfig just decides to delete it.

The second issue (kernel panic) is platform specific, probably when building big endian or hard float variants, as the current gcc patch for musl support doesn't account for the name variations of the dynamic linker. Essentially, when the system boots and starts init, it ends up looking for a dynamic linker like ld-musl-arm.so.1, when the installed linker is ld-musl-armhf.so.1, causing init to crash and the kernel to panic.

I've attached an updated patch that fixes the second issue and adds support for other platforms from the set maintained here: https://github.com/GregorR/musl-gcc-patches

I'm not really sure what to do about the first issue, maybe just reinstall musl after gcc-final? Anyhow, I am going to run another build using a relative symlink (i.e. ./libc.so) and see if that causes any trouble and report back.

I'm just reopening this to ping the ticket owner.

comment:31 Changed 3 years ago by nbd

the first issue should be fixed in r42480, please test.

Changed 3 years ago by scottvalen@…

simple patch to fix musl build issue

comment:32 Changed 3 years ago by scottvalen@…

I've added another patch, for the musl package this time. This just adjusts the installation of the dynamic linker symlink to use a relative rather than absolute path. The build completes with out error and the image boots fine.

comment:33 Changed 3 years ago by scottvalen@…

Oh, clever approach. No point in running ldconfig in the first place. I'll check out the tree and test the build.

Changed 3 years ago by scottvalen@…

updated patch for gcc-4.8-0 (not linaro) musl build

comment:34 Changed 3 years ago by scottvalen@…

The arm hard float builds and runs fine with your update, but it does need the gcc patch to properly identify the dynamic linker (otherwise no dynamic executable can load). I also added another patch for the stock gcc compiler and tested out a build on an ar71xx target (mips, big endian). It also builds fine but init still crashes. I'm fairly certain that doesn't have to do with the dynamic linker name. The stock compiler with the second patch also builds the arm target fine, so it seems likely to be an issue with mips and musl.

My apologies for the double attachment, I uploaded the in-tree patch accidently. gcc-4.8.0-200-musl.v2.patch is the correct one.

Changed 3 years ago by scottvalen@…

ignore previous, this is the correct patch

comment:35 Changed 3 years ago by scottvalen@…

I believe I found the problem with the mips build. I'm building a soft-float target, so it is expecting ld-musl-mips-sf.so.1 as the dynamic linker. Actually, here are all the targets that are generated by musl's configure script:

mips64, powerpc64 (unsupported)
arm, armeb, armhf, armebhf
i386, x32, x86_64
mips, mipsel, mips-sf, mipsel-sf
microblaze, microblazeel
or1k
powerpc
sh, sheb, sh-nofpu, sheb-nofpu

I will post another patch set for gcc after further testing.

Changed 3 years ago by scottvalen@…

updated patch for gcc-4.8-0 musl build, fixes sh and mips soft-float targets

Changed 3 years ago by scottvalen@…

updated patch for gcc-4.8-linaro musl build, fixes sh and mips soft-float targets

comment:36 Changed 3 years ago by scottvalen@…

The previous two attachments can be dropped in to replace the current 200-musl.patch in the respective toolchain/gcc/patches directory. I can confirm that mips-sf and armhf targets build and boot properly. I also fixed the sh-nofpu targets, but I can't confirm that they will work.

comment:37 Changed 3 years ago by scottvalen@…

The previous two attachments can be dropped in to replace the current 200-musl.patch in the respective toolchain/gcc/patches directory. I can confirm that mips-sf and armhf targets build and boot properly. I also fixed the sh-nofpu targets, but I can't confirm that they will work.

comment:38 Changed 3 years ago by nbd

  • Resolution set to fixed
  • Status changed from reopened to closed

fixed in r42969, r42970

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.