Added rust

This commit is contained in:
Ella-0 2021-01-30 21:58:39 +00:00
parent bbd6a84a3f
commit 04042c4108
7 changed files with 242 additions and 0 deletions

View file

@ -0,0 +1,10 @@
The script seems to be POSIX-sh (+ local) compatible.
--- a/src/tools/rust-installer/install-template.sh
+++ b/src/tools/rust-installer/install-template.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.

View file

@ -0,0 +1,38 @@
diff --git a/library/unwind/build.rs b/library/unwind/build.rs
index 24bcd40c..51777664 100644
--- a/library/unwind/build.rs
+++ b/library/unwind/build.rs
@@ -14,7 +14,7 @@ fn main() {
} else if target.contains("linux") {
// linking for Linux is handled in lib.rs
if target.contains("musl") {
- llvm_libunwind::compile();
+ println!("cargo:rustc-link-lib=unwind");
}
} else if target.contains("freebsd") {
println!("cargo:rustc-link-lib=gcc_s");
diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs
index dbdefa47..dca1897b 100644
--- a/library/unwind/src/lib.rs
+++ b/library/unwind/src/lib.rs
@@ -39,7 +39,7 @@ cfg_if::cfg_if! {
#[cfg(target_env = "musl")]
#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
-#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
// When building with crt-static, we get `gcc_eh` from the `libc` crate, since
diff -Naur rustc-1.48.0-src.orig/src/bootstrap/dist.rs rustc-1.48.0-src/src/bootstrap/dist.rs
--- rustc-1.48.0-src.orig/src/bootstrap/dist.rs 2020-12-22 16:39:30.504249113 +0100
+++ rustc-1.48.0-src/src/bootstrap/dist.rs 2020-12-22 16:42:08.663006830 +0100
@@ -1016,7 +1016,7 @@
copy_src_dirs(
builder,
&builder.src,
- &["library", "src/llvm-project/libunwind"],
+ &["library"],
&[
// not needed and contains symlinks which rustup currently
// chokes on when unpacking.

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,11 @@
--- a/compiler/rustc_target/src/spec/linux_musl_base.rs
+++ b/compiler/rustc_target/src/spec/linux_musl_base.rs
@@ -10,7 +10,7 @@
base.crt_objects_fallback = Some(CrtObjectsFallback::Musl);
// These targets statically link libc by default
- base.crt_static_default = false;
+ base.crt_static_default = true;
base
}

View file

@ -0,0 +1,23 @@
--- a/src/etc/rust-gdb
+++ b/src/etc/rust-gdb
@@ -12,7 +12,7 @@
# Find out where the pretty printer Python module is
RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)"
-GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
+GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/share/rust/etc"
# Run GDB with the additional arguments that load the pretty printers
# Set the environment variable `RUST_GDB` to overwrite the call to a
# Set the environment variable `RUST_GDB` to overwrite the call to a
--- a/src/etc/rust-lldb
+++ b/src/etc/rust-lldb
@@ -8,7 +8,7 @@
# Find out where to look for the pretty printer Python module
RUSTC_SYSROOT=$(rustc --print sysroot)
-RUST_LLDB="$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb"
+RUST_LLDB="$RUSTC_SYSROOT/share/rust/etc"
lldb=lldb
if [ -f "$RUST_LLDB" ]; then

98
pkgs/rust/build.sh Normal file
View file

@ -0,0 +1,98 @@
# Based on Abyss OS phase1/devel/rust APKBUILD:
#
# Copyright (c) 2019 by the Abyss Authors
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
pkgname=rust
pkgver=1.49.0
_clear_vendor_checksums() {
sed -i 's/\("files":{\)[^}]*/\1/' vendor/$1/.cargo-checksum.json
}
fetch() {
curl "https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz" -o $pkgname-$pkgver.tar.xz
tar -xf $pkgname-$pkgver.tar.xz
mv rustc-$pkgver-src $pkgname-$pkgver
cp ../*.patch .
cd $pkgname-$pkgver
patch -p1 < ../alpine-move-py.patch
patch -p1 < ../abyss-install-template-shebang.patch
patch -p1 < ../abyss-libunwind.patch
patch -p1 < ../abyss-libz.patch
patch -p1 < ../vendored-ssl.patch
patch -p1 < ../alpine-crt.patch
sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
_clear_vendor_checksums libc
_clear_vendor_checksums openssl-sys
_clear_vendor_checksums openssl-src
rm -rf src/llvm-project/
ln -s /usr/bin/gmake make
}
build() {
cd $pkgname-$pkgver
OPENSSL_LIB_DIR=/usr/lib/ ./configure \
--build="x86_64-unknown-linux-musl" \
--host="x86_64-unknown-linux-musl" \
--target="x86_64-unknown-linux-musl" \
--prefix="/usr" \
--release-channel="stable" \
--enable-local-rust \
--local-rust-root="/usr" \
--llvm-root="/usr" \
--disable-docs \
--enable-extended \
--tools="cargo" \
--enable-vendor \
--enable-locked-deps \
--enable-llvm-link-shared \
--enable-option-checking \
--python="python" \
--set="rust.musl-root=/usr" \
--set="target.x86_64-unknown-linux-musl.llvm-config=/usr/bin/llvm-config" \
--set="target.x86_64-unknown-linux-musl.musl-root=/usr" \
--set="target.x86_64-unknown-linux-musl.crt-static=false" \
--set="target.x86_64-unknown-linux-musl.cc=cc" \
--set="target.x86_64-unknown-linux-musl.cxx=c++" \
--set="target.x86_64-unknown-linux-musl.ar=ar" \
--set="target.x86_64-unknown-linux-musl.linker=cc" \
--set="target.x86_64-unknown-linux-musl.musl-root=/usr" \
--set="target.x86_64-unknown-linux-musl.crt-static=false" \
--set="target.x86_64-unknown-linux-musl.cc=cc" \
--set="target.x86_64-unknown-linux-musl.cxx=c++" \
--set="target.x86_64-unknown-linux-musl.ar=ar" \
--set="target.x86_64-unknown-linux-musl.linker=cc"
sed 's/#deny-warnings = .*/deny-warnings = false/' -i config.toml
sed 's|deny(warnings,|deny(|' -i src/bootstrap/lib.rs
PATH=$(pwd)"/..:$PATH" ./x.py build
}
package() {
cd $pkgname-$pkgver
DESTDIR="$pkgdir" ./x.py install
}
license() {
cd $pkgname-$pkgver
cat LICENSE
# cat COPYING
}

View file

@ -0,0 +1,54 @@
--- vendor/openssl-sys/Cargo.toml
+++ ../../rust-1.49.0/vendor/openssl-sys/Cargo.toml
@@ -33,12 +33,11 @@
[build-dependencies.openssl-src]
version = "111.0.1"
-optional = true
[build-dependencies.pkg-config]
version = "0.3.9"
[features]
-vendored = ["openssl-src"]
+vendored = []
[target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg]
version = "0.2.8"
Only in ../../rust-1.49.0/vendor/openssl-sys: Cargo.toml.1
--- vendor/openssl-sys/build/main.rs
+++ ../../rust-1.49.0/vendor/openssl-sys/build/main.rs
@@ -2,7 +2,6 @@
extern crate autocfg;
extern crate cc;
-#[cfg(feature = "vendored")]
extern crate openssl_src;
extern crate pkg_config;
#[cfg(target_env = "msvc")]
@@ -16,7 +15,6 @@
mod cfgs;
mod find_normal;
-#[cfg(feature = "vendored")]
mod find_vendored;
enum Version {
@@ -44,15 +42,14 @@
}
fn find_openssl(target: &str) -> (PathBuf, PathBuf) {
- #[cfg(feature = "vendored")]
{
// vendor if the feature is present, unless
// OPENSSL_NO_VENDOR exists and isn't `0`
- if env("OPENSSL_NO_VENDOR").map_or(true, |s| s == "0") {
+ //if env("OPENSSL_NO_VENDOR").map_or(true, |s| s == "0") {
return find_vendored::get_openssl(target);
- }
+ //}
}
- find_normal::get_openssl(target)
+ //find_normal::get_openssl(target)
}
fn main() {