From: Shiz Date: Thu, 20 Aug 2017 01:52:36 +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`. --- /dev/null +++ b/src/librustc_back/target/i586_alpine_linux_musl.rs @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +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.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(), + 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(), + options: base, + }) +} --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -214,6 +214,9 @@ ("thumbv7m-none-eabi", thumbv7m_none_eabi), ("thumbv7em-none-eabi", thumbv7em_none_eabi), ("thumbv7em-none-eabihf", thumbv7em_none_eabihf), + + ("i586-alpine-linux-musl", i586_alpine_linux_musl), + ("x86_64-alpine-linux-musl", x86_64_alpine_linux_musl), } /// Everything `rustc` knows about how to compile for a specific target. --- /dev/null +++ b/src/librustc_back/target/x86_64_alpine_linux_musl.rs @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +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.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(), + 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(), + options: base, + }) +} --- /dev/null +++ b/mk/cfg/i586-alpine-linux-musl.mk @@ -0,0 +1,29 @@ +# i586-alpine-linux-musl configuration +CC_i586-alpine-linux-musl=$(CC) +CXX_i586-alpine-linux-musl=$(CXX) +CPP_i586-alpine-linux-musl=$(CPP) +AR_i586-alpine-linux-musl=$(AR) +CFG_INSTALL_ONLY_RLIB_i586-alpine-linux-musl = 0 +CFG_LIB_NAME_i586-alpine-linux-musl=lib$(1).so +CFG_STATIC_LIB_NAME_i586-alpine-linux-musl=lib$(1).a +CFG_LIB_GLOB_i586-alpine-linux-musl=lib$(1)-*.so +CFG_JEMALLOC_CFLAGS_i586-alpine-linux-musl := +CFG_GCCISH_CFLAGS_i586-alpine-linux-musl := -g -fPIC +CFG_GCCISH_CXXFLAGS_i586-alpine-linux-musl := +CFG_GCCISH_LINK_FLAGS_i586-alpine-linux-musl := +CFG_GCCISH_DEF_FLAG_i586-alpine-linux-musl := +CFG_LLC_FLAGS_i586-alpine-linux-musl := +CFG_INSTALL_NAME_i586-alpine-linux-musl = +CFG_EXE_SUFFIX_i586-alpine-linux-musl = +CFG_WINDOWSY_i586-alpine-linux-musl := +CFG_UNIXY_i586-alpine-linux-musl := 1 +CFG_LDPATH_i586-alpine-linux-musl := +CFG_RUN_i586-alpine-linux-musl=$(2) +CFG_RUN_TARG_i586-alpine-linux-musl=$(call CFG_RUN_i586-alpine-linux-musl,,$(2)) +CFG_GNU_TRIPLE_i586-alpine-linux-musl := i586-alpine-linux-musl +CFG_THIRD_PARTY_OBJECTS_i586-alpine-linux-musl := +CFG_INSTALLED_OBJECTS_i586-alpine-linux-musl := + +NATIVE_DEPS_libc_T_i586-alpine-linux-musl += libc.a +NATIVE_DEPS_std_T_i586-alpine-linux-musl += +NATIVE_DEPS_unwind_T_i586-alpine-linux-musl += libunwind.a --- /dev/null +++ b/mk/cfg/x86_64-alpine-linux-musl.mk @@ -0,0 +1,29 @@ +# x86_64-alpine-linux-musl configuration +CC_x86_64-alpine-linux-musl=$(CC) +CXX_x86_64-alpine-linux-musl=$(CXX) +CPP_x86_64-alpine-linux-musl=$(CPP) +AR_x86_64-alpine-linux-musl=$(AR) +CFG_INSTALL_ONLY_RLIB_x86_64-alpine-linux-musl = 0 +CFG_LIB_NAME_x86_64-alpine-linux-musl=lib$(1).so +CFG_STATIC_LIB_NAME_x86_64-alpine-linux-musl=lib$(1).a +CFG_LIB_GLOB_x86_64-alpine-linux-musl=lib$(1)-*.so +CFG_JEMALLOC_CFLAGS_x86_64-alpine-linux-musl := +CFG_GCCISH_CFLAGS_x86_64-alpine-linux-musl := -g -fPIC +CFG_GCCISH_CXXFLAGS_x86_64-alpine-linux-musl := +CFG_GCCISH_LINK_FLAGS_x86_64-alpine-linux-musl := +CFG_GCCISH_DEF_FLAG_x86_64-alpine-linux-musl := +CFG_LLC_FLAGS_x86_64-alpine-linux-musl := +CFG_INSTALL_NAME_x86_64-alpine-linux-musl = +CFG_EXE_SUFFIX_x86_64-alpine-linux-musl = +CFG_WINDOWSY_x86_64-alpine-linux-musl := +CFG_UNIXY_x86_64-alpine-linux-musl := 1 +CFG_LDPATH_x86_64-alpine-linux-musl := +CFG_RUN_x86_64-alpine-linux-musl=$(2) +CFG_RUN_TARG_x86_64-alpine-linux-musl=$(call CFG_RUN_x86_64-alpine-linux-musl,,$(2)) +CFG_GNU_TRIPLE_x86_64-alpine-linux-musl := x86_64-alpine-linux-musl +CFG_THIRD_PARTY_OBJECTS_x86_64-alpine-linux-musl := +CFG_INSTALLED_OBJECTS_x86_64-alpine-linux-musl := + +NATIVE_DEPS_libc_T_x86_64-alpine-linux-musl += libc.a +NATIVE_DEPS_std_T_x86_64-alpine-linux-musl += +NATIVE_DEPS_unwind_T_x86_64-alpine-linux-musl += libunwind.a