Commit 11ffc0de authored by Thomas Levy's avatar Thomas Levy

Build relibc for macos

parent d3e4fa71
......@@ -238,7 +238,7 @@ version = "0.1.0"
dependencies = [
"ralloc 1.0.0",
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"sc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc 0.2.2 (git+https://github.com/NilSet/syscall.rs?branch=macos-syscall-class)",
]
[[package]]
......@@ -369,6 +369,11 @@ dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "sc"
version = "0.2.2"
source = "git+https://github.com/NilSet/syscall.rs?branch=macos-syscall-class#0f0ff20bc677d37f44fb980626686d482a28a678"
[[package]]
name = "sc"
version = "0.2.2"
......@@ -790,6 +795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum sc 0.2.2 (git+https://github.com/NilSet/syscall.rs?branch=macos-syscall-class)" = "<none>"
"checksum sc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ebbb026ba4a707c25caec2db5ef59ad8b41f7ad77cad06257e06229c891f376"
"checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920"
"checksum serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "652bc323d694dc925829725ec6c890156d8e70ae5202919869cb00fe2eff3788"
......
......@@ -10,6 +10,9 @@ fn main() {
.flag("-nostdlib")
.flag("-I")
.flag(&format!("{}/include", crate_dir))
.flag("-I")
.flag(&format!("{}/target/include", crate_dir))
.define("DARWIN", None)
.flag("-fno-stack-protector")
.file("src/c/dlmalloc.c")
.file("src/c/fcntl.c")
......
#ifndef _FCNTL_H
#define _FCNTL_H
#include <stdarg.h>
#include <sys/types.h>
#define FD_CLOEXEC 16777216
#define F_DUPFD 0
#define F_GETFD 1
#define F_GETFL 3
#define F_GETLK 5
#define F_RDLCK 0
#define F_SETFD 2
#define F_SETFL 4
#define F_SETLK 6
#define F_SETLKW 7
#define F_UNLCK 2
#define F_WRLCK 1
#if (!defined(__redox__))
#define O_APPEND 1024
#endif
#if (defined(__redox__))
#define O_APPEND 524288
#endif
#if (defined(__redox__))
#define O_ASYNC 4194304
#endif
#if (!defined(__redox__))
#define O_CLOEXEC 524288
#endif
#if (defined(__redox__))
#define O_CLOEXEC 16777216
#endif
#if (!defined(__redox__))
#define O_CREAT 64
#endif
#if (defined(__redox__))
#define O_CREAT 33554432
#endif
#if (defined(__redox__))
#define O_DIRECTORY 268435456
#endif
#if (!defined(__redox__))
#define O_EXCL 128
#endif
#if (defined(__redox__))
#define O_EXCL 134217728
#endif
#if (defined(__redox__))
#define O_EXLOCK 2097152
#endif
#if (defined(__redox__))
#define O_FSYNC 8388608
#endif
#if (defined(__redox__))
#define O_NOFOLLOW 2147483648
#endif
#if (defined(__redox__))
#define O_NONBLOCK 262144
#endif
#if (!defined(__redox__))
#define O_RDONLY 0
#endif
#if (defined(__redox__))
#define O_RDONLY 65536
#endif
#if (!defined(__redox__))
#define O_RDWR 2
#endif
#if (defined(__redox__))
#define O_RDWR 196608
#endif
#if (defined(__redox__))
#define O_SHLOCK 1048576
#endif
#if (defined(__redox__))
#define O_STAT 536870912
#endif
#if (defined(__redox__))
#define O_SYMLINK 1073741824
#endif
#if (!defined(__redox__))
#define O_TRUNC 512
#endif
#if (defined(__redox__))
#define O_TRUNC 67108864
#endif
#if (!defined(__redox__))
#define O_WRONLY 1
#endif
#if (defined(__redox__))
#define O_WRONLY 131072
#endif
int creat(const char *path, mode_t mode);
int sys_fcntl(int fildes, int cmd, int arg);
int sys_open(const char *path, int oflag, mode_t mode);
#endif /* _FCNTL_H */
#include <bits/fcntl.h>
#ifndef _SYS_MMAN_H
#define _SYS_MMAN_H
#include <stdint.h>
#include <sys/types.h>
#define MAP_ANON 4096
#define MAP_FILE 0
#define MAP_FIXED 16
#define MAP_PRIVATE 2
#define MAP_SHARED 1
#define PROT_EXEC 4
#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
void *mmap(void *addr, uintptr_t len, int prot, int flags, int fildes, off_t off);
int munmap(void *addr, uintptr_t len);
#endif /* _SYS_MMAN_H */
......@@ -523,12 +523,9 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
/* Customizations { */
#define HAVE_MMAP 0
#define LACKS_ERRNO_H
#define LACKS_FCNTL_H
#define LACKS_STDLIB_H
#define LACKS_STRING_H
#define LACKS_SYS_MMAN_H
#define LACKS_TIME_H
#define LACKS_UNISTD_H
#define NO_MALLOC_STATS 1
......
......@@ -19,7 +19,7 @@ use platform::types::*;
#[no_mangle]
#[naked]
pub unsafe extern "C" fn _start() {
#[cfg(target_arch = "x86_64")]
#[cfg(all(target_arch = "x86_64", not(target_os = "macos")))]
asm!("mov rdi, rsp
and rsp, 0xFFFFFFFFFFFFFFF0
call _start_rust"
......@@ -28,6 +28,15 @@ pub unsafe extern "C" fn _start() {
:
: "intel", "volatile"
);
#[cfg(all(target_arch = "x86_64", target_os = "macos"))]
asm!("mov rdi, rsp
and rsp, 0xFFFFFFFFFFFFFFF0
call __start_rust"
:
:
:
: "intel", "volatile"
);
#[cfg(target_arch = "aarch64")]
asm!("mov x0, sp
bl _start_rust"
......
......@@ -8,7 +8,7 @@ use platform::types::*;
pub use sys::*;
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "redox"))]
#[path = "linux.rs"]
pub mod sys;
......
......@@ -8,8 +8,8 @@ path = "../../ralloc"
default-features = false
optional = true
[target.'cfg(target_os = "linux")'.dependencies]
sc = "0.2"
[target.'cfg(not(target_os = "redox"))'.dependencies]
sc = { git = "https://github.com/NilSet/syscall.rs", branch = "macos-syscall-class" }
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.1"
......@@ -2,11 +2,12 @@
#![allow(non_camel_case_types)]
#![feature(alloc, allocator_api, const_vec_new)]
#![cfg_attr(target_os = "redox", feature(thread_local))]
#![cfg_attr(target_os = "macos", feature(asm))]
#[cfg_attr(target_os = "redox", macro_use)]
extern crate alloc;
#[cfg(all(not(feature = "no_std"), target_os = "linux"))]
#[cfg(all(not(feature = "no_std"), not(target_os = "redox")))]
#[macro_use]
extern crate sc;
......@@ -29,6 +30,10 @@ pub use sys::*;
#[path = "linux/mod.rs"]
mod sys;
#[cfg(all(not(feature = "no_std"), target_os = "macos"))]
#[path = "macos/mod.rs"]
mod sys;
#[cfg(all(not(feature = "no_std"), target_os = "redox"))]
#[path = "redox/mod.rs"]
mod sys;
......
This diff is collapsed.
/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
.global _longjmp
.global longjmp
.type _longjmp,@function
.type longjmp,@function
_longjmp:
longjmp:
mov %rsi,%rax /* val will be longjmp return */
......
......@@ -2,9 +2,6 @@
.global __setjmp
.global _setjmp
.global setjmp
.type __setjmp,@function
.type _setjmp,@function
.type setjmp,@function
__setjmp:
_setjmp:
setjmp:
......
......@@ -6,7 +6,7 @@
extern crate errno;
extern crate platform;
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "redox"))]
#[path = "linux.rs"]
pub mod sys;
......
......@@ -6,7 +6,7 @@ use platform::types::*;
pub use sys::*;
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "redox"))]
#[path = "linux.rs"]
pub mod sys;
......@@ -24,7 +24,7 @@ pub extern "C" fn mlockall(flags: c_int) -> c_int {
unimplemented!();
}
// #[no_mangle]
#[no_mangle]
pub extern "C" fn mmap(
addr: *mut c_void,
len: usize,
......@@ -33,7 +33,7 @@ pub extern "C" fn mmap(
fildes: c_int,
off: off_t,
) -> *mut c_void {
unimplemented!();
platform::mmap(addr, len, prot, flags, fildes, off)
}
// #[no_mangle]
......@@ -56,9 +56,9 @@ pub extern "C" fn munlockall() -> c_int {
unimplemented!();
}
// #[no_mangle]
#[no_mangle]
pub extern "C" fn munmap(addr: *mut c_void, len: usize) -> c_int {
unimplemented!();
platform::munmap(addr, len)
}
// #[no_mangle]
......
......@@ -7,3 +7,6 @@ pub const PROT_NONE: c_int = 0x0;
pub const MAP_SHARED: c_int = 0x1;
pub const MAP_PRIVATE: c_int = 0x2;
pub const MAP_FIXED: c_int = 0x0010;
pub const MAP_FILE: c_int = 0x0000;
pub const MAP_ANON: c_int = 0x1000;
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "redox"))]
#[path = "linux.rs"]
pub mod sys;
......
......@@ -123,6 +123,8 @@ CFLAGS=\
-I ../target/include \
-I ../target/openlibm/include \
-I ../target/openlibm/src \
-Wl,-static \
-Wl,-e -Wl,__start \
HEADLIBS=\
../target/debug/crt0.o
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment