Skip to content

Commit 2e2f53f

Browse files
committed
Port Rust to DragonFlyBSD
Not included are two required patches: * LLVM: segmented stack support for DragonFly [1] * jemalloc: simple configure patches [1]: http://reviews.llvm.org/D4705
1 parent 72e2c7d commit 2e2f53f

35 files changed

+457
-36
lines changed

configure

+4
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ case $CFG_OSTYPE in
291291
CFG_OSTYPE=unknown-freebsd
292292
;;
293293

294+
DragonFly)
295+
CFG_OSTYPE=unknown-dragonfly
296+
;;
297+
294298
Darwin)
295299
CFG_OSTYPE=apple-darwin
296300
;;

mk/platform.mk

+27
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,33 @@ CFG_LDPATH_x86_64-unknown-freebsd :=
580580
CFG_RUN_x86_64-unknown-freebsd=$(2)
581581
CFG_RUN_TARG_x86_64-unknown-freebsd=$(call CFG_RUN_x86_64-unknown-freebsd,,$(2))
582582

583+
# x86_64-pc-dragonfly-elf configuration
584+
CC_x86_64-unknown-dragonfly=$(CC)
585+
CXX_x86_64-unknown-dragonfly=$(CXX)
586+
CPP_x86_64-unknown-dragonfly=$(CPP)
587+
AR_x86_64-unknown-dragonfly=$(AR)
588+
CFG_LIB_NAME_x86_64-unknown-dragonfly=lib$(1).so
589+
CFG_STATIC_LIB_NAME_x86_64-unknown-dragonfly=lib$(1).a
590+
CFG_LIB_GLOB_x86_64-unknown-dragonfly=lib$(1)-*.so
591+
CFG_LIB_DSYM_GLOB_x86_64-unknown-dragonfly=$(1)-*.dylib.dSYM
592+
CFG_CFLAGS_x86_64-unknown-dragonfly := -I/usr/include -I/usr/local/include $(CFLAGS)
593+
CFG_GCCISH_CFLAGS_x86_64-unknown-dragonfly := -Wall -Werror -g -fPIC -I/usr/include -I/usr/local/include $(CFLAGS)
594+
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-dragonfly := -shared -fPIC -g -pthread -lrt
595+
CFG_GCCISH_DEF_FLAG_x86_64-unknown-dragonfly := -Wl,--export-dynamic,--dynamic-list=
596+
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-whole-archive
597+
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-no-whole-archive
598+
CFG_DEF_SUFFIX_x86_64-unknown-dragonfly := .bsd.def
599+
CFG_LLC_FLAGS_x86_64-unknown-dragonfly :=
600+
CFG_INSTALL_NAME_x86_64-unknown-dragonfly =
601+
CFG_LIBUV_LINK_FLAGS_x86_64-unknown-dragonfly := -pthread -lkvm
602+
CFG_EXE_SUFFIX_x86_64-unknown-dragonfly :=
603+
CFG_WINDOWSY_x86_64-unknown-dragonfly :=
604+
CFG_UNIXY_x86_64-unknown-dragonfly := 1
605+
CFG_PATH_MUNGE_x86_64-unknown-dragonfly :=
606+
CFG_LDPATH_x86_64-unknown-dragonfly :=
607+
CFG_RUN_x86_64-unknown-dragonfly=$(2)
608+
CFG_RUN_TARG_x86_64-unknown-dragonfly=$(call CFG_RUN_x86_64-unknown-dragonfly,,$(2))
609+
583610

584611
# The -Qunused-arguments sidesteps spurious warnings from clang
585612
define FILTER_FLAGS

mk/rt.mk

+5-1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ else ifeq ($(OSTYPE_$(1)), apple-ios)
171171
JEMALLOC_ARGS_$(1) := --disable-tls
172172
else ifeq ($(OSTYPE_$(1)), unknown-freebsd)
173173
LIBUV_OSTYPE_$(1) := freebsd
174+
else ifeq ($(OSTYPE_$(1)), unknown-dragonfly)
175+
LIBUV_OSTYPE_$(1) := freebsd
176+
# required on DragonFly, otherwise gyp fails with a Python exception
177+
LIBUV_GYP_ARGS_$(1) := --no-parallel
174178
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
175179
LIBUV_OSTYPE_$(1) := android
176180
LIBUV_ARGS_$(1) := PLATFORM=android host=android OS=linux
@@ -202,7 +206,7 @@ $$(LIBUV_MAKEFILE_$(1)): $$(LIBUV_DEPS) $$(MKFILE_DEPS) $$(LIBUV_STAMP_$(1))
202206
$$(CFG_PYTHON) ./gyp_uv.py -f make -Dtarget_arch=$$(LIBUV_ARCH_$(1)) \
203207
-D ninja \
204208
-DOS=$$(LIBUV_OSTYPE_$(1)) \
205-
-Goutput_dir=$$(@D) --generator-output $$(@D))
209+
-Goutput_dir=$$(@D) $$(LIBUV_GYP_ARGS_$(1)) --generator-output $$(@D))
206210
touch $$@
207211

208212
# Windows has a completely different build system for libuv because of mingw. In

src/doc/rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ The following configurations must be defined by the implementation:
20012001
`"unix"` or `"windows"`. The value of this configuration option is defined as
20022002
a configuration itself, like `unix` or `windows`.
20032003
* `target_os = "..."`. Operating system of the target, examples include
2004-
`"win32"`, `"macos"`, `"linux"`, `"android"` or `"freebsd"`.
2004+
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"` or `"dragonfly"`.
20052005
* `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
20062006
for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit
20072007
pointers.

src/etc/local_stage0.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LIB_PREFIX=lib
1818

1919
OS=`uname -s`
2020
case $OS in
21-
("Linux"|"FreeBSD")
21+
("Linux"|"FreeBSD"|"DragonFly")
2222
BIN_SUF=
2323
LIB_SUF=.so
2424
break
@@ -58,3 +58,6 @@ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}extra*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_D
5858
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}rust*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
5959
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}std*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
6060
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}syntax*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
61+
62+
# do not fail if one of the above fails, as all we need is a working rustc!
63+
exit 0

src/etc/mklldeps.py

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def run(args):
5656
os = 'linux'
5757
elif 'freebsd' in os:
5858
os = 'freebsd'
59+
elif 'dragonfly' in os:
60+
os = 'dragonfly'
5961
elif 'android' in os:
6062
os = 'android'
6163
elif 'win' in os or 'mingw' in os:

src/libgreen/stack.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ pub struct Stack {
2525
// anyway), but some platforms don't support it at all. For example, it appears
2626
// that there's a bug in freebsd that MAP_STACK implies MAP_FIXED (so it always
2727
// fails): http://lists.freebsd.org/pipermail/freebsd-bugs/2011-July/044840.html
28-
#[cfg(not(windows), not(target_os = "freebsd"))]
28+
//
29+
// DragonFly BSD also seems to suffer from the same problem. When MAP_STACK is
30+
// used, it returns the same `ptr` multiple times.
31+
#[cfg(not(windows), not(target_os = "freebsd"), not(target_os = "dragonfly"))]
2932
static STACK_FLAGS: libc::c_int = libc::MAP_STACK | libc::MAP_PRIVATE |
3033
libc::MAP_ANON;
3134
#[cfg(target_os = "freebsd")]
35+
#[cfg(target_os = "dragonfly")]
3236
static STACK_FLAGS: libc::c_int = libc::MAP_PRIVATE | libc::MAP_ANON;
3337
#[cfg(windows)]
3438
static STACK_FLAGS: libc::c_int = 0;

0 commit comments

Comments
 (0)