Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite loader.c in Rust #51

Merged
merged 9 commits into from
Aug 9, 2021
Merged

Rewrite loader.c in Rust #51

merged 9 commits into from
Aug 9, 2021

Conversation

imlk0
Copy link
Collaborator

@imlk0 imlk0 commented Aug 8, 2021

This PR contains the following main contents.

  • Rewriting loader.c in Rust, so that we can avoid dependencies on the additional gcc cross-compilation toolchain.
  • Converting to cargo workspace, with two packages, proot-rs and loader-shim.
  • Introducing cargo-make to manage the compilation tasks.

Closes: #36

@imlk0 imlk0 added this to the v0.0.1 milestone Aug 8, 2021
@imlk0 imlk0 requested a review from oxr463 August 8, 2021 15:53
@imlk0 imlk0 self-assigned this Aug 8, 2021
Copy link
Contributor

@oxr463 oxr463 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker-compose build
Building proot-rs-sdk
Step 1/6 : FROM rust:alpine as build
 ---> 2d0e5b6cc5bf
Step 2/6 : RUN apk update &&     apk add bash             bats             curl             shellcheck             openssl-dev             musl-dev
 ---> Running in 88750bc8b4d6
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
v3.13.5-269-g122ecbaa66 [https://dl-cdn.alpinelinux.org/alpine/v3.13/main]
v3.13.5-272-g7442f96e1c [https://dl-cdn.alpinelinux.org/alpine/v3.13/community]
OK: 13894 distinct packages available
(1/15) Upgrading musl (1.2.2-r0 -> 1.2.2-r1)
(2/15) Installing ncurses-terminfo-base (6.2_p20210109-r0)
(3/15) Installing ncurses-libs (6.2_p20210109-r0)
(4/15) Installing readline (8.1.0-r0)
(5/15) Installing bash (5.1.0-r0)
Executing bash-5.1.0-r0.post-install
(6/15) Installing bats (1.2.1-r0)
(7/15) Installing brotli-libs (1.0.9-r3)
(8/15) Installing nghttp2-libs (1.42.0-r1)
(9/15) Installing libcurl (7.78.0-r0)
(10/15) Installing curl (7.78.0-r0)
(11/15) Installing musl-dev (1.2.2-r1)
(12/15) Installing pkgconf (1.7.3-r0)
(13/15) Installing openssl-dev (1.1.1k-r0)
(14/15) Installing libffi (3.3-r2)
(15/15) Installing shellcheck (0.7.1-r2)
Executing busybox-1.32.1-r5.trigger
OK: 143 MiB in 40 packages
Removing intermediate container 88750bc8b4d6
 ---> 6e6e8478523c
Step 3/6 : RUN cargo install --force cargo-make
 ---> Running in 70b295589752
    Updating crates.io index
 Downloading crates ...
  Downloaded cargo-make v0.35.0
  Installing cargo-make v0.35.0
 Downloading crates ...
  Downloaded flate2 v1.0.20
  Downloaded foreign-types-shared v0.1.1
  Downloaded foreign-types v0.3.2
  Downloaded fnv v1.0.7
  Downloaded glob v0.3.0
  Downloaded globset v0.4.8
  Downloaded getrandom v0.2.3
  Downloaded hashbrown v0.11.2
  Downloaded num-traits v0.2.14
  Downloaded once_cell v1.8.0
  Downloaded same-file v1.0.6
  Downloaded openssl-probe v0.1.4
  Downloaded num-iter v0.1.42
  Downloaded home v0.5.3
  Downloaded time v0.1.43
  Downloaded thread_local v1.1.3
  Downloaded which v4.2.2
  Downloaded winapi-build v0.1.1
  Downloaded whoami v1.1.2
  Downloaded autocfg v1.0.1
  Downloaded adler v1.0.2
  Downloaded base64 v0.13.0
  Downloaded bytes v1.0.1
  Downloaded cargo-platform v0.1.2
  Downloaded crc32fast v1.2.1
  Downloaded colored v2.0.0
  Downloaded either v1.6.1
  Downloaded bstr v0.2.16
  Downloaded encoding-index-singlebyte v1.20141219.5
  Downloaded crossbeam-utils v0.8.5
  Downloaded heck v0.3.3
  Downloaded encoding_index_tests v0.1.4
  Downloaded encoding-index-japanese v1.20141219.5
  Downloaded quote v1.0.9
  Downloaded strsim v0.8.0
  Downloaded serde_json v1.0.66
  Downloaded pkg-config v0.3.19
  Downloaded dirs-sys-next v0.1.2
  Downloaded unicode-bidi v0.3.5
  Downloaded aho-corasick v0.7.18
  Downloaded unicode-segmentation v1.8.0
  Downloaded serde v1.0.127
  Downloaded regex v1.5.4
  Downloaded unicode-width v0.1.8
  Downloaded tinyvec_macros v0.1.0
  Downloaded syn v1.0.74
  Downloaded vec_map v0.8.2
  Downloaded url v2.2.2
  Downloaded atty v0.2.14
  Downloaded ansi_term v0.11.0
  Downloaded serde_derive v1.0.127
  Downloaded cc v1.0.69
  Downloaded textwrap v0.11.0
  Downloaded thread_local v0.2.7
  Downloaded encoding-index-korean v1.20141219.5
  Downloaded walkdir v2.3.2
  Downloaded tinyvec v1.3.1
  Downloaded users v0.11.0
  Downloaded semver v1.0.4
  Downloaded ryu v1.0.5
  Downloaded ftp v3.0.1
  Downloaded unicode-normalization v0.1.19
  Downloaded regex v0.1.80
  Downloaded camino v1.0.5
  Downloaded serde_ignored v0.1.2
  Downloaded cargo_metadata v0.14.0
  Downloaded proc-macro2 v1.0.28
  Downloaded cfg-if v1.0.0
  Downloaded fs_extra v1.2.0
  Downloaded encoding v0.2.33
  Downloaded regex-syntax v0.6.25
  Downloaded unicode-xid v0.2.2
  Downloaded bitflags v1.2.1
  Downloaded uname v0.1.1
  Downloaded wildmatch v1.1.0
  Downloaded regex-syntax v0.3.9
  Downloaded attohttpc v0.17.0
  Downloaded rand v0.8.4
  Downloaded duckscript v0.7.0
  Downloaded duckscriptsdk v0.8.4
  Downloaded toml v0.5.8
  Downloaded chrono v0.2.25
  Downloaded http v0.2.4
  Downloaded kernel32-sys v0.2.2
  Downloaded indexmap v1.7.0
  Downloaded native-tls v0.2.7
  Downloaded miniz_oxide v0.4.4
  Downloaded num_cpus v1.13.0
  Downloaded lazy_static v1.4.0
  Downloaded log v0.4.14
  Downloaded form_urlencoded v1.0.1
  Downloaded num-integer v0.1.44
  Downloaded itoa v0.4.7
  Downloaded clap v2.33.3
  Downloaded utf8-ranges v0.1.3
  Downloaded thread-id v2.0.0
  Downloaded ignore v0.4.18
  Downloaded rand_chacha v0.3.1
  Downloaded matches v0.1.8
  Downloaded memchr v2.4.0
  Downloaded encoding-index-tradchinese v1.20141219.5
  Downloaded rand_core v0.6.3
  Downloaded percent-encoding v2.1.0
  Downloaded encoding-index-simpchinese v1.20141219.5
  Downloaded ppv-lite86 v0.2.10
  Downloaded meval v0.2.0
  Downloaded num v0.1.42
  Downloaded nom v1.2.4
  Downloaded memchr v0.1.11
  Downloaded openssl-sys v0.9.65
  Downloaded java-properties v1.4.0
  Downloaded fern v0.6.0
  Downloaded aho-corasick v0.5.3
  Downloaded openssl v0.10.35
  Downloaded idna v0.2.3
  Downloaded dirs-next v2.0.0
  Downloaded libc v0.2.98
  Downloaded winapi v0.2.8
  Downloaded git_info v0.1.2
  Downloaded run_script v0.8.0
  Downloaded lazy_static v0.1.16
  Downloaded fsio v0.2.0
  Downloaded shell2batch v0.4.2
  Downloaded envmnt v0.9.0
  Downloaded ci_info v0.14.2
  Downloaded rust_info v0.3.2
   Compiling libc v0.2.98
   Compiling autocfg v1.0.1
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.28
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.74
   Compiling log v0.4.14
   Compiling serde_derive v1.0.127
   Compiling serde v1.0.127
   Compiling memchr v2.4.0
   Compiling cc v1.0.69
   Compiling pkg-config v0.3.19
   Compiling winapi-build v0.1.1
   Compiling encoding_index_tests v0.1.4
   Compiling ppv-lite86 v0.2.10
   Compiling bitflags v1.2.1
   Compiling tinyvec_macros v0.1.0
   Compiling matches v0.1.8
   Compiling regex-syntax v0.6.25
   Compiling once_cell v1.8.0
   Compiling winapi v0.2.8
   Compiling fnv v1.0.7
   Compiling foreign-types-shared v0.1.1
   Compiling lazy_static v1.4.0
   Compiling ryu v1.0.5
   Compiling openssl v0.10.35
   Compiling itoa v0.4.7
   Compiling crc32fast v1.2.1
   Compiling crossbeam-utils v0.8.5
   Compiling serde_json v1.0.66
   Compiling semver v1.0.4
   Compiling native-tls v0.2.7
   Compiling percent-encoding v2.1.0
   Compiling adler v1.0.2
   Compiling openssl-probe v0.1.4
   Compiling hashbrown v0.11.2
   Compiling utf8-ranges v0.1.3
   Compiling regex-syntax v0.3.9
   Compiling camino v1.0.5
   Compiling same-file v1.0.6
   Compiling whoami v1.1.2
   Compiling bytes v1.0.1
   Compiling unicode-segmentation v1.8.0
   Compiling either v1.6.1
   Compiling lazy_static v0.1.16
   Compiling nom v1.2.4
   Compiling wildmatch v1.1.0
   Compiling unicode-width v0.1.8
   Compiling base64 v0.13.0
   Compiling fs_extra v1.2.0
   Compiling ansi_term v0.11.0
   Compiling home v0.5.3
   Compiling vec_map v0.8.2
   Compiling glob v0.3.0
   Compiling strsim v0.8.0
   Compiling git_info v0.1.2
   Compiling rust_info v0.3.2
error[E0658]: the `unsafe_op_in_unsafe_fn` lint is unstable
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rust_info-0.3.2/src/lib.rs:1:1
    |
1   | / #![deny(
2   | |     absolute_paths_not_starting_with_crate,
3   | |     ambiguous_associated_items,
4   | |     anonymous_parameters,
...   |
125 | |     useless_deprecated
126 | | )]
    | |__^
    |
    = note: see issue #71668 <https://github.com/rust-lang/rust/issues/71668> for more information

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: could not compile `rust_info`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-make v0.35.0`, intermediate artifacts can be found at `/tmp/cargo-installxJvqXv`

Caused by:
  build failed
ERROR: Service 'proot-rs-sdk' failed to build: The command '/bin/sh -c cargo install --force cargo-make' returned a non-zero code: 101

@imlk0
Copy link
Collaborator Author

imlk0 commented Aug 9, 2021

@oxr463 Sorry I missed this, it seems to fail easily when installing cargo-make using the nightly version of toolchain. I've changed it to use the stable version to install

@oxr463 oxr463 merged commit 637c122 into master Aug 9, 2021
@oxr463 oxr463 deleted the convert_loader_to_rust branch August 9, 2021 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite loader in rust
2 participants