Skip to content

Commit 8110338

Browse files
committed
Auto merge of #31298 - japaric:mips-musl, r=alexcrichton
This target covers MIPS devices that run the trunk version of OpenWRT. The x86_64-unknown-linux-musl target always links statically to C libraries. For the mips(el)-unknown-linux-musl target, we opt for dynamic linking (like most of other targets do) to keep binary size down. As for the C compiler flags used in the build system, we use the same flags used for the mips(el)-unknown-linux-gnu target. r? @alexcrichton
2 parents 9a07087 + 64ac041 commit 8110338

9 files changed

+120
-4
lines changed

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ do
11641164
;;
11651165

11661166

1167-
*-musl)
1167+
x86_64-*-musl)
11681168
if [ ! -f $CFG_MUSL_ROOT/lib/libc.a ]
11691169
then
11701170
err "musl libc $CFG_MUSL_ROOT/lib/libc.a not found"

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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# mips-unknown-linux-musl configuration
2+
CC_mips-unknown-linux-musl=mips-linux-musl-gcc
3+
CXX_mips-unknown-linux-musl=mips-linux-musl-g++
4+
CPP_mips-unknown-linux-musl=mips-linux-musl-gcc -E
5+
AR_mips-unknown-linux-musl=mips-linux-musl-ar
6+
CFG_LIB_NAME_mips-unknown-linux-musl=lib$(1).so
7+
CFG_STATIC_LIB_NAME_mips-unknown-linux-musl=lib$(1).a
8+
CFG_LIB_GLOB_mips-unknown-linux-musl=lib$(1)-*.so
9+
CFG_LIB_DSYM_GLOB_mips-unknown-linux-musl=lib$(1)-*.dylib.dSYM
10+
CFG_JEMALLOC_CFLAGS_mips-unknown-linux-musl := -mips32r2 -msoft-float -mabi=32 $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_mips-unknown-linux-musl := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32 $(CFLAGS)
12+
CFG_GCCISH_CXXFLAGS_mips-unknown-linux-musl := -fno-rtti $(CXXFLAGS)
13+
CFG_GCCISH_LINK_FLAGS_mips-unknown-linux-musl := -shared -fPIC -g -mips32r2 -msoft-float -mabi=32
14+
CFG_GCCISH_DEF_FLAG_mips-unknown-linux-musl := -Wl,--export-dynamic,--dynamic-list=
15+
CFG_LLC_FLAGS_mips-unknown-linux-musl :=
16+
CFG_INSTALL_NAME_mips-unknown-linux-musl =
17+
CFG_EXE_SUFFIX_mips-unknown-linux-musl =
18+
CFG_WINDOWSY_mips-unknown-linux-musl :=
19+
CFG_UNIXY_mips-unknown-linux-musl := 1
20+
CFG_LDPATH_mips-unknown-linux-musl :=
21+
CFG_RUN_mips-unknown-linux-musl=
22+
CFG_RUN_TARG_mips-unknown-linux-musl=
23+
RUSTC_FLAGS_mips-unknown-linux-musl :=
24+
CFG_GNU_TRIPLE_mips-unknown-linux-musl := mips-unknown-linux-musl

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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# mipsel-unknown-linux-musl configuration
2+
CC_mipsel-unknown-linux-musl=mipsel-linux-musl-gcc
3+
CXX_mipsel-unknown-linux-musl=mipsel-linux-musl-g++
4+
CPP_mipsel-unknown-linux-musl=mipsel-linux-musl-gcc
5+
AR_mipsel-unknown-linux-musl=mipsel-linux-musl-ar
6+
CFG_LIB_NAME_mipsel-unknown-linux-musl=lib$(1).so
7+
CFG_STATIC_LIB_NAME_mipsel-unknown-linux-musl=lib$(1).a
8+
CFG_LIB_GLOB_mipsel-unknown-linux-musl=lib$(1)-*.so
9+
CFG_LIB_DSYM_GLOB_mipsel-unknown-linux-musl=lib$(1)-*.dylib.dSYM
10+
CFG_JEMALLOC_CFLAGS_mipsel-unknown-linux-musl := -mips32 -mabi=32 $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_mipsel-unknown-linux-musl := -Wall -g -fPIC -mips32 -mabi=32 $(CFLAGS)
12+
CFG_GCCISH_CXXFLAGS_mipsel-unknown-linux-musl := -fno-rtti $(CXXFLAGS)
13+
CFG_GCCISH_LINK_FLAGS_mipsel-unknown-linux-musl := -shared -fPIC -g -mips32
14+
CFG_GCCISH_DEF_FLAG_mipsel-unknown-linux-musl := -Wl,--export-dynamic,--dynamic-list=
15+
CFG_LLC_FLAGS_mipsel-unknown-linux-musl :=
16+
CFG_INSTALL_NAME_mipsel-unknown-linux-musl =
17+
CFG_EXE_SUFFIX_mipsel-unknown-linux-musl :=
18+
CFG_WINDOWSY_mipsel-unknown-linux-musl :=
19+
CFG_UNIXY_mipsel-unknown-linux-musl := 1
20+
CFG_LDPATH_mipsel-unknown-linux-musl :=
21+
CFG_RUN_mipsel-unknown-linux-musl=
22+
CFG_RUN_TARG_mipsel-unknown-linux-musl=
23+
RUSTC_FLAGS_mipsel-unknown-linux-musl :=
24+
CFG_GNU_TRIPLE_mipsel-unknown-linux-musl := mipsel-unknown-linux-musl

src/liblibc

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
use target::{Target, TargetOptions};
12+
13+
pub fn target() -> Target {
14+
Target {
15+
llvm_target: "mips-unknown-linux-musl".to_string(),
16+
target_endian: "big".to_string(),
17+
target_pointer_width: "32".to_string(),
18+
arch: "mips".to_string(),
19+
target_os: "linux".to_string(),
20+
target_env: "musl".to_string(),
21+
target_vendor: "unknown".to_string(),
22+
options: TargetOptions {
23+
cpu: "mips32r2".to_string(),
24+
features: "+mips32r2,+soft-float".to_string(),
25+
..super::linux_base::opts()
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
use target::{Target, TargetOptions};
12+
13+
pub fn target() -> Target {
14+
Target {
15+
llvm_target: "mipsel-unknown-linux-musl".to_string(),
16+
target_endian: "little".to_string(),
17+
target_pointer_width: "32".to_string(),
18+
arch: "mips".to_string(),
19+
target_os: "linux".to_string(),
20+
target_env: "musl".to_string(),
21+
target_vendor: "unknown".to_string(),
22+
options: TargetOptions {
23+
cpu: "mips32".to_string(),
24+
features: "+mips32".to_string(),
25+
..super::linux_base::opts()
26+
}
27+
}
28+
}

src/librustc_back/target/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ impl Target {
420420
armv7_unknown_linux_gnueabihf,
421421
aarch64_unknown_linux_gnu,
422422
x86_64_unknown_linux_musl,
423+
mips_unknown_linux_musl,
424+
mipsel_unknown_linux_musl,
423425

424426
i686_linux_android,
425427
arm_linux_androideabi,

src/libstd/os/linux/raw.rs

+9
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,20 @@ mod arch {
9393
use os::raw::{c_long, c_ulong};
9494
use os::unix::raw::{gid_t, uid_t};
9595

96+
#[cfg(target_env = "musl")]
97+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
98+
#[cfg(not(target_env = "musl"))]
9699
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
97100
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
101+
#[cfg(target_env = "musl")]
102+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
103+
#[cfg(not(target_env = "musl"))]
98104
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
99105
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
106+
#[cfg(target_env = "musl")]
100107
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
108+
#[cfg(not(target_env = "musl"))]
109+
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
101110
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
102111

103112
#[repr(C)]

src/libstd/sys/common/libunwind.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ pub type _Unwind_Exception_Cleanup_Fn =
101101
exception: *mut _Unwind_Exception);
102102

103103
#[cfg_attr(any(all(target_os = "linux", not(target_env = "musl")),
104-
target_os = "freebsd"),
104+
target_os = "freebsd",
105+
all(target_os = "linux", target_env = "musl", not(target_arch = "x86_64"))),
105106
link(name = "gcc_s"))]
106-
#[cfg_attr(all(target_os = "linux", target_env = "musl", not(test)),
107+
#[cfg_attr(all(target_os = "linux", target_env = "musl", target_arch = "x86_64", not(test)),
107108
link(name = "unwind", kind = "static"))]
108109
#[cfg_attr(any(target_os = "android", target_os = "openbsd"),
109110
link(name = "gcc"))]

0 commit comments

Comments
 (0)