aports/community/rust/alpine-target.patch
2018-02-17 16:08:01 +01:00

188 lines
7.0 KiB
Diff

From: Shiz <hi@shiz.me>
Date: Thu, 20 Aug 2017 01:52:36 +0200
Last-Updated: Sat, 28 Oct 2017 20:23:00 +0200
Subject: [PATCH] Add Alpine targets
This adds `$arch-alpine-linux-musl` targets to Rust to encode our toolchain
and distribution-specific quirks instead of polluting the main musl target of
`$arch-unknown-linux-musl`.
--- a/src/librustc_back/target/mod.rs
+++ b/src/librustc_back/target/mod.rs
@@ -234,6 +234,11 @@
("armv7-unknown-cloudabi-eabihf", armv7_unknown_cloudabi_eabihf),
("i686-unknown-cloudabi", i686_unknown_cloudabi),
("x86_64-unknown-cloudabi", x86_64_unknown_cloudabi),
+
+ ("i586-alpine-linux-musl", i586_alpine_linux_musl),
+ ("x86_64-alpine-linux-musl", x86_64_alpine_linux_musl),
+ ("aarch64-alpine-linux-musl", aarch64_alpine_linux_musl),
+ ("arm-alpine-linux-musleabihf", arm_alpine_linux_musleabihf),
}
/// Everything `rustc` knows about how to compile for a specific target.
--- /dev/null
+++ b/src/librustc_back/target/i586_alpine_linux_musl.rs
@@ -0,0 +1,36 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use LinkerFlavor;
+use target::{Target, TargetResult};
+
+pub fn target() -> TargetResult {
+ let mut base = super::linux_musl_base::opts();
+ base.cpu = "pentium4".to_string();
+ base.max_atomic_width = Some(64);
+ base.stack_probes = true;
+ base.crt_static_default = false;
+ base.static_position_independent_executables = true;
+ base.need_rpath = true;
+
+ Ok(Target {
+ llvm_target: "i586-alpine-linux-musl".to_string(),
+ target_endian: "little".to_string(),
+ target_pointer_width: "32".to_string(),
+ target_c_int_width: "32".to_string(),
+ data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
+ arch: "x86".to_string(),
+ target_os: "linux".to_string(),
+ target_env: "musl".to_string(),
+ target_vendor: "alpine".to_string(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: base,
+ })
+}
--- /dev/null
+++ b/src/librustc_back/target/x86_64_alpine_linux_musl.rs
@@ -0,0 +1,36 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use LinkerFlavor;
+use target::{Target, TargetResult};
+
+pub fn target() -> TargetResult {
+ let mut base = super::linux_musl_base::opts();
+ base.cpu = "x86-64".to_string();
+ base.max_atomic_width = Some(64);
+ base.stack_probes = true;
+ base.crt_static_default = false;
+ base.static_position_independent_executables = true;
+ base.need_rpath = true;
+
+ Ok(Target {
+ llvm_target: "x86_64-alpine-linux-musl".to_string(),
+ target_endian: "little".to_string(),
+ target_pointer_width: "64".to_string(),
+ target_c_int_width: "32".to_string(),
+ data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
+ arch: "x86_64".to_string(),
+ target_os: "linux".to_string(),
+ target_env: "musl".to_string(),
+ target_vendor: "alpine".to_string(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: base,
+ })
+}
--- /dev/null
+++ b/src/librustc_back/target/aarch64_alpine_linux_musl.rs
@@ -0,0 +1,39 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use LinkerFlavor;
+use target::{Target, TargetOptions, TargetResult};
+
+pub fn target() -> TargetResult {
+ let mut base = super::linux_musl_base::opts();
+ base.max_atomic_width = Some(128);
+ base.crt_static_default = false;
+ base.static_position_independent_executables = true;
+ base.need_rpath = true;
+ // see #36994
+ base.exe_allocation_crate = None;
+
+ Ok(Target {
+ llvm_target: "aarch64-alpine-linux-musl".to_string(),
+ target_endian: "little".to_string(),
+ target_pointer_width: "64".to_string(),
+ target_c_int_width: "32".to_string(),
+ data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
+ arch: "aarch64".to_string(),
+ target_os: "linux".to_string(),
+ target_env: "musl".to_string(),
+ target_vendor: "alpine".to_string(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: TargetOptions {
+ abi_blacklist: super::arm_base::abi_blacklist(),
+ .. base
+ },
+ })
+}
--- /dev/null
+++ b/src/librustc_back/target/arm_alpine_linux_musleabihf.rs
@@ -0,0 +1,41 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use LinkerFlavor;
+use target::{Target, TargetOptions, TargetResult};
+
+pub fn target() -> TargetResult {
+ let mut base = super::linux_musl_base::opts();
+
+ // Most of these settings are copied from the arm_unknown_linux_gnueabihf
+ // target.
+ base.features = "+v6,+vfp2".to_string();
+ base.max_atomic_width = Some(64);
+ base.crt_static_default = false;
+ base.static_position_independent_executables = true;
+ base.need_rpath = true;
+
+ Ok(Target {
+ llvm_target: "arm-alpine-linux-musleabihf".to_string(),
+ target_endian: "little".to_string(),
+ target_pointer_width: "32".to_string(),
+ target_c_int_width: "32".to_string(),
+ data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+ arch: "arm".to_string(),
+ target_os: "linux".to_string(),
+ target_env: "musl".to_string(),
+ target_vendor: "alpine".to_string(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: TargetOptions {
+ abi_blacklist: super::arm_base::abi_blacklist(),
+ .. base
+ },
+ })
+}