Skip to content

Commit

Permalink
Merge pull request #4086 from tgross35/misc-sync
Browse files Browse the repository at this point in the history
[0.2] Small sync fixes and backports
  • Loading branch information
tgross35 authored Nov 18, 2024
2 parents 7c64d5d + a00d7e6 commit 1c913e7
Show file tree
Hide file tree
Showing 20 changed files with 445 additions and 36 deletions.
30 changes: 8 additions & 22 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output {

cmd.arg("--version");

let output = cmd.output().ok().expect("Failed to get rustc version");
let output = cmd.output().expect("Failed to get rustc version");

if !output.status.success() {
panic!(
Expand Down Expand Up @@ -187,20 +187,14 @@ fn rustc_minor_nightly() -> (u32, bool) {
}

fn which_freebsd() -> Option<i32> {
let output = std::process::Command::new("freebsd-version").output().ok();
if output.is_none() {
return None;
}
let output = output.unwrap();
let output = std::process::Command::new("freebsd-version")
.output()
.ok()?;
if !output.status.success() {
return None;
}

let stdout = String::from_utf8(output.stdout).ok();
if stdout.is_none() {
return None;
}
let stdout = stdout.unwrap();
let stdout = String::from_utf8(output.stdout).ok()?;

match &stdout {
s if s.starts_with("10") => Some(10),
Expand All @@ -217,24 +211,16 @@ fn emcc_version_code() -> Option<u64> {
let output = std::process::Command::new("emcc")
.arg("-dumpversion")
.output()
.ok();
if output.is_none() {
return None;
}
let output = output.unwrap();
.ok()?;
if !output.status.success() {
return None;
}

let stdout = String::from_utf8(output.stdout).ok();
if stdout.is_none() {
return None;
}
let version = stdout.unwrap();
let version = String::from_utf8(output.stdout).ok()?;

// Some Emscripten versions come with `-git` attached, so split the
// version string also on the `-` char.
let mut pieces = version.trim().split(|c| c == '.' || c == '-');
let mut pieces = version.trim().split(['.', '-']);

let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
Expand Down
2 changes: 1 addition & 1 deletion ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ about above), and then shut down.
poweroff

1. Exit the post install shell: `exit`
1. Back in in the installer choose Reboot
1. Back in the installer choose Reboot
1. If all went well the machine should reboot and show a login prompt. If you
switch to the serial console by choosing View > serial0 in the qemu menu,
you should be logged in as root.
Expand Down
10 changes: 9 additions & 1 deletion ci/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rustfmt -V
cargo fmt --all -- --check

if shellcheck --version ; then
find . -name '*.sh' -exec shellcheck {} ';'
find . -name '*.sh' -print0 | xargs -0 shellcheck
else
echo "shellcheck not found"
exit 1
Expand All @@ -29,4 +29,12 @@ for file in libc-test/semver/*.txt; do
echo "Unsorted semver file $file"
exit 1
fi

duplicates=$(uniq -d "$file")
if [ -n "$duplicates" ]; then
echo "Semver file $file contains duplicates:"
echo "$duplicates"

exit 1
fi
done
37 changes: 34 additions & 3 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ fn test_apple(target: &str) {
"netinet/ip.h",
"netinet/tcp.h",
"netinet/udp.h",
"netinet6/in6_var.h",
"os/clock.h",
"os/lock.h",
"os/signpost.h",
Expand Down Expand Up @@ -401,6 +402,7 @@ fn test_apple(target: &str) {
("__darwin_arm_neon_state64", "__v") => true,

("ifreq", "ifr_ifru") => true,
("in6_ifreq", "ifr_ifru") => true,
("ifkpi", "ifk_data") => true,
("ifconf", "ifc_ifcu") => true,
// FIXME: this field has been incorporated into a resized `rmx_filler` array.
Expand Down Expand Up @@ -1789,6 +1791,8 @@ fn test_android(target: &str) {
"linux/netfilter/nfnetlink_log.h",
"linux/netfilter/nfnetlink_queue.h",
"linux/netfilter/nf_tables.h",
"linux/netfilter_arp.h",
"linux/netfilter_bridge.h",
"linux/netfilter_ipv4.h",
"linux/netfilter_ipv6.h",
"linux/netfilter_ipv6/ip6_tables.h",
Expand Down Expand Up @@ -1858,6 +1862,7 @@ fn test_android(target: &str) {

// These are tested in the `linux_elf.rs` file.
"Elf64_Phdr" | "Elf32_Phdr" => true,

// These are intended to be opaque
"posix_spawn_file_actions_t" => true,
"posix_spawnattr_t" => true,
Expand Down Expand Up @@ -2463,7 +2468,7 @@ fn test_freebsd(target: &str) {
true
}

// Added in in FreeBSD 13.0 (r367776 and r367287)
// Added in FreeBSD 13.0 (r367776 and r367287)
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,

// Added in FreeBSD 14
Expand Down Expand Up @@ -2593,6 +2598,13 @@ fn test_freebsd(target: &str) {
true
}

// Added in FreeBSD 14.1
"KCMP_FILE" | "KCMP_FILEOBJ" | "KCMP_FILES" | "KCMP_SIGHAND" | "KCMP_VM"
if Some(14) > freebsd_ver =>
{
true
}

// FIXME: Removed in FreeBSD 15:
"LOCAL_CONNWAIT" if freebsd_ver >= Some(15) => true,

Expand Down Expand Up @@ -2713,6 +2725,9 @@ fn test_freebsd(target: &str) {
true
}

// Those are introduced in FreeBSD 14.1.
"kcmp" => true,

_ => false,
}
});
Expand Down Expand Up @@ -3591,6 +3606,8 @@ fn test_linux(target: &str) {
"linux/netfilter/nfnetlink_log.h",
"linux/netfilter/nfnetlink_queue.h",
"linux/netfilter/nf_tables.h",
"linux/netfilter_arp.h",
"linux/netfilter_bridge.h",
"linux/netfilter_ipv4.h",
"linux/netfilter_ipv6.h",
"linux/netfilter_ipv6/ip6_tables.h",
Expand Down Expand Up @@ -3678,6 +3695,14 @@ fn test_linux(target: &str) {
});

cfg.skip_type(move |ty| {
// FIXME: very recent additions to musl, not yet released.
// also apparently some glibc versions
if ty == "Elf32_Relr" || ty == "Elf64_Relr" {
return true;
}
if sparc64 && (ty == "Elf32_Rela" || ty == "Elf64_Rela") {
return true;
}
match ty {
// FIXME: `sighandler_t` type is incorrect, see:
// https://github.com/rust-lang/libc/issues/1359
Expand Down Expand Up @@ -4112,9 +4137,15 @@ fn test_linux(target: &str) {
| "MINSIGSTKSZ"
if gnu => true,

// FIXME: Linux >= 5.16 changed its value:
// FIXME: Linux >= 5.10:
// https://github.com/torvalds/linux/commit/d25e2e9388eda61b6e298585024ee3355f50c493
"NF_INET_INGRESS" if musl => true,

// FIXME: Linux >= 5.16:
// https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96
"NF_NETDEV_NUMHOOKS" => true,
"NF_NETDEV_EGRESS" if musl || sparc64 => true,
// value changed
"NF_NETDEV_NUMHOOKS" if musl || sparc64 => true,

// FIXME: requires Linux >= 5.6:
| "RESOLVE_BENEATH"
Expand Down
2 changes: 1 addition & 1 deletion libc-test/semver/TODO-linux.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The following symbols are not not available in some combinations of
# The following symbols are not available in some combinations of
# musl/gnu/android and/or architecture.
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
Expand Down
27 changes: 24 additions & 3 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@



ABS_CNT
ABS_MAX
ADDR_COMPAT_LAYOUT
Expand Down Expand Up @@ -1692,8 +1689,29 @@ NFULNL_COPY_PACKET
NFULNL_MSG_CONFIG
NFULNL_MSG_PACKET
NF_ACCEPT
NF_ARP
NF_ARP_FORWARD
NF_ARP_IN
NF_ARP_NUMHOOKS
NF_ARP_OUT
NF_BR_BROUTING
NF_BR_FORWARD
NF_BR_LOCAL_IN
NF_BR_LOCAL_OUT
NF_BR_NUMHOOKS
NF_BR_POST_ROUTING
NF_BR_PRE_ROUTING
NF_BR_PRI_BRNF
NF_BR_PRI_FILTER_BRIDGED
NF_BR_PRI_FILTER_OTHER
NF_BR_PRI_FIRST
NF_BR_PRI_LAST
NF_BR_PRI_NAT_DST_BRIDGED
NF_BR_PRI_NAT_DST_OTHER
NF_BR_PRI_NAT_SRC
NF_DROP
NF_INET_FORWARD
NF_INET_INGRESS
NF_INET_LOCAL_IN
NF_INET_LOCAL_OUT
NF_INET_NUMHOOKS
Expand All @@ -1715,6 +1733,7 @@ NF_IP6_PRI_MANGLE
NF_IP6_PRI_NAT_DST
NF_IP6_PRI_NAT_SRC
NF_IP6_PRI_RAW
NF_IP6_PRI_RAW_BEFORE_DEFRAG
NF_IP6_PRI_SECURITY
NF_IP6_PRI_SELINUX_FIRST
NF_IP6_PRI_SELINUX_LAST
Expand All @@ -1735,10 +1754,12 @@ NF_IP_PRI_MANGLE
NF_IP_PRI_NAT_DST
NF_IP_PRI_NAT_SRC
NF_IP_PRI_RAW
NF_IP_PRI_RAW_BEFORE_DEFRAG
NF_IP_PRI_SECURITY
NF_IP_PRI_SELINUX_FIRST
NF_IP_PRI_SELINUX_LAST
NF_MAX_VERDICT
NF_NETDEV_EGRESS
NF_NETDEV_INGRESS
NF_NETDEV_NUMHOOKS
NF_QUEUE
Expand Down
5 changes: 5 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,7 @@ globfree
host_cpu_load_info
host_cpu_load_info_data_t
host_cpu_load_info_t
icmp6_ifstat
iconv
iconv_close
iconv_open
Expand All @@ -2018,6 +2019,9 @@ ifconf
ifkpi
ifreq
image_offset
in6_addrlifetime
in6_ifreq
in6_ifstat
in6_pktinfo
in_pktinfo
initgroups
Expand Down Expand Up @@ -2338,6 +2342,7 @@ timeval32
timex
truncate
ttyname_r
u_quad_t
ucontext_t
unmount
useconds_t
Expand Down
6 changes: 6 additions & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,11 @@ JAIL_SYS_DISABLE
JAIL_SYS_INHERIT
JAIL_SYS_NEW
JAIL_UPDATE
KCMP_FILE
KCMP_FILEOBJ
KCMP_FILES
KCMP_SIGHAND
KCMP_VM
KENV_DUMP
KENV_DUMP_LOADER
KENV_DUMP_STATIC
Expand Down Expand Up @@ -2007,6 +2012,7 @@ jail_get
jail_remove
jail_set
jrand48
kcmp
kevent
key_t
killpg
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-aarch64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ BPF_W
BPF_X
BPF_XOR
CIBAUD
Elf32_Rela
Elf64_Rela
FICLONE
FICLONERANGE
MADV_SOFT_OFFLINE
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-i686.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ EFL
EIP
ES
ESI
Elf32_Rela
Elf64_Rela
FS
GS
KEYCTL_CAPABILITIES
Expand Down
6 changes: 6 additions & 0 deletions libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ copy_file_range
ctermid
dirname
eaccess
endutxent
euidaccess
explicit_bzero
futimes
getauxval
getloadavg
getutxent
getutxid
getutxline
lio_listio
ntptimeval
open_wmemstream
Expand All @@ -94,8 +98,10 @@ prlimit
prlimit64
process_vm_readv
process_vm_writev
pututxline
pwritev2
pwritev64
reallocarray
setutxent
tcp_info
timex
2 changes: 2 additions & 0 deletions libc-test/semver/linux-powerpc64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ B2500000
B3000000
B3500000
B4000000
Elf32_Rela
Elf64_Rela
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
KEYCTL_CAPS0_CAPABILITIES
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-riscv64gc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ COMPAT_HWCAP_ISA_F
COMPAT_HWCAP_ISA_I
COMPAT_HWCAP_ISA_M
COMPAT_HWCAP_ISA_V
Elf32_Rela
Elf64_Rela
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
KEYCTL_CAPS0_CAPABILITIES
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ CIBAUD
CS
DS
ES
Elf32_Rela
Elf64_Rela
FS
GS
MADV_SOFT_OFFLINE
Expand Down
Loading

0 comments on commit 1c913e7

Please sign in to comment.