rustybox
rustybox copied to clipboard
Static / musl build
I get the build working with a glibc based Host and nightly channel.
But it isn't static and it should be musl linux target.
-
Is it possible to build for musl target? Musl host build fails I know. So I would try to build on a glibc host with musl target. Should that work?
-
Or how else I could build a small static binary?
After some testing it looks like rustybox can't build static?
# ldd /rustybox/target/x86_64-unknown-linux-gnu/release/rustybox
linux-vdso.so.1 (0x00007ffcaffaf000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f3ff2477000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3ff2472000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3ff2468000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3ff2447000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3ff242d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3ff226c000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3ff20e7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3ff25ee000)
In order to get a completely static binary, you'll need to use the x86_64-unknown-linux-musl
target instead of x86_64-unknown-linux-gnu
: https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html. I'm not sure that rustybox will immediately compile this way, but it'd be great if we could get it compiling with MUSL!
Tried it:
|
396 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
397 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
398 | | | (7i32 << 0) as libc::c_uint
399 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
396 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
397 | | (0xabi32 << 0 + 8i32) as libc::c_uint
398 | | (7i32 << 0) as libc::c_uint
399 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:404:9
|
404 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
405 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
406 | | | (4i32 << 0) as libc::c_uint
407 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
404 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
405 | | (0xabi32 << 0 + 8i32) as libc::c_uint
406 | | (4i32 << 0) as libc::c_uint
407 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:523:9
|
523 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
524 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
525 | | | (1i32 << 0) as libc::c_uint
526 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
523 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
524 | | (0xabi32 << 0 + 8i32) as libc::c_uint
525 | | (1i32 << 0) as libc::c_uint
526 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:531:9
|
531 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
532 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
533 | | | (7i32 << 0) as libc::c_uint
534 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
531 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
532 | | (0xabi32 << 0 + 8i32) as libc::c_uint
533 | | (7i32 << 0) as libc::c_uint
534 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:539:9
|
539 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
540 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
541 | | | (4i32 << 0) as libc::c_uint
542 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
539 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
540 | | (0xabi32 << 0 + 8i32) as libc::c_uint
541 | | (4i32 << 0) as libc::c_uint
542 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:546:9
|
546 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
547 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
548 | | | (10i32 << 0) as libc::c_uint
549 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
546 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
547 | | (0xabi32 << 0 + 8i32) as libc::c_uint
548 | | (10i32 << 0) as libc::c_uint
549 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:589:7
|
589 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
590 | | | (0x12i32 << 0 + 8i32) as libc::c_uint
591 | | | (93i32 << 0) as libc::c_uint
592 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_____________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
589 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
590 | | (0x12i32 << 0 + 8i32) as libc::c_uint
591 | | (93i32 << 0) as libc::c_uint
592 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:603:9
|
603 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
604 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
605 | | | (9i32 << 0) as libc::c_uint
606 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
603 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
604 | | (0xabi32 << 0 + 8i32) as libc::c_uint
605 | | (9i32 << 0) as libc::c_uint
606 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:617:7
|
617 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
618 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
619 | | | (0i32 << 0) as libc::c_uint
620 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_____________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
617 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
618 | | (0xabi32 << 0 + 8i32) as libc::c_uint
619 | | (0i32 << 0) as libc::c_uint
620 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:664:7
|
664 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
665 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
666 | | | (3i32 << 0) as libc::c_uint
667 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_____________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
664 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
665 | | (0xabi32 << 0 + 8i32) as libc::c_uint
666 | | (3i32 << 0) as libc::c_uint
667 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:674:9
|
674 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
675 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
676 | | | (5i32 << 0) as libc::c_uint
677 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
674 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
675 | | (0xabi32 << 0 + 8i32) as libc::c_uint
676 | | (5i32 << 0) as libc::c_uint
677 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> networking/nbd_client.rs:681:9
|
681 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
682 | | | (0xabi32 << 0 + 8i32) as libc::c_uint
683 | | | (4i32 << 0) as libc::c_uint
684 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_______________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
681 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
682 | | (0xabi32 << 0 + 8i32) as libc::c_uint
683 | | (4i32 << 0) as libc::c_uint
684 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ispeed`
--> networking/slattach.rs:82:5
|
82 | c_ispeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ispeed`
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ospeed`
--> networking/slattach.rs:83:5
|
83 | c_ospeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ospeed`
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ispeed`
--> networking/slattach.rs:138:5
|
138 | c_ispeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ispeed`
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ospeed`
--> networking/slattach.rs:139:5
|
139 | c_ospeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ospeed`
error[E0308]: mismatched types
--> networking/slattach.rs:295:13
|
295 | 0x5415i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
295 | (0x5415i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> networking/telnetd.rs:348:17
|
348 | 0x5414i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
348 | (0x5414i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ispeed`
--> networking/telnetd.rs:475:5
|
475 | c_ispeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ispeed`
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ospeed`
--> networking/telnetd.rs:476:5
|
476 | c_ospeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ospeed`
error[E0308]: mismatched types
--> networking/udhcp/d6_socket.rs:348:18
|
348 | if ioctl(fd, 0x8933i32 as libc::c_ulong, &mut ifr as *mut ifreq) == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
348 | if ioctl(fd, (0x8933i32 as libc::c_ulong).try_into().unwrap(), &mut ifr as *mut ifreq) == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> procps/uptime.rs:39:21
|
39 | current_secs -= info.uptime
| ^^^^^^^^^^^ expected `i64`, found `u64`
error[E0277]: cannot subtract-assign `u64` from `i64`
--> procps/uptime.rs:39:18
|
39 | current_secs -= info.uptime
| ^^ no implementation for `i64 -= u64`
|
= help: the trait `std::ops::SubAssign<u64>` is not implemented for `i64`
error[E0308]: mismatched types
--> shell/cttyhack.rs:170:7
|
170 | VT_GETSTATE as libc::c_int as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
170 | (VT_GETSTATE as libc::c_int as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> shell/cttyhack.rs:182:7
|
182 | 0x541ei32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
182 | (0x541ei32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> shell/cttyhack.rs:229:19
|
229 | ioctl(0i32, 0x540ei32 as libc::c_ulong, 1i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
229 | ioctl(0i32, (0x540ei32 as libc::c_ulong).try_into().unwrap(), 1i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/blockdev.rs:172:5
|
172 | bdcmd_ioctl[bdcmd as usize] as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
172 | (bdcmd_ioctl[bdcmd as usize] as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/eject.rs:75:5
|
75 | 0x2282i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
75 | (0x2282i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/eject.rs:112:5
|
112 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
113 | | | (0x12i32 << 0 + 8i32) as libc::c_uint
114 | | | (95i32 << 0) as libc::c_uint
115 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |___________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
112 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
113 | | (0x12i32 << 0 + 8i32) as libc::c_uint
114 | | (95i32 << 0) as libc::c_uint
115 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> util_linux/eject.rs:121:57
|
121 | || flags & 2i32 as libc::c_uint != 0 && ioctl(3i32, 0x5326i32 as libc::c_ulong) == 2i32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
121 | || flags & 2i32 as libc::c_uint != 0 && ioctl(3i32, (0x5326i32 as libc::c_ulong).try_into().unwrap()) == 2i32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/fdisk.rs:441:5
|
441 | / (2u32 << 0 + 8i32 + 8i32 + 14i32
442 | | | (0x12i32 << 0 + 8i32) as libc::c_uint
443 | | | (114i32 << 0) as libc::c_uint) as libc::c_ulong
444 | | | (::std::mem::size_of::<size_t>() as libc::c_ulong) << 0 + 8i32 + 8i32,
| |_____________________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
441 | ((2u32 << 0 + 8i32 + 8i32 + 14i32
442 | | (0x12i32 << 0 + 8i32) as libc::c_uint
443 | | (114i32 << 0) as libc::c_uint) as libc::c_ulong
444 | | (::std::mem::size_of::<size_t>() as libc::c_ulong) << 0 + 8i32 + 8i32).try_into().unwrap(),
|
error[E0308]: mismatched types
--> util_linux/fdisk.rs:459:7
|
459 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
460 | | | (0x12i32 << 0 + 8i32) as libc::c_uint
461 | | | (96i32 << 0) as libc::c_uint
462 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_____________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
459 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
460 | | (0x12i32 << 0 + 8i32) as libc::c_uint
461 | | (96i32 << 0) as libc::c_uint
462 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> util_linux/fdisk.rs:1134:7
|
1134 | / (0u32 << 0 + 8i32 + 8i32 + 14i32
1135 | | | (0x12i32 << 0 + 8i32) as libc::c_uint
1136 | | | (104i32 << 0) as libc::c_uint
1137 | | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong,
| |_____________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
1134 | ((0u32 << 0 + 8i32 + 8i32 + 14i32
1135 | | (0x12i32 << 0 + 8i32) as libc::c_uint
1136 | | (104i32 << 0) as libc::c_uint
1137 | | (0i32 << 0 + 8i32 + 8i32) as libc::c_uint) as libc::c_ulong).try_into().unwrap(),
|
error[E0308]: mismatched types
--> util_linux/fdisk.rs:1160:5
|
1160 | 0x301i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
1160 | (0x301i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/fdisk.rs:3259:7
|
3259 | 0x301i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
3259 | (0x301i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/mkfs_vfat.rs:338:5
|
338 | 0x301i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
338 | (0x301i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/mkfs_vfat.rs:352:7
|
352 | / (2u32 << 0 + 8i32 + 8i32 + 14i32
353 | | | (2i32 << 0 + 8i32) as libc::c_uint
354 | | | (0x4i32 << 0) as libc::c_uint) as libc::c_ulong
355 | | | (::std::mem::size_of::<floppy_struct>() as libc::c_ulong) << 0 + 8i32 + 8i32,
| |______________________________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
352 | ((2u32 << 0 + 8i32 + 8i32 + 14i32
353 | | (2i32 << 0 + 8i32) as libc::c_uint
354 | | (0x4i32 << 0) as libc::c_uint) as libc::c_ulong
355 | | (::std::mem::size_of::<floppy_struct>() as libc::c_ulong) << 0 + 8i32 + 8i32).try_into().unwrap(),
|
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ispeed`
--> util_linux/script.rs:150:5
|
150 | c_ispeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ispeed`
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ospeed`
--> util_linux/script.rs:151:5
|
151 | c_ospeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ospeed`
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ispeed`
--> util_linux/script.rs:160:5
|
160 | c_ispeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ispeed`
error[E0560]: struct `libc::unix::linux_like::linux::musl::termios` has no field named `c_ospeed`
--> util_linux/script.rs:161:5
|
161 | c_ospeed: 0,
| ^^^^^^^^ help: a field with a similar name exists: `__c_ospeed`
error[E0308]: mismatched types
--> util_linux/script.rs:221:5
|
221 | 0x5413i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
221 | (0x5413i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/script.rs:410:7
|
410 | 0x5414i32 as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
410 | (0x5414i32 as libc::c_ulong).try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/script.rs:416:15
|
416 | ioctl(0i32, 0x540ei32 as libc::c_ulong, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
416 | ioctl(0i32, (0x540ei32 as libc::c_ulong).try_into().unwrap(), 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/setsid.rs:77:17
|
77 | ioctl(0i32, 0x540ei32 as libc::c_ulong, 1i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
77 | ioctl(0i32, (0x540ei32 as libc::c_ulong).try_into().unwrap(), 1i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> util_linux/volume_id/get_devname.rs:70:5
|
70 | / (2u32 << 0 + 8i32 + 8i32 + 14i32
71 | | | (0x12i32 << 0 + 8i32) as libc::c_uint
72 | | | (114i32 << 0) as libc::c_uint) as libc::c_ulong
73 | | | (::std::mem::size_of::<size_t>() as libc::c_ulong) << 0 + 8i32 + 8i32,
| |_____________________________________________________________________________^ expected `i32`, found `u64`
|
help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit
|
70 | ((2u32 << 0 + 8i32 + 8i32 + 14i32
71 | | (0x12i32 << 0 + 8i32) as libc::c_uint
72 | | (114i32 << 0) as libc::c_uint) as libc::c_ulong
73 | | (::std::mem::size_of::<size_t>() as libc::c_ulong) << 0 + 8i32 + 8i32).try_into().unwrap(),
|
error: aborting due to 172 previous errors
Some errors have detailed explanations: E0277, E0308, E0432, E0560.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `rustybox`.
To learn more, run the command again with --verbose.
Dockerfile to try the build:
FROM rustlang/rust:nightly AS rustybox
RUN apt-get update && \
apt-get install -y \
musl-dev
RUN rustup target add x86_64-unknown-linux-musl --toolchain=nightly
RUN git clone https://github.com/samuela/rustybox.git
WORKDIR /rustybox
ARG FEATURES=$FEATURES
ENV FEATURES=${FEATURES:-"--all-features"}
ENV RUSTFLAGS="-C target-feature=+crt-static"
RUN if [ "$FEATURES" = '--all-features' ]; then \
echo "Features:\n$FEATURES"; \
cargo build --target x86_64-unknown-linux-musl $FEATURES --release; \
# cargo build $FEATURES --release; \
else \
echo "Features:\n--features\n$FEATURES"; \
cargo build --target x86_64-unknown-linux-musl --features "$FEATURES" --release; \
# cargo build --features "$FEATURES" --release; \
fi
RUN strip /rustybox/target/release/rustybox
RUN /rustybox/target/release/rustybox
FROM scratch AS build
COPY --from=rustybox /rustybox/target/release/rustybox /bin/
RUN /bin/rustybox
Yeah, there will definitely be errors since this was c2rust'ed with glibc. But they should all be pretty similar and rustybox will be better for having them fixed!
Would be great to have a static rustybox working 👍
Most of the errors above seems to be because
- musl doesn't support some standard C functions or at least libc doesn't define them for musl
- the function has a different signature in musl than in glibc
The errors shown above are because ioctl
is defined as pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
in glibc but as pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
in musl.
The root cause is that c2rust preprocess C files and this makes them non-portable.
Also it seems that busybox need to be patched to build with musl (https://wiki.musl-libc.org/building-busybox.html), so I wouldn't expect to get rustybox working without the same patches.
I think your best bet would be to take busybox and patch it, then transpile it with c2rust and a musl libc/clang/llvm
Thanks for the pointers @kellda ! I wasn't aware that busybox had issues building with musl. Getting a static build working would be great. I think the main blocker is just going through and getting rid of extern "C"
crap in general... It all got transpiled out of c2rust that way and most of it can be replaced with more rust-friendly alternatives.
Hi, is there progress with rustybox / static musl build?
Hi, is there progress with rustybox / static musl build?
No, still in the same situation. OOC what do you need a static build for?
I would sugest taking a look at https://github.com/uutils/coreutils