queer / boxxy

boxxy puts bad Linux applications in a box with only their files.
MIT License
1.59k stars 25 forks source link

ARM support #37

Open PaddiM8 opened 1 year ago

PaddiM8 commented 1 year ago

Would it be possible to support ARM64? Doesn't seem to compile on Asahi Linux.

queer commented 1 year ago

Some support for splitting up architecture-specific code was added in #36; I don't know if ARM64 is doable right now because I don't have an ARM machine to test with, and cross-compiling is giving me a hell of a time locally. I'm open to PRs for it tho!

SuperSandro2000 commented 1 year ago

I just ran cross compilation with nix and got the following

$ NIXPKGS_ALLOW_BROKEN=1 nix build .#pkgsCross.aarch64-multiplatform.boxxy --impure
unpacking sources
unpacking source archive /nix/store/hkln0r8d0fknd2jbcr8kkxi4js35yd3k-source
source root is source
Executing cargoSetupPostUnpackHook
unpacking source archive /nix/store/s05iw7rz44536wswyfnafilmjs269ici-boxxy-0.6.3-vendor.tar.gz
Finished cargoSetupPostUnpackHook
patching sources
Executing cargoSetupPostPatchHook
Validating consistency between /build/source/Cargo.lock and /build/boxxy-0.6.3-vendor.tar.gz/Cargo.lock
Finished cargoSetupPostPatchHook
updateAutotoolsGnuConfigScriptsPhase
configuring
building
Executing cargoBuildHook
++ env CC_x86_64-unknown-linux-gnu=/nix/store/h5003wsy3qqimqvrkn3bc5mwq4hhidag-gcc-wrapper-12.2.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/h5003wsy3qqimqvrkn3bc5mwq4hhidag-gcc-wrapper-12.2.0/bin/c++ CC_aarch64-unknown-linux-gnu=/nix/store/gidaifwkxf341vg12q9v6hmsx5ll3hzl-aarch64-unknown-linux-gnu-stage-final-gcc-wrapper-12.2.0/bin/aarch64-unknown-linux-gnu-cc CXX_aarch64-unknown-linux-gnu=/nix/store/gidaifwkxf341vg12q9v6hmsx5ll3hzl-aarch64-unknown-linux-gnu-stage-final-gcc-wrapper-12.2.0/bin/aarch64-unknown-linux-gnu-c++ cargo build -j 40 --target aarch64-unknown-linux-gnu --frozen --release
   Compiling libc v0.2.140
   Compiling proc-macro2 v1.0.52
   Compiling unicode-ident v1.0.6
   Compiling quote v1.0.26
   Compiling cfg-if v1.0.0
   Compiling syn v1.0.107
   Compiling once_cell v1.17.0
   Compiling version_check v0.9.4
   Compiling memchr v2.5.0
   Compiling thiserror v1.0.38
   Compiling serde_derive v1.0.159
   Compiling serde v1.0.159
   Compiling autocfg v1.1.0
   Compiling bitflags v1.3.2
   Compiling cc v1.0.79
   Compiling lazy_static v1.4.0
   Compiling ucd-trie v0.1.5
   Compiling encoding_index_tests v0.1.4
   Compiling log v0.4.17
   Compiling regex-syntax v0.6.29
   Compiling pkg-config v0.3.26
   Compiling ryu v1.0.12
   Compiling adler v1.0.2
   Compiling tinyvec_macros v0.1.1
   Compiling crc32fast v1.3.2
   Compiling io-lifetimes v1.0.5
   Compiling serde_json v1.0.95
   Compiling itoa v1.0.5
   Compiling rustix v0.36.8
   Compiling pin-project-lite v0.2.9
   Compiling rustversion v1.0.11
   Compiling linked-hash-map v0.5.6
   Compiling is_ci v1.1.1
   Compiling heck v0.4.1
   Compiling quick-error v1.2.3
   Compiling dlv-list v0.3.0
   Compiling fnv v1.0.7
   Compiling semver v1.0.16
   Compiling tinyvec v1.6.0
   Compiling eyre v0.6.8
   Compiling bytemuck v1.13.0
   Compiling linux-raw-sys v0.1.4
   Compiling sharded-slab v0.1.4
   Compiling miniz_oxide v0.6.2
   Compiling same-file v1.0.6
   Compiling percent-encoding v2.2.0
   Compiling gimli v0.27.1
   Compiling termcolor v1.2.0
   Compiling tracing-core v0.1.30
   Compiling thread_local v1.1.5
   Compiling yaml-rust v0.4.5
   Compiling unicode-bidi v0.3.10
   Compiling async-trait v0.1.64
   Compiling rgb v0.8.35
   Compiling form_urlencoded v1.1.0
   Compiling walkdir v2.3.2
   Compiling humantime v1.3.0
   Compiling encoding-index-korean v1.20141219.5
   Compiling encoding-index-singlebyte v1.20141219.5
   Compiling encoding-index-japanese v1.20141219.5
   Compiling encoding-index-tradchinese v1.20141219.5
   Compiling encoding-index-simpchinese v1.20141219.5
   Compiling static_assertions v1.1.0
   Compiling ahash v0.7.6
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling minimal-lexical v0.2.1
   Compiling rustc-demangle v0.1.21
   Compiling indexmap v1.9.2
   Compiling memoffset v0.7.1
   Compiling indenter v0.3.3
   Compiling os_str_bytes v6.4.1
   Compiling std_prelude v0.2.12
   Compiling flate2 v1.0.25
   Compiling unicode-width v0.1.10
   Compiling pin-utils v0.1.0
   Compiling bat v0.23.0
   Compiling tracing v0.1.37
   Compiling base64 v0.13.1
   Compiling ansi_colours v1.2.1
   Compiling path_abs v0.5.1
   Compiling aho-corasick v0.7.20
   Compiling object v0.30.3
   Compiling bstr v1.2.0
   Compiling encoding v0.2.33
   Compiling content_inspector v0.2.4
   Compiling clap_lex v0.3.1
   Compiling nom v7.1.3
   Compiling unsafe-libyaml v0.2.7
   Compiling bytesize v1.1.0
   Compiling nu-ansi-term v0.47.0
   Compiling either v1.8.1
   Compiling strsim v0.10.0
   Compiling pathdiff v0.2.1
   Compiling bitflags v2.0.2
   Compiling syscall-numbers v3.0.0
   Compiling dotenv v0.15.0
   Compiling byteorder v1.4.3
   Compiling syn v2.0.3
   Compiling unicode-normalization v0.1.22
   Compiling tracing-subscriber v0.3.16
   Compiling onig_sys v69.8.1
   Compiling backtrace v0.3.67
   Compiling onig v6.4.0
   Compiling idna v0.3.0
   Compiling getrandom v0.2.8
   Compiling atty v0.2.14
   Compiling dirs-sys v0.4.0
   Compiling rand v0.4.6
   Compiling nix v0.26.2
   Compiling console v0.15.5
   Compiling rlimit v0.9.1
   Compiling which v4.4.0
   Compiling supports-color v1.3.1
   Compiling dirs v5.0.0
   Compiling owo-colors v3.5.0
   Compiling shellexpand v3.1.0
   Compiling hashbrown v0.12.3
   Compiling regex v1.7.3
   Compiling url v2.3.1
   Compiling tracing-error v0.2.0
   Compiling rand v0.3.23
   Compiling haikunator v0.1.2
   Compiling addr2line v0.19.0
   Compiling ordered-multimap v0.4.3
   Compiling color-spantrace v0.2.0
   Compiling rust-ini v0.18.0
   Compiling env_logger v0.7.1
   Compiling globset v0.4.10
   Compiling is-terminal v0.4.3
   Compiling pretty_env_logger v0.4.0
   Compiling color-eyre v0.6.2
   Compiling ctrlc v3.2.5
   Compiling thiserror-impl v1.0.38
   Compiling strum_macros v0.24.3
   Compiling clap_derive v4.1.9
   Compiling pest v2.5.5
   Compiling strum v0.24.1
   Compiling clap v4.1.11
   Compiling pest_meta v2.5.5
   Compiling pest_generator v2.5.5
   Compiling bincode v1.3.3
   Compiling serde_yaml v0.8.26
   Compiling ron v0.7.1
   Compiling toml v0.5.11
   Compiling clircle v0.3.0
   Compiling serde_yaml v0.9.19
   Compiling pest_derive v2.5.5
   Compiling json5 v0.4.1
   Compiling dotenv-parser v0.1.3
   Compiling syntect v5.0.0
   Compiling config v0.13.3
   Compiling boxxy v0.6.3 (/build/source)
error: The current architecture is unsupported!
  --> src/enclosure/syscall/mod.rs:26:9
   |
26 |         compile_error!("The current architecture is unsupported!");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved import `super::register::StringRegister`
  --> src/enclosure/tracer.rs:13:54
   |
13 | use super::register::{syscall_number_from_user_regs, StringRegister};
   |                                                      ^^^^^^^^^^^^^^ no `StringRegister` in `enclosure::register`

error[E0432]: unresolved import `syscall_number_from_user_regs`
  --> src/enclosure/register.rs:17:16
   |
17 | pub(crate) use syscall_number_from_user_regs;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no external crate `syscall_number_from_user_regs`

error[E0432]: unresolved import `super::syscall::Syscall`
  --> src/enclosure/tracer.rs:14:5
   |
14 | use super::syscall::Syscall;
   |     ^^^^^^^^^^^^^^^^^^^^^^^ no `Syscall` in `enclosure::syscall`

error: cannot determine resolution for the macro `syscall_number_from_user_regs`
   --> src/enclosure/tracer.rs:232:52
    |
232 |             syscall_numbers::native::sys_call_name(syscall_number_from_user_regs!(regs) as i64)
    |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error[E0425]: cannot find function `handle_syscall` in module `super::syscall`
   --> src/enclosure/tracer.rs:221:48
    |
221 |         if let Some(syscall) = super::syscall::handle_syscall(self, pid)? {
    |                                                ^^^^^^^^^^^^^^ not found in `super::syscall`

error[E0425]: cannot find function `getregs` in module `ptrace`
   --> src/enclosure/tracer.rs:270:17
    |
270 |         ptrace::getregs(self.pid).map_err(|e| e.into())
    |                 ^^^^^^^ not found in `ptrace`

warning: unused macro definition: `string_registers`
 --> src/enclosure/register.rs:1:14
  |
1 | macro_rules! string_registers {
  |              ^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_macros)]` on by default

Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
warning: `boxxy` (bin "boxxy") generated 1 warning
error: could not compile `boxxy` due to 7 previous errors; 1 warning emitted
queer commented 1 year ago

@SuperSandro2000 Yes, the architecture-specific code will currently raise if you build it on any platform other than x86_64. The correct fix to this would be any of

I'm open to PRs for any of these if anyone wants to open one at some point. I'm not currently in a position where I'm capable of dedicating time to this, and I don't know when that'll change.

kxxt commented 1 year ago

Adding ARM64 support should be easy with the following steps:

I have already ported the ptrace feature to architectures that support PTRACE_GETREGSET. (Most platforms support this) So only the register and syscall parts need porting.

My riscv64 support PR(#52) can be taken as a reference.