Skip to content

Commit bd3fe49

Browse files
committed
Add support for i686-unknown-linux-musl
1 parent 81ba4a7 commit bd3fe49

File tree

5 files changed

+80
-2
lines changed

5 files changed

+80
-2
lines changed

mk/cfg/i686-unknown-linux-musl.mk

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# i686-unknown-linux-musl configuration
2+
CC_i686-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc
3+
CXX_i686-unknown-linux-musl=notaprogram
4+
CPP_i686-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc -E
5+
AR_i686-unknown-linux-musl=$(AR)
6+
CFG_INSTALL_ONLY_RLIB_i686-unknown-linux-musl = 1
7+
CFG_LIB_NAME_i686-unknown-linux-musl=lib$(1).so
8+
CFG_STATIC_LIB_NAME_i686-unknown-linux-musl=lib$(1).a
9+
CFG_LIB_GLOB_i686-unknown-linux-musl=lib$(1)-*.so
10+
CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386
11+
CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -Wall -Werror -g -fPIC -m32 -Wl,-melf_i386
12+
CFG_GCCISH_CXXFLAGS_i686-unknown-linux-musl :=
13+
CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-musl :=
14+
CFG_GCCISH_DEF_FLAG_i686-unknown-linux-musl :=
15+
CFG_LLC_FLAGS_i686-unknown-linux-musl :=
16+
CFG_INSTALL_NAME_i686-unknown-linux-musl =
17+
CFG_EXE_SUFFIX_i686-unknown-linux-musl =
18+
CFG_WINDOWSY_i686-unknown-linux-musl :=
19+
CFG_UNIXY_i686-unknown-linux-musl := 1
20+
CFG_LDPATH_i686-unknown-linux-musl :=
21+
CFG_RUN_i686-unknown-linux-musl=$(2)
22+
CFG_RUN_TARG_i686-unknown-linux-musl=$(call CFG_RUN_i686-unknown-linux-musl,,$(2))
23+
CFG_GNU_TRIPLE_i686-unknown-linux-musl := i686-unknown-linux-musl
24+
CFG_THIRD_PARTY_OBJECTS_i686-unknown-linux-musl := crt1.o crti.o crtn.o
25+
CFG_INSTALLED_OBJECTS_i686-unknown-linux-musl := crt1.o crti.o crtn.o
26+
27+
NATIVE_DEPS_libc_T_i686-unknown-linux-musl += libc.a
28+
NATIVE_DEPS_std_T_i686-unknown-linux-musl += libunwind.a crt1.o crti.o crtn.o

mk/main.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ export CFG_DISABLE_UNSTABLE_FEATURES
361361
export RUSTC_BOOTSTRAP_KEY:=$(CFG_BOOTSTRAP_KEY)
362362
endif
363363
export CFG_BOOTSTRAP_KEY
364+
ifdef CFG_MUSL_ROOT
365+
export CFG_MUSL_ROOT
366+
endif
364367

365368
######################################################################
366369
# Per-stage targets and runner
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// See x86_64_unknown_linux_musl for explanation of arguments
12+
13+
use target::Target;
14+
15+
pub fn target() -> Target {
16+
let mut base = super::linux_base::opts();
17+
base.cpu = "pentium4".to_string();
18+
base.pre_link_args.push("-m32".to_string());
19+
base.pre_link_args.push("-Wl,-melf_i386".to_string());
20+
21+
base.pre_link_args.push("-nostdlib".to_string());
22+
base.pre_link_args.push("-static".to_string());
23+
base.pre_link_args.push("-Wl,--eh-frame-hdr".to_string());
24+
25+
base.pre_link_args.push("-Wl,-(".to_string());
26+
base.post_link_args.push("-Wl,-)".to_string());
27+
28+
base.pre_link_objects_exe.push("crt1.o".to_string());
29+
base.pre_link_objects_exe.push("crti.o".to_string());
30+
base.post_link_objects.push("crtn.o".to_string());
31+
32+
base.dynamic_linking = false;
33+
base.has_rpath = false;
34+
base.position_independent_executables = false;
35+
36+
Target {
37+
llvm_target: "i686-unknown-linux-musl".to_string(),
38+
target_endian: "little".to_string(),
39+
target_pointer_width: "32".to_string(),
40+
arch: "x86".to_string(),
41+
target_os: "linux".to_string(),
42+
target_env: "musl".to_string(),
43+
target_vendor: "unknown".to_string(),
44+
options: base,
45+
}
46+
}

src/librustc_back/target/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ impl Target {
431431
armv7_unknown_linux_gnueabihf,
432432
aarch64_unknown_linux_gnu,
433433
x86_64_unknown_linux_musl,
434+
i686_unknown_linux_musl,
434435
mips_unknown_linux_musl,
435436
mipsel_unknown_linux_musl,
436437

src/libstd/sys/unix/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Drop for Thread {
168168
}
169169
}
170170

171-
#[cfg(all(not(target_os = "linux"),
171+
#[cfg(all(not(all(target_os = "linux", not(target_env = "musl"))),
172172
not(target_os = "macos"),
173173
not(target_os = "bitrig"),
174174
not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
@@ -181,7 +181,7 @@ pub mod guard {
181181
}
182182

183183

184-
#[cfg(any(target_os = "linux",
184+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")),
185185
target_os = "macos",
186186
target_os = "bitrig",
187187
all(target_os = "netbsd", not(target_vendor = "rumprun")),

0 commit comments

Comments
 (0)