Rust`ишка (не Danone)

Форум для малосерьезного общения, трёпа, поздравлений
Аватара пользователя
TheBB
Сообщения: 107
Зарегистрирован: 31 авг 2015, 02:24
Откуда: 26 ~44.098,43.022

Сообщение TheBB » 29 ноя 2021, 12:18

За вынос кукух аффтар ответственности не несётъ!

"... дело было вечером, делать было нечего...", хотя... история этого уже и не помнит, на кой оно было надо
(тут ls -al первого? варианта)

Код: Выделить всё

~ # ls -l rust/
итого 4
-rw-r--r-- 1 thebb 1668 авг 14  2019 Makefile

За основу было взято из проекта buildroot ( тут ссыль на проект)
(у OpenWrt тогда ещё не было PR, который висит до сих пор (тут ссыль на PR).
Ессна, попробовал на зуб, как оно. оно оказалось не очень, даже с набитыми костылями.
То, что собиралось своим вариантом, напрочь отказывалось собираться owrt`шным. Лень победила!)


Печаль первая: на cmake`и надо натянуть ssl - или libre, или open.
Пробовал оба-два, но, т.к. libre изначально не задействована, остался на open.
тут git diff tools/Makefile

Код: Выделить всё

diff --git a/tools/Makefile b/tools/Makefile
index c354d818..0958a7d2 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -25,7 +25,7 @@ tools-y += autoconf autoconf-archive automake bc bison cmake cpio dosfstools
 tools-y += e2fsprogs fakeroot findutils flex gengetopt
 tools-y += go-bootstrap go-src
 tools-y += libtool lzma m4 missing-macros
-tools-y += mklibs mm-macros mtools ninja
+tools-y += mklibs mm-macros mtools ninja openssl
 tools-y += patchelf pkgconf quilt sstrip xxd zip zlib zstd
 tools-$(BUILD_ISL) += isl
 tools-$(BUILD_TOOLCHAIN) += expat gmp mpc mpfr
@@ -35,7 +35,7 @@ $(curdir)/autoconf/compile := $(curdir)/m4/compile
 $(curdir)/automake/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile $(curdir)/pkgconf/compile $(curdir)/xz/compile
 $(curdir)/bc/compile := $(curdir)/bison/compile $(curdir)/libtool/compile
 $(curdir)/bison/compile := $(curdir)/flex/compile
-$(curdir)/cmake/compile += $(curdir)/ninja/compile
+$(curdir)/cmake/compile += $(curdir)/openssl/compile $(curdir)/ninja/compile
 $(curdir)/dosfstools/compile := $(curdir)/autoconf/compile $(curdir)/automake/compile
 $(curdir)/e2fsprogs/compile := $(curdir)/libtool/compile
 $(curdir)/fakeroot/compile := $(curdir)/libtool/compile
@@ -51,6 +51,7 @@ $(curdir)/mklibs/compile := $(curdir)/libtool/compile
 $(curdir)/mm-macros/compile := $(curdir)/libtool/compile
 $(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile
 $(curdir)/mpfr/compile := $(curdir)/gmp/compile
+$(curdir)/openssl/compile := $(curdir)/pkgconf/compile
 $(curdir)/patchelf/compile := $(curdir)/libtool/compile
 $(curdir)/quilt/compile := $(curdir)/autoconf/compile $(curdir)/findutils/compile
 $(curdir)/zlib/compile := $(curdir)/cmake/compile
@@ -59,7 +60,7 @@ $(curdir)/zstd/compile := $(curdir)/cmake/compile
 tools-y += coreutils
 
 ifneq ($(CONFIG_CCACHE)$(CONFIG_SDK),)
-$(foreach tool, $(filter-out xz zstd patch pkgconf ninja cmake,$(tools-y)), $(eval $(curdir)/$(tool)/compile += $(curdir)/ccache/compile))
+$(foreach tool, $(filter-out xz zstd pkgconf patch openssl ninja cmake,$(tools-y)), $(eval $(curdir)/$(tool)/compile += $(curdir)/ccache/compile))
 tools-y += ccache
 $(curdir)/ccache/compile := $(curdir)/zstd/compile
 endif
Свернуть
тут cat tools/openssl/Makefile

Код: Выделить всё

#
# Copyright (C) 2018-2021 Entware
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=openssl
PKG_BASE:=1.1.1
PKG_BUGFIX:=l
PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
PKG_RELEASE:=1

PKG_CPE_ID:=cpe:/a:openssl:openssl

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:= \
	http://www.openssl.org/source/ \
	http://www.openssl.org/source/old/$(PKG_BASE)/ \
	http://ftp.fi.muni.cz/pub/openssl/source/ \
	http://ftp.fi.muni.cz/pub/openssl/source/old/$(PKG_BASE)/ \
	ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
	ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/old/$(PKG_BASE)/

PKG_HASH:=0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1

include $(INCLUDE_DIR)/host-build.mk

HOST_CFLAGS += $(FPIC)

define Host/Prepare
	$(call Host/Prepare/Default)
	( cd $(HOST_BUILD_DIR); ./config \
		--prefix=$(STAGING_DIR_HOST) \
		--openssldir=$(STAGING_DIR_HOST)/etc/ssl \
		no-asm \
		no-shared \
		386 \
	)
endef

$(eval $(call HostBuild))
Свернуть
Или присмотреться к PR (https://github.com/openwrt/openwrt/pull/4749/files)

Печаль вторая: время сборки (зависит от железа)
Не считая время загрузки архивов, распаковки, bootstrap, да ещё и по фен-шуй, выходило накладно.
Будем резать!
~ минут 20 собирается LLVM - обрезаны неиспользуемые таргеты (BPF;Hexagon;MSP430;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly + AVR(experimental)), добавление каждого из них увеличивает время сборки.
+ ~ минут 25 собирается хостовый rust (было ~ 20 минут, увеличилось из-за добавления clippy & rustfmt)
+ ~ минут 15 собираются бибки для выбранной $arch.
Итого: выходит около часа на полную сборку для первой выбранной архитектуры, для следующей занимает ~ 15 минут.


Печаль третья: targets
Когда собиралось только для mips (be/el), можно было и забить, да и обходился одним патчем (+soft-float).
cat rustc/patches/999-fix_mips_sf.patch

Код: Выделить всё

--- a/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs
@@ -10,7 +10,7 @@ pub fn target() -> Target {
         options: TargetOptions {
             endian: Endian::Big,
             cpu: "mips32r2".to_string(),
-            features: "+mips32r2,+fpxx,+nooddspreg".to_string(),
+            features: "+mips32r2,+soft-float".to_string(),
             max_atomic_width: Some(32),
             mcount: "_mcount".to_string(),
 
--- a/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs
@@ -9,7 +9,7 @@ pub fn target() -> Target {
 
         options: TargetOptions {
             cpu: "mips32r2".to_string(),
-            features: "+mips32r2,+fpxx,+nooddspreg".to_string(),
+            features: "+mips32r2,+soft-float".to_string(),
             max_atomic_width: Some(32),
             mcount: "_mcount".to_string(),
 
Свернуть
После какого-то обновления на новую версию, добавился ещё один (getrandom)
cat rustc/patches/999-fix-getrandom.patch

Код: Выделить всё

--- a/library/std/src/sys/unix/rand.rs
+++ b/library/std/src/sys/unix/rand.rs
@@ -26,22 +26,10 @@ mod imp {
     use crate::io::Read;
 
     #[cfg(any(target_os = "linux", target_os = "android"))]
-    use crate::sys::weak::syscall;
-
-    #[cfg(any(target_os = "linux", target_os = "android"))]
-    fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
-        // A weak symbol allows interposition, e.g. for perf measurements that want to
-        // disable randomness for consistency. Otherwise, we'll try a raw syscall.
-        // (`getrandom` was added in glibc 2.25, musl 1.1.20, android API level 28)
-        syscall! {
-            fn getrandom(
-                buffer: *mut libc::c_void,
-                length: libc::size_t,
-                flags: libc::c_uint
-            ) -> libc::ssize_t
+    fn getrandom(buf: &mut [u8]) -> libc::c_long {
+        unsafe {
+            libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr(), buf.len(), libc::GRND_NONBLOCK)
         }
-
-        unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), libc::GRND_NONBLOCK) }
     }
 
     #[cfg(target_os = "espidf")]
Свернуть
однако...

Засада первая: arm - armv5 vs armv7 - разрезать можно, но... см. ниже.

Засада вторая: arm(v7) - armv7-2.6 vs armv7-3.2 - а тут уже фих знаетъ чего прилепить.

Засада третья: x86_64 - $host vs $target - ну-с, делать нечего, переименовываем...
Что-то типа, $(ARCH)-entware-linux-gnu$(ABI)? Ага, щаззз. suricata (см. ниже)

Засада четвёртая: host,host_alias,host_triplet,target_alias... - шоб owrt`шникам икалось до-о-олго, переименовываем в... $(REAL_GNU_TARGET_NAME)

Засада пятая: вот это всё должно валяться в $(STAGING_DIR_HOSTPKG) - тута сразу и первая, и вторая, и третья вылезають.
Не по шен-фуй, но тоже могет быть... Закидываем в $(STAGING_DIR)/host
запчасти от лисапеда )))
cat rustc/Makefile

Код: Выделить всё

# SPDX-License-Identifier: WTFPL

include $(TOPDIR)/rules.mk

PKG_NAME:=rustc
PKG_VERSION:=1.56.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-src.tar.xz
PKG_SOURCE_URL:=https://static.rust-lang.org/dist
PKG_HASH:=61fdcc8bc2530ee18f91318347e09b7cc07e9ca04b1c627c135ecc8dcb8f2ac5

HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION)-src
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-src

PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT

HOST_BUILD_DEPENDS:=python3/host
PKG_BUILD_DEPENDS:=rustc/host

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk

define Package/rustc
  SECTION:=devel
  CATEGORY:=Development
  TITLE:=Rust
  URL:=https://crates.io/
  BUILDONLY:=1
endef

define Package/rustc/description
  Rust.
endef

# host
RUST_HOST_TRIPLE:=$(HOST_ARCH)-unknown-linux-gnu

define Host/Configure
	( \
		echo 'changelog-seen = 2'; \
		echo '[llvm]'; \
		echo 'targets = "AArch64;ARM;Mips;X86"'; \
		echo 'experimental-targets = ""'; \
		echo 'link-shared = true'; \
		echo '[build]'; \
		echo 'test-stage = 0'; \
		echo 'dist-stage = 0'; \
		echo 'bench-stage = 0'; \
		echo 'target = ["$(RUST_HOST_TRIPLE)"]'; \
		echo 'docs = false'; \
		echo 'compiler-docs = false'; \
		echo 'submodules = false'; \
		echo 'python = "$(STAGING_DIR_HOSTPKG)/bin/python3"'; \
		echo 'vendor = true'; \
		echo 'extended = true'; \
		echo 'tools = ["cargo", "clippy", "rustfmt"]'; \
		echo 'verbose = 0'; \
		echo '[install]'; \
		echo 'prefix = "/"'; \
		echo 'sysconfdir = "/etc"'; \
		echo 'bindir = "/bin"'; \
		echo 'libdir = "/lib"'; \
		echo 'datadir = "/share"'; \
		echo '[rust]'; \
		echo 'backtrace = false'; \
		echo 'incremental = true'; \
		echo 'channel = "nightly"'; \
		echo 'codegen-tests = false'; \
		echo 'dist-src = false'; \
		echo '[target.$(RUST_HOST_TRIPLE)]'; \
		echo 'cc = "$(HOSTCC)"'; \
		echo 'cxx = "$(HOSTCXX)"'; \
		echo '[dist]'; \
		echo 'src-tarball = false'; \
		echo 'compression-formats = ["gz"]'; \
	) > $(HOST_BUILD_DIR)/config.toml
endef

define Host/Compile
#	( cd $(HOST_BUILD_DIR); \
#		$(STAGING_DIR_HOSTPKG)/bin/python3 x.py build; \
#	)
endef

define Host/Install
	( cd $(HOST_BUILD_DIR); \
		DESTDIR=$(HOST_BUILD_DIR)/install \
		$(STAGING_DIR_HOSTPKG)/bin/python3 x.py install \
	)
endef

# target
#RUST_TARGET_TRIPLE:=

#ifeq ($(CONFIG_TARGET_armv5_3_2),y)
#RUST_TARGET_TRIPLE=armv5te-openwrt-linux-gnueabi
#else
#ifeq ($(or $(CONFIG_TARGET_armv7_2_6),$(CONFIG_TARGET_armv7_3_2)),y)
#RUST_TARGET_TRIPLE=armv7-openwrt-linux-gnueabi
#else
#ifeq ($(CONFIG_TARGET_x86_2_6),y)
#RUST_TARGET_TRIPLE=i486-openwrt-linux-gnu
#else
RUST_TARGET_TRIPLE=$(REAL_GNU_TARGET_NAME)
#endif
#endif
#endif

# XXX saved ~ 20 min (skip LLVM)
define Build/Prepare
	$(call Build/Prepare/Default)

	$(INSTALL_DIR) $(PKG_BUILD_DIR)/build/$(RUST_HOST_TRIPLE)
	$(LN) $(HOST_BUILD_DIR)/build/$(RUST_HOST_TRIPLE)/llvm \
		$(PKG_BUILD_DIR)/build/$(RUST_HOST_TRIPLE)


	$(INSTALL_DIR) $(STAGING_DIR)/host/bin $(STAGING_DIR)/host/lib/rustlib
	$(CP) $(HOST_BUILD_DIR)/install/bin/{cargo,clippy,rustc,rustd,rustf}* \
		 $(STAGING_DIR)/host/bin

	$(CP) $(HOST_BUILD_DIR)/install/lib/lib* $(STAGING_DIR)/host/lib
	$(CP) $(HOST_BUILD_DIR)/install/lib/rustlib/$(RUST_HOST_TRIPLE) \
		 $(STAGING_DIR)/host/lib/rustlib
endef

define Build/Configure
	( \
		echo 'changelog-seen = 2'; \
		echo 'profile = "library"'; \
		echo '[llvm]'; \
		echo 'download-ci-llvm = false'; \
		echo 'skip-rebuild = true'; \
		echo 'allow-old-toolchain = true'; \
		echo '[build]'; \
		echo 'host = ["$(RUST_TARGET_TRIPLE)"]'; \
		echo 'target = ["$(RUST_TARGET_TRIPLE)"]'; \
		echo 'cargo = "$(STAGING_DIR)/host/bin/cargo"'; \
		echo 'rustc = "$(STAGING_DIR)/host/bin/rustc"'; \
		echo 'docs = false'; \
		echo 'compiler-docs = false'; \
		echo 'submodules = false'; \
		echo 'python = "$(STAGING_DIR_HOSTPKG)/bin/python3"'; \
		echo 'vendor = true'; \
		echo 'full-bootstrap = false'; \
		echo 'extended = false'; \
		echo 'tools = [""]'; \
		echo 'verbose = 0'; \
		echo 'local-rebuild = false'; \
		echo '[install]'; \
		echo 'prefix = "/opt"'; \
		echo 'sysconfdir = "/opt/etc"'; \
		echo 'bindir = "/opt/bin"'; \
		echo 'libdir = "/opt/lib"'; \
		echo 'datadir = "/opt/share"'; \
		echo '[rust]'; \
		echo 'incremental = true'; \
		echo 'channel = "nightly"'; \
		echo 'rpath = false'; \
		echo 'codegen-tests = false'; \
		echo 'dist-src = false'; \
		echo '[target.$(RUST_TARGET_TRIPLE)]'; \
		echo 'cc = "$(TARGET_CROSS)gcc"'; \
		echo 'cxx = "$(TARGET_CROSS)g++"'; \
		echo 'ar = "$(TARGET_CROSS)ar"'; \
		echo 'ranlib = "$(TARGET_CROSS)ranlib"'; \
		echo 'linker = "$(TARGET_CROSS)gcc"'; \
		echo '[dist]'; \
		echo 'src-tarball = false'; \
		echo 'compression-formats = ["gz"]'; \
	) > $(PKG_BUILD_DIR)/config.toml
endef

# XXX saved ~ 10 min
define Build/Compile
#	( cd $(PKG_BUILD_DIR); \
#		$(STAGING_DIR_HOSTPKG)/bin/python3 x.py build library/std \
#	)
endef

define Build/Install
	( cd $(PKG_BUILD_DIR); \
		PKG_CONFIG_ALLOW_CROSS=1 \
		DESTDIR=$(PKG_INSTALL_DIR) \
		$(STAGING_DIR_HOSTPKG)/bin/python3 x.py install \
		library/std --stage 1 \
	)
endef

define Build/InstallDev
	$(INSTALL_DIR) $(2)/lib/rustlib
	$(CP) $(PKG_INSTALL_DIR)/opt/lib/rustlib/$(RUST_TARGET_TRIPLE) \
		 $(2)/lib/rustlib

	$(INSTALL_DIR) $(2)/share/cargo/.cargo
	( \
		echo '[target.$(RUST_TARGET_TRIPLE)]'; \
		echo 'linker = "$(TARGET_CROSS)gcc"'; \
	) > $(2)/share/cargo/.cargo/config.toml
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,rustc))
Свернуть
cat rustc/patches/600-fix-getrandom.patch

Код: Выделить всё

--- a/library/std/src/sys/unix/rand.rs
+++ b/library/std/src/sys/unix/rand.rs
@@ -26,22 +26,10 @@ mod imp {
     use crate::io::Read;
 
     #[cfg(any(target_os = "linux", target_os = "android"))]
-    use crate::sys::weak::syscall;
-
-    #[cfg(any(target_os = "linux", target_os = "android"))]
-    fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
-        // A weak symbol allows interposition, e.g. for perf measurements that want to
-        // disable randomness for consistency. Otherwise, we'll try a raw syscall.
-        // (`getrandom` was added in glibc 2.25, musl 1.1.20, android API level 28)
-        syscall! {
-            fn getrandom(
-                buffer: *mut libc::c_void,
-                length: libc::size_t,
-                flags: libc::c_uint
-            ) -> libc::ssize_t
+    fn getrandom(buf: &mut [u8]) -> libc::c_long {
+        unsafe {
+            libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr(), buf.len(), libc::GRND_NONBLOCK)
         }
-
-        unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), libc::GRND_NONBLOCK) }
     }
 
     #[cfg(target_os = "espidf")]
Свернуть
cat rustc/patches/610-fix1-targets.patch

Код: Выделить всё

--- /dev/null
+++ b/compiler/rustc_target/src/spec/aarch64_openwrt_linux_gnu.rs
@@ -0,0 +1,20 @@
+use crate::spec::{SanitizerSet, Target, TargetOptions};
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "aarch64-openwrt-linux-gnu".to_string(),
+        pointer_width: 64,
+        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
+        arch: "aarch64".to_string(),
+        options: TargetOptions {
+            mcount: "\u{1}_mcount".to_string(),
+            max_atomic_width: Some(128),
+            supported_sanitizers: SanitizerSet::ADDRESS
+                | SanitizerSet::LEAK
+                | SanitizerSet::MEMORY
+                | SanitizerSet::THREAD
+                | SanitizerSet::HWADDRESS,
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/arm_openwrt_linux_gnueabi.rs
@@ -0,0 +1,17 @@
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "arm-openwrt-linux-gnueabi".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+        arch: "arm".to_string(),
+        options: TargetOptions {
+            abi: "eabi".to_string(),
+            features: "+strict-align,+v6".to_string(),
+            max_atomic_width: Some(64),
+            mcount: "\u{1}__gnu_mcount_nc".to_string(),
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/armv5te_openwrt_linux_gnueabi.rs
@@ -0,0 +1,19 @@
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "armv5te-openwrt-linux-gnueabi".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+        arch: "arm".to_string(),
+        options: TargetOptions {
+            abi: "eabi".to_string(),
+            features: "+soft-float,+strict-align".to_string(),
+            // Atomic operations provided by compiler-builtins
+            max_atomic_width: Some(32),
+            mcount: "\u{1}__gnu_mcount_nc".to_string(),
+            has_thumb_interworking: true,
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/armv7_openwrt_linux_gnueabi.rs
@@ -0,0 +1,20 @@
+use crate::spec::{Target, TargetOptions};
+
+// This target is for glibc Linux on ARMv7 without thumb-mode, NEON or
+// hardfloat.
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "armv7-openwrt-linux-gnueabi".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+        arch: "arm".to_string(),
+        options: TargetOptions {
+            abi: "eabi".to_string(),
+            features: "+v7,+thumb2,+soft-float,-neon".to_string(),
+            max_atomic_width: Some(64),
+            mcount: "\u{1}__gnu_mcount_nc".to_string(),
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/i386_openwrt_linux_gnu.rs
@@ -0,0 +1,8 @@
+use crate::spec::Target;
+
+pub fn target() -> Target {
+    let mut base = super::i686_openwrt_linux_gnu::target();
+    base.cpu = "i386".to_string();
+    base.llvm_target = "i386-openwrt-linux-gnu".to_string();
+    base
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/i486_openwrt_linux_gnu.rs
@@ -0,0 +1,8 @@
+use crate::spec::Target;
+
+pub fn target() -> Target {
+    let mut base = super::i686_openwrt_linux_gnu::target();
+    base.cpu = "i486".to_string();
+    base.llvm_target = "i486-openwrt-linux-gnu".to_string();
+    base
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/i586_openwrt_linux_gnu.rs
@@ -0,0 +1,8 @@
+use crate::spec::Target;
+
+pub fn target() -> Target {
+    let mut base = super::i686_openwrt_linux_gnu::target();
+    base.cpu = "pentium".to_string();
+    base.llvm_target = "i586-openwrt-linux-gnu".to_string();
+    base
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/i686_openwrt_linux_gnu.rs
@@ -0,0 +1,20 @@
+use crate::spec::{LinkerFlavor, StackProbeType, Target};
+
+pub fn target() -> Target {
+    let mut base = super::openwrt_linux_gnu_base::opts();
+    base.cpu = "pentium4".to_string();
+    base.max_atomic_width = Some(64);
+    base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
+    // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
+    base.stack_probes = StackProbeType::Call;
+
+    Target {
+        llvm_target: "i686-openwrt-linux-gnu".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
+            f64:32:64-f80:32-n8:16:32-S128"
+            .to_string(),
+        arch: "x86".to_string(),
+        options: base,
+    }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/mips_openwrt_linux_gnu.rs
@@ -0,0 +1,20 @@
+use crate::abi::Endian;
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "mips-openwrt-linux-gnu".to_string(),
+        pointer_width: 32,
+        data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
+        arch: "mips".to_string(),
+        options: TargetOptions {
+            endian: Endian::Big,
+            cpu: "mips32r2".to_string(),
+            features: "+mips32r2,+soft-float,+nooddspreg".to_string(),
+            max_atomic_width: Some(32),
+            mcount: "_mcount".to_string(),
+
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/mipsel_openwrt_linux_gnu.rs
@@ -0,0 +1,19 @@
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "mipsel-openwrt-linux-gnu".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
+        arch: "mips".to_string(),
+
+        options: TargetOptions {
+            cpu: "mips32r2".to_string(),
+            features: "+mips32r2,+soft-float,+nooddspreg".to_string(),
+            max_atomic_width: Some(32),
+            mcount: "_mcount".to_string(),
+
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -73,6 +73,8 @@ mod linux_uclibc_base;
 mod msvc_base;
 mod netbsd_base;
 mod openbsd_base;
+mod openwrt_linux_base;
+mod openwrt_linux_gnu_base;
 mod redox_base;
 mod solaris_base;
 mod thumb_base;
@@ -738,6 +740,18 @@ macro_rules! supported_targets {
 }
 
 supported_targets! {
+    ("aarch64-openwrt-linux-gnu", aarch64_openwrt_linux_gnu),
+    ("arm-openwrt-linux-gnueabi", arm_openwrt_linux_gnueabi),
+    ("armv5te-openwrt-linux-gnueabi", armv5te_openwrt_linux_gnueabi),
+    ("armv7-openwrt-linux-gnueabi", armv7_openwrt_linux_gnueabi),
+    ("i386-openwrt-linux-gnu", i386_openwrt_linux_gnu),
+    ("i486-openwrt-linux-gnu", i486_openwrt_linux_gnu),
+    ("i586-openwrt-linux-gnu", i586_openwrt_linux_gnu),
+    ("i686-openwrt-linux-gnu", i686_openwrt_linux_gnu),
+    ("mips-openwrt-linux-gnu", mips_openwrt_linux_gnu),
+    ("mipsel-openwrt-linux-gnu", mipsel_openwrt_linux_gnu),
+    ("x86_64-openwrt-linux-gnu", x86_64_openwrt_linux_gnu),
+
     ("x86_64-unknown-linux-gnu", x86_64_unknown_linux_gnu),
     ("x86_64-unknown-linux-gnux32", x86_64_unknown_linux_gnux32),
     ("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
--- /dev/null
+++ b/compiler/rustc_target/src/spec/openwrt_linux_base.rs
@@ -0,0 +1,16 @@
+use crate::spec::{RelroLevel, TargetOptions};
+
+pub fn opts() -> TargetOptions {
+    TargetOptions {
+        os: "linux".to_string(),
+        dynamic_linking: true,
+        executables: true,
+        families: vec!["unix".to_string()],
+        has_rpath: false,
+        position_independent_executables: false,
+        relro_level: RelroLevel::None,
+        has_elf_tls: true,
+        crt_static_respected: true,
+        ..Default::default()
+    }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/openwrt_linux_gnu_base.rs
@@ -0,0 +1,5 @@
+use crate::spec::TargetOptions;
+
+pub fn opts() -> TargetOptions {
+    TargetOptions { env: "gnu".to_string(), ..super::openwrt_linux_base::opts() }
+}
--- /dev/null
+++ b/compiler/rustc_target/src/spec/x86_64_openwrt_linux_gnu.rs
@@ -0,0 +1,21 @@
+use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
+
+pub fn target() -> Target {
+    let mut base = super::openwrt_linux_gnu_base::opts();
+    base.cpu = "x86-64".to_string();
+    base.max_atomic_width = Some(64);
+    base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
+    // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
+    base.stack_probes = StackProbeType::Call;
+    base.supported_sanitizers =
+        SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD;
+
+    Target {
+        llvm_target: "x86_64-openwrt-linux-gnu".to_string(),
+        pointer_width: 64,
+        data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+            .to_string(),
+        arch: "x86_64".to_string(),
+        options: base,
+    }
+}
Свернуть
cat rustc/patches/620-fix2-targets.patch

Код: Выделить всё

--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/aarch64_openwrt_linux_gnu.rs
@@ -0,0 +1,23 @@
+use crate::spec::{SanitizerSet, Target, TargetOptions};
+
+pub fn target() -> Target {
+    let mut base = super::linux_gnu_base::opts();
+    base.max_atomic_width = Some(128);
+    base.supported_sanitizers = SanitizerSet::ADDRESS
+        | SanitizerSet::LEAK
+        | SanitizerSet::MEMORY
+        | SanitizerSet::THREAD
+        | SanitizerSet::HWADDRESS;
+
+    Target {
+        llvm_target: "aarch64-openwrt-linux-gnu".to_string(),
+        pointer_width: 64,
+        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
+        arch: "aarch64".to_string(),
+        options: TargetOptions {
+            unsupported_abis: super::arm_base::unsupported_abis(),
+            mcount: "\u{1}_mcount".to_string(),
+            ..base
+        },
+    }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/arm_openwrt_linux_gnueabi.rs
@@ -0,0 +1,19 @@
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    let mut base = super::openwrt_linux_gnu_base::opts();
+    base.max_atomic_width = Some(64);
+    Target {
+        llvm_target: "arm-openwrt-linux-gnueabi".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+        arch: "arm".to_string(),
+
+        options: TargetOptions {
+            features: "+soft-float,+strict-align".to_string(),
+            unsupported_abis: super::arm_base::unsupported_abis(),
+            mcount: "\u{1}__gnu_mcount_nc".to_string(),
+            ..base
+        },
+    }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/armv5te_openwrt_linux_gnueabi.rs
@@ -0,0 +1,21 @@
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    let base = super::openwrt_linux_gnu_base::opts();
+    Target {
+        llvm_target: "armv5te-openwrt-linux-gnueabi".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+        arch: "arm".to_string(),
+
+        options: TargetOptions {
+            features: "+soft-float,+strict-align".to_string(),
+            // Atomic operations provided by compiler-builtins
+            max_atomic_width: Some(32),
+            unsupported_abis: super::arm_base::unsupported_abis(),
+            mcount: "\u{1}__gnu_mcount_nc".to_string(),
+            has_thumb_interworking: true,
+            ..base
+        },
+    }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/armv7_openwrt_linux_gnueabi.rs
@@ -0,0 +1,22 @@
+use crate::spec::{Target, TargetOptions};
+
+// This target is for glibc Linux on ARMv7 without thumb-mode, NEON or
+// hardfloat.
+
+pub fn target() -> Target {
+    let base = super::openwrt_linux_gnu_base::opts();
+    Target {
+        llvm_target: "armv7-openwrt-linux-gnueabi".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+        arch: "arm".to_string(),
+
+        options: TargetOptions {
+            features: "+v7,+thumb2,+soft-float,-neon".to_string(),
+            max_atomic_width: Some(64),
+            unsupported_abis: super::arm_base::unsupported_abis(),
+            mcount: "\u{1}__gnu_mcount_nc".to_string(),
+            ..base
+        },
+    }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/i386_openwrt_linux_gnu.rs
@@ -0,0 +1,8 @@
+use crate::spec::Target;
+
+pub fn target() -> Target {
+    let mut base = super::i686_openwrt_linux_gnu::target();
+    base.cpu = "i386".to_string();
+    base.llvm_target = "i386-openwrt-linux-gnu".to_string();
+    base
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/i486_openwrt_linux_gnu.rs
@@ -0,0 +1,8 @@
+use crate::spec::Target;
+
+pub fn target() -> Target {
+    let mut base = super::i686_openwrt_linux_gnu::target();
+    base.cpu = "i486".to_string();
+    base.llvm_target = "i486-openwrt-linux-gnu".to_string();
+    base
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/i586_openwrt_linux_gnu.rs
@@ -0,0 +1,8 @@
+use crate::spec::Target;
+
+pub fn target() -> Target {
+    let mut base = super::i686_openwrt_linux_gnu::target();
+    base.cpu = "pentium".to_string();
+    base.llvm_target = "i586-openwrt-linux-gnu".to_string();
+    base
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/i686_openwrt_linux_gnu.rs
@@ -0,0 +1,20 @@
+use crate::spec::{LinkerFlavor, StackProbeType, Target};
+
+pub fn target() -> Target {
+    let mut base = super::openwrt_linux_gnu_base::opts();
+    base.cpu = "pentium4".to_string();
+    base.max_atomic_width = Some(64);
+    base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
+    // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
+    base.stack_probes = StackProbeType::Call;
+
+    Target {
+        llvm_target: "i686-openwrt-linux-gnu".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
+            f64:32:64-f80:32-n8:16:32-S128"
+            .to_string(),
+        arch: "x86".to_string(),
+        options: base,
+    }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/mips_openwrt_linux_gnu.rs
@@ -0,0 +1,20 @@
+use crate::abi::Endian;
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "mips-openwrt-linux-gnu".to_string(),
+        pointer_width: 32,
+        data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
+        arch: "mips".to_string(),
+        options: TargetOptions {
+            endian: Endian::Big,
+            cpu: "mips32r2".to_string(),
+            features: "+mips32r2,+soft-float,+nooddspreg".to_string(),
+            max_atomic_width: Some(32),
+            mcount: "_mcount".to_string(),
+
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/mipsel_openwrt_linux_gnu.rs
@@ -0,0 +1,19 @@
+use crate::spec::{Target, TargetOptions};
+
+pub fn target() -> Target {
+    Target {
+        llvm_target: "mipsel-openwrt-linux-gnu".to_string(),
+        pointer_width: 32,
+        data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
+        arch: "mips".to_string(),
+
+        options: TargetOptions {
+            cpu: "mips32r2".to_string(),
+            features: "+mips32r2,+soft-float,+nooddspreg".to_string(),
+            max_atomic_width: Some(32),
+            mcount: "_mcount".to_string(),
+
+            ..super::openwrt_linux_gnu_base::opts()
+        },
+    }
+}
--- a/vendor/rustc-ap-rustc_target/src/spec/mod.rs
+++ b/vendor/rustc-ap-rustc_target/src/spec/mod.rs
@@ -73,6 +73,8 @@ mod linux_uclibc_base;
 mod msvc_base;
 mod netbsd_base;
 mod openbsd_base;
+mod openwrt_linux_base;
+mod openwrt_linux_gnu_base;
 mod redox_base;
 mod riscv_base;
 mod solaris_base;
@@ -701,6 +703,18 @@ macro_rules! supported_targets {
 }
 
 supported_targets! {
+    ("aarch64-openwrt-linux-gnu", aarch64_openwrt_linux_gnu),
+    ("arm-openwrt-linux-gnueabi", arm_openwrt_linux_gnueabi),
+    ("armv5te-openwrt-linux-gnueabi", armv5te_openwrt_linux_gnueabi),
+    ("armv7-openwrt-linux-gnueabi", armv7_openwrt_linux_gnueabi),
+    ("i386-openwrt-linux-gnu", i386_openwrt_linux_gnu),
+    ("i486-openwrt-linux-gnu", i486_openwrt_linux_gnu),
+    ("i586-openwrt-linux-gnu", i586_openwrt_linux_gnu),
+    ("i686-openwrt-linux-gnu", i686_openwrt_linux_gnu),
+    ("mips-openwrt-linux-gnu", mips_openwrt_linux_gnu),
+    ("mipsel-openwrt-linux-gnu", mipsel_openwrt_linux_gnu),
+    ("x86_64-openwrt-linux-gnu", x86_64_openwrt_linux_gnu),
+
     ("x86_64-unknown-linux-gnu", x86_64_unknown_linux_gnu),
     ("x86_64-unknown-linux-gnux32", x86_64_unknown_linux_gnux32),
     ("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/openwrt_linux_base.rs
@@ -0,0 +1,16 @@
+use crate::spec::{RelroLevel, TargetOptions};
+
+pub fn opts() -> TargetOptions {
+    TargetOptions {
+        os: "linux".to_string(),
+        dynamic_linking: true,
+        executables: true,
+        families: vec!["unix".to_string()],
+        has_rpath: false,
+        position_independent_executables: false,
+        relro_level: RelroLevel::None,
+        has_elf_tls: true,
+        crt_static_respected: true,
+        ..Default::default()
+    }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/openwrt_linux_gnu_base.rs
@@ -0,0 +1,5 @@
+use crate::spec::TargetOptions;
+
+pub fn opts() -> TargetOptions {
+    TargetOptions { env: "gnu".to_string(), ..super::openwrt_linux_base::opts() }
+}
--- /dev/null
+++ b/vendor/rustc-ap-rustc_target/src/spec/x86_64_openwrt_linux_gnu.rs
@@ -0,0 +1,21 @@
+use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
+
+pub fn target() -> Target {
+    let mut base = super::openwrt_linux_gnu_base::opts();
+    base.cpu = "x86-64".to_string();
+    base.max_atomic_width = Some(64);
+    base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".to_string());
+    // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
+    base.stack_probes = StackProbeType::Call;
+    base.supported_sanitizers =
+        SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD;
+
+    Target {
+        llvm_target: "x86_64-openwrt-linux-gnu".to_string(),
+        pointer_width: 64,
+        data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+            .to_string(),
+        arch: "x86_64".to_string(),
+        options: base,
+    }
+}
Свернуть
cat cargo.mk

Код: Выделить всё

# deps ???
#PKG_BUILD_DEPENDS:=rustc

CARGO_BUILD_DIR = $(PKG_BUILD_DIR)$(if $(CARGO_BINARY_SUBDIR),/$(CARGO_BINARY_SUBDIR))
CARGO:=$(STAGING_DIR)/host/bin/cargo
CARGO_HOME:=$(STAGING_DIR)/host/share/cargo
CARGO_TARGET_DIR:=$(PKG_BUILD_DIR)/openwrt-build
RUSTC:=$(STAGING_DIR)/host/bin/rustc
RUSTC_WRAPPER:=$(STAGING_DIR)/host/bin/rustc
RUSTDOC:=$(STAGING_DIR)/host/bin/rustdoc
RUSTFMT:=$(STAGING_DIR)/host/bin/rustfmt

RUST_TARGET_TRIPLE:=$(REAL_GNU_TARGET_NAME)

CARGO_ARGS:=
CARGO_VARS:=
RUSTC_VARS:=
RUSTFLAGS:=

# target
#RUST_TARGET_TRIPLE:=

#ifeq ($(CONFIG_TARGET_armv5_3_2),y)
#RUST_TARGET_TRIPLE=armv5te-openwrt-linux-gnueabi
#else
#ifeq ($(or $(CONFIG_TARGET_armv7_2_6),$(CONFIG_TARGET_armv7_3_2)),y)
#RUST_TARGET_TRIPLE=armv7-openwrt-linux-gnueabi
#else
#ifeq ($(CONFIG_TARGET_x86_2_6),y)
#RUST_TARGET_TRIPLE=i486-openwrt-linux-gnu
#else
#RUST_TARGET_TRIPLE=$(REAL_GNU_TARGET_NAME)
#endif
#endif
#endif

# for *-sys
RUSTC_VARS = \
	CRATE_CC_NO_DEFAULTS="" \
	CROSS_COMPILE="$(RUST_TARGET_TRIPLE)" \
	PKG_CONFIG_ALLOW_CROSS=1 \
	PKG_CONFIG_PATH="$(STAGING_DIR)/opt/lib/pkgconfig:$(STAGING_DIR)/opt/share/pkgconfig" \
	PKG_CONFIG_SYSROOT_DIR="$(STAGING_DIR)/opt" \
	TARGET="$(RUST_TARGET_TRIPLE)" \
	AR="${TARGET_AR}" \
	CC="${TARGET_CC}" \
	CXX="${TARGET_CXX}" \
	CFLAGS="${TARGET_CFLAGS}" \
	CXXFLAGS="${TARGET_CXXFLAGS}" \
	TARGET_AR="${TARGET_AR}" \
	TARGET_CC="${TARGET_CC}" \
	TARGET_CXX="${TARGET_CXX}" \
	TARGET_CFLAGS="${TARGET_CFLAGS}" \
	TARGET_CXXFLAGS="${TARGET_CXXFLAGS}" \
	HOST_AR="${AR}" \
	HOST_CC="${HOSTCC}" \
	HOST_CXX="${HOSTCXX}" \
	HOST_CFLAGS="${HOST_CFLAGS}" \
	HOST_CXXFLAGS="${HOST_CFLAGS}"

# FIXME: */cargo: undefined symbol: ENGINE_init, version OPENSSL_1_1_0
#ifeq ($(CONFIG_x86_64),)
#RUSTC_VARS += \
#	LD_LIBRARY_PATH="$(STAGING_DIR)/opt/lib"
#endif

RUSTFLAGS += \
	-C embed-bitcode=yes \
	-C link-arg=-Wl,--dynamic-linker=/opt/lib/$(DYNLINKER) \
	-C linker=$(TARGET_CROSS)gcc \
	-C opt-level=z \
	-C panic=abort \
	-C relocation-model=static \
	-Z strip=symbols

define Build/Configure/Cargo
endef
#	( [ -f $(PKG_BUILD_DIR)/.cargo/config.toml ]; $(RM) $(PKG_BUILD_DIR)/.catgo/config.toml ; \
#		$(INSTALL_DIR) $(PKG_BUILD_DIR)/.cargo; \
#	( \
#		echo '[target.$(RUST_TARGET_TRIPLE)]'; \
#		echo 'linker = "$(TARGET_CROSS)gcc"'; \
#		echo '[install]'; \
#		echo 'root = "$(PKG_INSTALL_DIR)/opt"'; \
#	) > $(PKG_BUILD_DIR)/.cargo/config.toml ; \
#	)
#endef

define Build/Compile/Cargo
endef
#	( \
#		cd $(CARGO_BUILD_DIR); \
#		$(RUSTC_VARS) \
#		RUSTFLAGS="$(RUSTFLAGS)" \
#		CARGO_HOME="$(CARGO_HOME)" \
#		CARGO_TARGET_DIR="$(CARGO_TARGET_DIR)" \
#		$(CARGO) build \
#		$(CARGO_ARGS) \
#		--target $(RUST_TARGET_TRIPLE) \
#		--release \
#		$(CARGO_VARS); \
#	)
#endef

define Build/Install/Cargo
	( \
		cd $(CARGO_BUILD_DIR); \
		$(RUSTC_VARS) \
		RUSTFLAGS="$(RUSTFLAGS)" \
		CARGO_HOME="$(CARGO_HOME)" \
		CARGO_TARGET_DIR="$(CARGO_TARGET_DIR)" \
		$(CARGO) install \
		$(CARGO_ARGS) \
		--path . \
		--root $(PKG_INSTALL_DIR)/opt \
		--target $(RUST_TARGET_TRIPLE) \
		$(CARGO_VARS); \
	)
endef

Build/Configure=$(call Build/Configure/Cargo)
Build/Compile=$(call Build/Compile/Cargo)
Build/Install=$(call Build/Install/Cargo)
Свернуть
^ as is

Из известного:

1) если в зависимости от зависимости зависимости зависимости... (здесь пламенный привет go, python, node и подобным) есть ring, mips`ы идут тёмным лесом, дальним полем - не то, что не взлетит, а даже не соберётся.
(тут ссыль на проект https://github.com/briansmith/ring | https://github.com/briansmith/ring/search?q=mips&type=issues)

2) т.к. таргеты растишки переименованы в $(REAL_GNU_TARGET_NAME), есть шанс отвала сборки на некоторых проектах, но решаемо, типа:
https://github.com/BurntSushi/memchr/blob/master/build.rs
fix for @(aarch64||arm||mips||mipsel):

Код: Выделить всё

RUSTFLAGS += --cfg memchr_disable_auto_simd

https://github.com/crossbeam-rs/crossbeam/blob/master/no_atomic.rs
fix for @(arm||mips||mipsel):

Код: Выделить всё

RUSTFLAGS += --cfg crossbeam_no_atomic_64

3) x11* - как повезёт...

а тут картинки:
btm (bottom) https://github.com/ClementTsang/bottom
 
screen_btm.png
Свернуть
coreutils-rs https://github.com/uutils/coreutils
 
screen_coreutils-rs.png
Свернуть
dust https://github.com/bootandy/dust
 
screen_dust.png
Свернуть
gping https://github.com/orf/gping
 
screen_gping.png
Свернуть
nushell https://github.com/nushell/nushell
 
screen_nushell.png
Свернуть
ripgrep https://github.com/BurntSushi/ripgrep
 
screen_ripgrep.png
Свернуть
rustscan https://github.com/RustScan/RustScan
 
screen_rustscan.png
Свернуть
sniffglue https://github.com/kpcyrd/sniffglue
замазывать было лень, смотрим на сайте
---
фиксик: было `RUSTC_VARS += \`, стало `RUSTC_VARS = \`
У вас нет необходимых прав для просмотра вложений в этом сообщении.

Аватара пользователя
TheBB
Сообщения: 107
Зарегистрирован: 31 авг 2015, 02:24
Откуда: 26 ~44.098,43.022

Сообщение TheBB » 29 ноя 2021, 12:43

неск-ко примеров Makefile`ов
cat rustscan/Makefile

Код: Выделить всё

# SPDX-License-Identifier: WTFPL
# XXX ring (asm?)

include $(TOPDIR)/rules.mk

PKG_NAME:=rustscan
PKG_VERSION:=2.0.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/RustScan/RustScan/tar.gz/refs/tags/$(PKG_VERSION)?
PKG_HASH:=skip

PKG_BUILD_DIR:=$(BUILD_DIR)/RustScan-$(PKG_VERSION)

PKG_LICENSE:=GPL-3.0-only

include $(INCLUDE_DIR)/package.mk
include ../cargo.mk

define Package/rustscan
  SECTION:=net
  CATEGORY:=Network
  TITLE:=The Modern Port Scanner
  URL:=https://github.com/RustScan/RustScan
  DEPENDS:=@!(mips||mipsel) +nmap +TARGET_x86_2_6:libatomic
endef

define Package/rustscan/description
  The Modern Port Scanner.
endef

CARGO_VARS += -v

ifeq ($(or $(CONFIG_aarch64),$(CONFIG_i386),$(CONFIG_x86_64)),)
RUSTFLAGS += \
	--cfg crossbeam_no_atomic_64
endif

ifeq ($(or $(CONFIG_i386),$(CONFIG_x86_64)),y)
RUSTFLAGS += \
	-C link-arg=-lssp
endif

ifeq ($(CONFIG_i386),y)
RUSTFLAGS += \
	-C link-arg=-latomic
endif

define Package/rustscan/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/rustscan $(1)/opt/usr/bin
endef

$(eval $(call BuildPackage,rustscan))
Свернуть
^ ring
cat ripgrep/Makefile

Код: Выделить всё

# SPDX-License-Identifier: WTFPL

include $(TOPDIR)/rules.mk

PKG_NAME:=ripgrep
PKG_VERSION:=13.0.0
PKG_RELEASE:=3

PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=ba535fb5a34f6d703fc652e8dfc23c0fed78fc74
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
PKG_SOURCE_URL:=https://github.com/BurntSushi/ripgrep
PKG_MIRROR_HASH:=skip

PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE-MIT

PKG_CONFIG_DEPENDS:= \
	CONFIG_RIPGREP_PCRE2

include $(INCLUDE_DIR)/package.mk
include ../cargo.mk

define Package/ripgrep
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=a line-oriented search tool
  URL:=https://github.com/BurntSushi/ripgrep
  DEPENDS:=+RIPGREP_PCRE2:libpcre2
endef

define Package/ripgrep/description
  .
  ripgrep is a line-oriented search tool that recursively searches the current
  directory for a regex pattern while respecting gitignore rules. ripgrep has
  first class support on Windows, macOS and Linux.
endef

define Package/ripgrep/config
config RIPGREP_PCRE2
	depends on PACKAGE_ripgrep
	bool "PCRE2 support"
	default n
endef

CARGO_ARGS += \
	$(if $(CONFIG_RIPGREP_PCRE2),--features 'pcre2')

RUSTFLAGS += \
	-C lto=yes

ifeq ($(or $(CONFIG_aarch64),$(CONFIG_i386),$(CONFIG_x86_64)),)
RUSTFLAGS += \
	--cfg crossbeam_no_atomic_64
endif

define Package/ripgrep/install
	$(INSTALL_DIR) $(1)/opt/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/rg $(1)/opt/bin
endef

$(eval $(call BuildPackage,ripgrep))
Свернуть
^ crossbeam
cat nushell/patches/610-no-x11.patch

Код: Выделить всё

--- a/Cargo.lock
+++ b/Cargo.lock
@@ -119,7 +119,6 @@ dependencies = [
  "scopeguard",
  "thiserror",
  "winapi 0.3.9",
- "x11rb",
 ]
 
 [[package]]
@@ -4019,7 +4018,6 @@ dependencies = [
  "readkey",
  "user32-sys",
  "winapi 0.3.9",
- "x11",
 ]
 
 [[package]]
@@ -5567,28 +5565,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "x11"
-version = "2.18.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77ecd092546cb16f25783a5451538e73afc8d32e242648d54f4ae5459ba1e773"
-dependencies = [
- "libc",
- "pkg-config",
-]
-
-[[package]]
-name = "x11rb"
-version = "0.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ffb080b3f2f616242a4eb8e7d325035312127901025b0052bc3154a282d0f19"
-dependencies = [
- "gethostname",
- "nix 0.20.1",
- "winapi 0.3.9",
- "winapi-wsapoll",
-]
-
-[[package]]
 name = "xml-rs"
 version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
Свернуть
cat nushell/patches/620-fix-binaryview.patch

Код: Выделить всё

# rawkey wants x11
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2918,7 +2918,6 @@ dependencies = [
  "nu-pretty-hex",
  "nu-protocol",
  "nu-source",
- "rawkey",
 ]
 
 [[package]]
--- a/crates/nu_plugin_binaryview/src/binaryview.rs
+++ b/crates/nu_plugin_binaryview/src/binaryview.rs
@@ -308,7 +308,7 @@ pub fn view_contents_interactive(
     source: Option<&AnchorLocation>,
     lores_mode: bool,
 ) -> Result<(), Box<dyn std::error::Error>> {
-    use rawkey::{KeyCode, RawKey};
+//    use rawkey::{KeyCode, RawKey};
 
     let sav_path = if let Some(AnchorLocation::File(f)) = source {
         let mut path = std::path::PathBuf::from(f);
@@ -319,7 +319,7 @@ pub fn view_contents_interactive(
     };
 
     let mut nes = neso::Nes::new(0.0);
-    let rawkey = RawKey::new();
+//    let rawkey = RawKey::new();
     nes.load_rom(buffer);
 
     if let Some(ref sav_path) = sav_path {
@@ -333,16 +333,16 @@ pub fn view_contents_interactive(
     if let Ok(_raw) = crossterm::terminal::enable_raw_mode() {
         let mut render_context: RenderContext = RenderContext::blank(lores_mode);
 
-        let buttons = vec![
-            KeyCode::Alt,
-            KeyCode::LeftControl,
-            KeyCode::Tab,
-            KeyCode::BackSpace,
-            KeyCode::UpArrow,
-            KeyCode::DownArrow,
-            KeyCode::LeftArrow,
-            KeyCode::RightArrow,
-        ];
+        let buttons = [0];
+//            KeyCode::Alt,
+//            KeyCode::LeftControl,
+//            KeyCode::Tab,
+//            KeyCode::BackSpace,
+//            KeyCode::UpArrow,
+//            KeyCode::DownArrow,
+//            KeyCode::LeftArrow,
+//            KeyCode::RightArrow,
+//        ];
 
         let _ = std::io::stdout().execute(crossterm::cursor::Hide);
 
@@ -372,16 +372,16 @@ pub fn view_contents_interactive(
             }
             render_context.flush();
 
-            if rawkey.is_pressed(rawkey::KeyCode::Escape) {
-                break 'gameloop;
-            } else {
+//            if rawkey.is_pressed(rawkey::KeyCode::Escape) {
+//                break 'gameloop;
+//            } else {
                 for (idx, button) in buttons.iter().enumerate() {
-                    if rawkey.is_pressed(*button) {
-                        nes.press_button(0, idx as u8);
-                    } else {
+//                    if rawkey.is_pressed(*button) {
+//                        nes.press_button(0, idx as u8);
+//                    } else {
                         nes.release_button(0, idx as u8);
                     }
-                }
+//                }
                 loop {
                     let x = crossterm::event::poll(std::time::Duration::from_secs(0));
                     match x {
@@ -394,7 +394,7 @@ pub fn view_contents_interactive(
                         }
                     }
                 }
-            }
+//            }
         }
     }
 
--- a/crates/nu_plugin_binaryview/Cargo.toml
+++ b/crates/nu_plugin_binaryview/Cargo.toml
@@ -19,6 +19,5 @@ nu-protocol = { path="../nu-protocol", v
 nu-source = { path="../nu-source", version = "0.40.0" }
 nu-ansi-term = { version = "0.40.0", path="../nu-ansi-term" }
 nu-pretty-hex = { version = "0.40.0", path="../nu-pretty-hex" }
-rawkey = "0.1.3"
 
 [build-dependencies]
Свернуть
cat nushell/Makefile

Код: Выделить всё

# SPDX-License-Identifier: WTFPL

include $(TOPDIR)/rules.mk

PKG_NAME:=nushell
PKG_VERSION:=0.40.0
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/nushell/nushell/tar.gz/refs/tags/$(PKG_VERSION)?
PKG_HASH:=skip

PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE

include $(INCLUDE_DIR)/package.mk
include ../cargo.mk

define Package/nushell/Default
  SECTION:=utils
  CATEGORY:=Utilities
  SUBMENU:=Shells
  TITLE:=A new type of shell
  URL:=https://www.nushell.sh/
endef

define Package/nushell
  $(call Package/nushell/Default)
  DEPENDS:=+libopenssl +zlib +TARGET_x86_2_6:libatomic
  MENU:=1
endef

define Package/nu_plugin_core_inc
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_core_match
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_core_textview
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell +less
endef

define Package/nu_plugin_extra_binaryview
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_chart_bar
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_chart_line
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_from_bson
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_from_sqlite
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_query_json
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_s3
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_selector
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_start
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_to_bson
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_to_sqlite
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_tree
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nu_plugin_extra_xpath
  $(call Package/nushell/Default)
  TITLE+= (plugin)
  DEPENDS:=nushell
endef

define Package/nushell/description
  A new type of shell.
endef

Package/nu_plugin_core_inc/description=$(Package/nushell/description)
Package/nu_plugin_core_match/description=$(Package/nushell/description)
Package/nu_plugin_core_textview/description=$(Package/nushell/description)
Package/nu_plugin_extra_binaryview/description=$(Package/nushell/description)
Package/nu_plugin_extra_chart_bar/description=$(Package/nushell/description)
Package/nu_plugin_extra_chart_line/description=$(Package/nushell/description)
Package/nu_plugin_extra_from_bson/description=$(Package/nushell/description)
Package/nu_plugin_extra_from_sqlite/description=$(Package/nushell/description)
Package/nu_plugin_extra_query_json/description=$(Package/nushell/description)
Package/nu_plugin_extra_s3/description=$(Package/nushell/description)
Package/nu_plugin_extra_selector/description=$(Package/nushell/description)
Package/nu_plugin_extra_start/description=$(Package/nushell/description)
Package/nu_plugin_extra_to_bson/description=$(Package/nushell/description)
Package/nu_plugin_extra_to_sqlite/description=$(Package/nushell/description)
Package/nu_plugin_extra_tree/description=$(Package/nushell/description)
Package/nu_plugin_extra_xpath/description=$(Package/nushell/description)

CARGO_ARGS += \
	--features=extra

ifeq ($(or $(CONFIG_i386),$(CONFIG_x86_64)),)
RUSTFLAGS += \
	--cfg memchr_disable_auto_simd
endif

ifeq ($(or $(CONFIG_aarch64),$(CONFIG_i386),$(CONFIG_x86_64)),)
RUSTFLAGS += \
	--cfg crossbeam_no_atomic_64
endif

ifeq ($(CONFIG_i386),y)
RUSTFLAGS += \
	-C link-arg=-latomic
endif

define Package/nushell/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu $(1)/opt/usr/bin
endef

define Package/nu_plugin_core_inc/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_core_inc \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_core_match/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_core_match \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_core_textview/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_core_textview \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_binaryview/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_binaryview \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_chart_bar/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_chart_bar \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_chart_line/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_chart_line \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_from_bson/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_from_bson \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_from_sqlite/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_from_sqlite \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_query_json/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_query_json \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_s3/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_s3 \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_selector/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_selector \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_start/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_start \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_to_bson/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_to_bson \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_to_sqlite/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_to_sqlite \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_tree/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_tree \
		$(1)/opt/usr/bin
endef

define Package/nu_plugin_extra_xpath/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/nu_plugin_extra_xpath \
		$(1)/opt/usr/bin
endef

$(eval $(call BuildPackage,nushell))
$(eval $(call BuildPackage,nu_plugin_core_inc))
$(eval $(call BuildPackage,nu_plugin_core_match))
$(eval $(call BuildPackage,nu_plugin_core_textview))
$(eval $(call BuildPackage,nu_plugin_extra_binaryview))
$(eval $(call BuildPackage,nu_plugin_extra_chart_bar))
$(eval $(call BuildPackage,nu_plugin_extra_chart_line))
$(eval $(call BuildPackage,nu_plugin_extra_from_bson))
$(eval $(call BuildPackage,nu_plugin_extra_from_sqlite))
$(eval $(call BuildPackage,nu_plugin_extra_query_json))
$(eval $(call BuildPackage,nu_plugin_extra_s3))
$(eval $(call BuildPackage,nu_plugin_extra_selector))
$(eval $(call BuildPackage,nu_plugin_extra_start))
$(eval $(call BuildPackage,nu_plugin_extra_to_bson))
$(eval $(call BuildPackage,nu_plugin_extra_to_sqlite))
$(eval $(call BuildPackage,nu_plugin_extra_tree))
$(eval $(call BuildPackage,nu_plugin_extra_xpath))
Свернуть
^ x11/memchr/crossbeam
K Giga II NDMSv.2.06C/2.11D/2.15A + Entware-Keenetic/Entware&Gentoo; K DSL NDMSv.2.05C/2.11D + Entware-Keenetic/Entware&Debian 8.11/9.6

Аватара пользователя
TheBB
Сообщения: 107
Зарегистрирован: 31 авг 2015, 02:24
Откуда: 26 ~44.098,43.022

Сообщение TheBB » 01 дек 2021, 10:31

https://github.com/cloudflare/boringtun
Как-то было предложено собрать его. Собрал:

Код: Выделить всё

~ # ls -al boringtun_0.3.0-1*
-rw-r--r--    1 root     root        410019 Nov  4 22:54 boringtun_0.3.0-1_aarch64-3.10.ipk
~ #
Решил повторить сей "подвиг" снова и... опаньки (журнал/дневник не вёл, что сменилось в сборке и не вспомнить).
Собсна, ниже Makefile с набитыми костылями, под каждый таргет свой чопик )))
cat boringtun/Makefile

Код: Выделить всё

# SPDX-License-Identifier: WTFPL

include $(TOPDIR)/rules.mk

PKG_NAME:=boringtun
PKG_VERSION:=0.3.0
PKG_RELEASE:=2

PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=fa724a73f873954587d7460f7601d897f2022e2f
PKG_SOURCE_URL:=https://github.com/cloudflare/boringtun
PKG_MIRROR_HASH:=skip

PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE.md

include $(INCLUDE_DIR)/package.mk
include ../cargo.mk

define Package/boringtun
  SECTION:=net
  CATEGORY:=Network
  SUBMENU:=VPN
  TITLE:=Userspace WireGuard Implementation in Rust
  URL:=https://github.com/cloudflare/boringtun
  DEPENDS:=@!(mips||mipsel) +TARGET_x86_2_6:libatomic
endef

define Package/boringtun/description
  BoringTun is an implementation of the WireGuard® protocol designed
  for portability and speed.
endef

# XXX aarch64 & x64
ifeq ($(or $(CONFIG_aarch64),$(CONFIG_x86_64)),y)
TARGET_CFLAGS += -fPIC
RUSTFLAGS += \
	-C relocation-model=dynamic-no-pic
endif

# XXX arm* & mips*
ifeq ($(or $(CONFIG_aarch64),$(CONFIG_i386),$(CONFIG_x86_64)),)
RUSTFLAGS += \
	--cfg crossbeam_no_atomic_64
endif

# XXX arm*
ifeq ($(CONFIG_arm),y)
RUSTFLAGS += \
	-C relocation-model=pic
endif

# XXX x86
ifeq ($(CONFIG_i386),y)
RUSTFLAGS += \
	-l dylib=atomic \
	-l dylib=ssp
endif

RUSTFLAGS += \
	-C llvm-args=-slp-recursion-max-depth=1024 \
	--emit asm

define Package/boringtun/install
	$(INSTALL_DIR) $(1)/opt/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/bin/boringtun $(1)/opt/usr/bin
endef

$(eval $(call BuildPackage,boringtun))
Свернуть
arm

Код: Выделить всё

~ # uname -a
Linux localhost 3.0.101-g9800976 #2 PREEMPT Mon Jun 8 22:24:14 CEST 2015 armv7l GNU/Linux
~ #
~ # cat /proc/cpuinfo 
Processor	: ARMv7 Processor rev 2 (v7l)
BogoMIPS	: 99.26
Features	: swp half thumb fastmult vfp edsp thumbee neon vfpv3 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x2
CPU part	: 0xc08
CPU revision	: 2

Hardware	: wave2
Revision	: 0030
Serial		: 0000045600000123
~ # 
не взлетим, так попрыгаем

Код: Выделить всё

~ # boringtun --disable-multi-queue --disable-drop-privileges 1 --tun-fd=1 --uapi-fd=-1 -f -l /opt/var/log/bor.log -t 2 -v debug wg0
  Nov 30 14:35:21.028  INFO boringtun: BoringTun started successfully
    at src/main.rs:186

  Nov 30 14:35:23.017 ERROR boringtun::device: Poll error, error: "Interrupted system call"
    at src/device/mod.rs:289
...
  Nov 30 14:35:23.017 ERROR boringtun::device: Poll error, error: "Interrupted system call"
    at src/device/mod.rs:289
на aarch64 (KN-2710) завелось

Код: Выделить всё

~ # ps | grep -v grep | grep bor
31880 root      139m S    boringtun --disable-drop-privileges 0 -t 2 wg0
~ #
K Giga II NDMSv.2.06C/2.11D/2.15A + Entware-Keenetic/Entware&Gentoo; K DSL NDMSv.2.05C/2.11D + Entware-Keenetic/Entware&Debian 8.11/9.6


Вернуться в «Флейм»

Кто сейчас на конференции

Всего 0 посетителей :: 0 зарегистрированных, 0 скрытых и 0 гостей (основано на активности пользователей за последние 5 минут)
Больше всего посетителей (162) здесь было 16 ноя 2019, 18:33

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 0 гостей