Skip to content

Commit

Permalink
codegen: Generate for 32-bit PowerPC
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 22, 2025
1 parent 1ea5378 commit 2c3ceff
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ jobs:
done
"$@"
}
retry sudo apt-get -o Acquire::Retries=10 -qq update
retry sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabi \
gcc-powerpc64le-linux-gnu \
gcc-riscv64-linux-gnu \
apt_packages=(
gcc-aarch64-linux-gnu
gcc-arm-linux-gnueabi
# gcc-powerpc-linux-gnu # powerpc64le-linux-gnu-gcc -m32 -mbig-endian
# gcc-powerpc64-linux-gnu # powerpc64le-linux-gnu-gcc -mbig-endian
gcc-powerpc64le-linux-gnu
gcc-riscv64-linux-gnu
gettext
)
retry sudo apt-get -o Acquire::Retries=10 -qq update
retry sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends "${apt_packages[@]}"
- run: tools/gen.sh
- name: Handle diff
id: diff
Expand Down
13 changes: 13 additions & 0 deletions tools/codegen/patches/netbsd.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/sys/arch/powerpc/include/cpu.h b/sys/arch/powerpc/include/cpu.h
index cc9278867..3e8fce615 100644
--- a/sys/arch/powerpc/include/cpu.h
+++ b/sys/arch/powerpc/include/cpu.h
@@ -490,7 +490,7 @@ bool fix_unaligned(struct trapframe *, ksiginfo_t *);
#endif /* PPC_OEA64_BRIDGE */
#endif

-void __syncicache(void *, size_t);
+// void __syncicache(void *, size_t);

/*
* CTL_MACHDEP definitions.
33 changes: 27 additions & 6 deletions tools/codegen/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,25 @@ static TARGETS: &[Target] = &[
"aarch64_be-unknown-linux-gnu_ilp32",
"armv5te-unknown-linux-gnueabi",
"armeb-unknown-linux-gnueabi", // TODO: v6
"powerpc-unknown-linux-gnu",
"powerpc64-unknown-linux-gnu",
"powerpc64le-unknown-linux-gnu",
"riscv32gc-unknown-linux-gnu",
"riscv64gc-unknown-linux-gnu",
// Linux (musl)
"aarch64-unknown-linux-musl",
"armv5te-unknown-linux-musleabi",
"powerpc-unknown-linux-musl",
"powerpc64-unknown-linux-musl",
"powerpc64le-unknown-linux-musl",
"riscv32gc-unknown-linux-musl",
"riscv64gc-unknown-linux-musl",
// Linux (uClibc-ng)
"aarch64-unknown-linux-uclibc",
"armv5te-unknown-linux-uclibceabi",
// "powerpc-unknown-linux-uclibc",
// "riscv32gc-unknown-linux-uclibc",
// "riscv64gc-unknown-linux-uclibc",
// L4Re (uClibc-ng)
"aarch64-unknown-l4re-uclibc",
// Android
Expand All @@ -67,7 +72,7 @@ static TARGETS: &[Target] = &[
types: &[],
vars: &["PPC_FEATURE.*"],
functions: &[],
arch: &[powerpc64],
arch: &[powerpc, powerpc64],
os: &[],
env: &[],
},
Expand Down Expand Up @@ -212,6 +217,7 @@ static TARGETS: &[Target] = &[
triples: &[
"aarch64-unknown-freebsd",
"armv6-unknown-freebsd",
"powerpc-unknown-freebsd",
"powerpc64-unknown-freebsd",
"powerpc64le-unknown-freebsd",
"riscv64gc-unknown-freebsd",
Expand Down Expand Up @@ -273,7 +279,7 @@ static TARGETS: &[Target] = &[
types: &[],
vars: &["PPC_FEATURE.*"],
functions: &[],
arch: &[powerpc64],
arch: &[powerpc, powerpc64],
os: &[],
env: &[],
},
Expand All @@ -287,7 +293,7 @@ static TARGETS: &[Target] = &[
vars: &["HWCAP.*"],
functions: &[],
// TODO: riscv
arch: &[aarch64, arm, powerpc64],
arch: &[aarch64, arm, powerpc, powerpc64],
os: &[],
env: &[],
},
Expand All @@ -298,6 +304,7 @@ static TARGETS: &[Target] = &[
"aarch64-unknown-netbsd",
"aarch64_be-unknown-netbsd",
"armv6-unknown-netbsd-eabihf",
"powerpc-unknown-netbsd",
// "riscv64gc-unknown-netbsd",
],
headers: &[
Expand All @@ -315,8 +322,8 @@ static TARGETS: &[Target] = &[
// https://github.com/NetBSD/src/blob/HEAD/sys/sys/sysctl.h
path: "sys/sysctl.h",
types: &["sysctlnode"],
vars: &["CTL_QUERY", "SYSCTL_VERS_1", "SYSCTL_VERSION"],
functions: &["sysctlbyname"],
vars: &["CTL_MACHDEP", "CTL_QUERY", "SYSCTL_VERS_1", "SYSCTL_VERSION"],
functions: &["sysctl", "sysctlbyname"],
arch: &[],
os: &[],
env: &[],
Expand All @@ -331,12 +338,23 @@ static TARGETS: &[Target] = &[
os: &[],
env: &[],
},
Header {
// https://github.com/NetBSD/src/blob/HEAD/sys/arch/powerpc/include/cpu.h
path: "machine/cpu.h",
types: &[],
vars: &["CPU_.*"],
functions: &[],
arch: &[powerpc, powerpc64],
os: &[],
env: &[],
},
],
},
Target {
triples: &[
"aarch64-unknown-openbsd",
// "armv7-unknown-openbsd", // TODO: not in rustc
"powerpc-unknown-openbsd",
"powerpc64-unknown-openbsd",
"riscv64gc-unknown-openbsd",
],
Expand Down Expand Up @@ -374,6 +392,7 @@ static TARGETS: &[Target] = &[
Header {
// https://github.com/openbsd/src/blob/HEAD/sys/arch/arm64/include/cpu.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/arm/include/cpu.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/macppc/include/cpu.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/powerpc64/include/cpu.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/riscv64/include/cpu.h
path: "machine/cpu.h",
Expand All @@ -387,14 +406,15 @@ static TARGETS: &[Target] = &[
Header {
// https://github.com/openbsd/src/blob/HEAD/sys/arch/arm64/include/elf.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/arm/include/elf.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/powerpc/include/elf.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/powerpc64/include/elf.h
// https://github.com/openbsd/src/blob/HEAD/sys/arch/riscv64/include/elf.h
path: "machine/elf.h",
types: &[],
vars: &["HWCAP.*", "PPC_FEATURE.*"],
functions: &[],
// TODO: riscv
arch: &[aarch64, arm, powerpc64],
arch: &[aarch64, arm, powerpc, powerpc64],
os: &[],
env: &[],
},
Expand Down Expand Up @@ -779,6 +799,7 @@ pub(crate) fn generate() {
unknown_lints,
unnameable_types, // unnameable_types is available on Rust 1.79+
clippy::cast_sign_loss,
clippy::ptr_as_ptr,
clippy::pub_underscore_fields,
clippy::unnecessary_cast,
)]
Expand Down

0 comments on commit 2c3ceff

Please sign in to comment.