Skip to content

Commit

Permalink
codegen: Generate for AArch64 illumos
Browse files Browse the repository at this point in the history
Split from PR 175.
  • Loading branch information
taiki-e committed Sep 7, 2024
1 parent ffb1569 commit 15afa46
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ elems
espup
exynos
getauxval
getisax
getpid
gimli
Halfword
Expand Down Expand Up @@ -116,6 +117,7 @@ RAII
rcpc
reentrancy
revidr
richlowe
rsbegin
rsend
rsil
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ jobs:

codegen:
needs: tidy
runs-on: ubuntu-latest
runs-on: ubuntu-24.04 # old clang doesn't support AArch64 illumos
timeout-minutes: 60
permissions:
contents: read
Expand Down
73 changes: 73 additions & 0 deletions tests/helper/src/gen/sys/aarch64_illumos/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/helper/src/gen/sys/aarch64_illumos/sys_auxv.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions tests/helper/src/gen/sys/aarch64_illumos/sys_auxv_aarch64.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions tests/helper/src/gen/sys/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions tools/codegen/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,34 @@ static TARGETS: &[Target] = &[
},
],
},
Target {
triples: &[
"aarch64-unknown-illumos",
],
headers: &[
Header {
// /~https://github.com/illumos/illumos-gate/blob/HEAD/usr/src/uts/common/sys/auxv.h
// /~https://github.com/richlowe/illumos-gate/blob/arm64-gate/usr/src/uts/common/sys/auxv.h
path: "sys/auxv.h",
types: &[],
vars: &[],
functions: &["getisax"],
arch: &[],
os: &[],
env: &[],
},
Header {
// /~https://github.com/richlowe/illumos-gate/blob/arm64-gate/usr/src/uts/common/sys/auxv_aarch64.h
path: "sys/auxv_aarch64.h",
types: &[],
vars: &["AV_AARCH64.*"],
functions: &[],
arch: &[aarch64],
os: &[],
env: &[],
},
],
},
Target {
triples: &[
"aarch64-unknown-fuchsia",
Expand Down Expand Up @@ -554,6 +582,14 @@ pub(crate) fn gen() -> Result<()> {
src_dir.join("lib/libpthread"),
];
}
illumos => {
header_path = src_dir.join("usr/src/uts/common").join(header.path);
include = vec![
src_dir.join("usr/src/uts/common"),
src_dir.join("usr/src/uts").join(illumos_arch(target)),
src_dir.join("usr/src/head"),
];
}
fuchsia => {
header_path = src_dir.join(header.path);
include = vec![
Expand Down Expand Up @@ -905,6 +941,14 @@ fn download_headers(target: &TargetSpec, download_dir: &Utf8Path) -> Result<Utf8
src_dir.join("include/machine"),
)?;
}
illumos => {
if target.arch == aarch64 {
// TODO: use illumos/illumos-gate once merged to upstream
src_dir = clone(download_dir, "richlowe/illumos-gate", &["/usr/"])?;
} else {
todo!("{target:?}")
}
}
fuchsia => {
src_dir = clone(download_dir, "https://fuchsia.googlesource.com/fuchsia", &[])?;
fs::write(src_dir.join("zircon/kernel/lib/libc/include/stdbool.h"), "")?;
Expand Down Expand Up @@ -1028,6 +1072,14 @@ fn openbsd_arch(target: &TargetSpec) -> &'static str {
_ => todo!("{target:?}"),
}
}
fn illumos_arch(target: &TargetSpec) -> &'static str {
// /~https://github.com/illumos/illumos-gate/tree/HEAD/usr/src/uts
// /~https://github.com/richlowe/illumos-gate/tree/arm64-gate/usr/src/uts
match target.arch {
aarch64 => "aarch64",
_ => todo!("{target:?}"),
}
}

fn target_spec_json(target: &str) -> Result<TargetSpec> {
let spec_path = workspace_root().join("target-specs").join(target).with_extension("json");
Expand Down

0 comments on commit 15afa46

Please sign in to comment.