Skip to content

Commit

Permalink
Auto merge of #21959 - dhuseby:bitrig-support, r=brson
Browse files Browse the repository at this point in the history
This patch adds the necessary pieces to support rust on Bitrig https://bitrig.org
  • Loading branch information
bors committed Feb 21, 2015
2 parents 522d09d + 5513040 commit 2b01a37
Show file tree
Hide file tree
Showing 50 changed files with 773 additions and 150 deletions.
13 changes: 12 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,12 @@ case $CFG_OSTYPE in
CFG_OSTYPE=unknown-dragonfly
;;

Bitrig)
CFG_OSTYPE=unknown-bitrig
;;

OpenBSD)
CFG_OSTYPE=unknown-openbsd
CFG_OSTYPE=unknown-openbsd
;;

Darwin)
Expand Down Expand Up @@ -747,6 +751,13 @@ then
CFG_ENABLE_CLANG=1
fi

# Force bitrig to build with clang; gcc doesn't like us there
if [ $CFG_OSTYPE = unknown-bitrig ]
then
step_msg "on Bitrig, forcing use of clang"
CFG_ENABLE_CLANG=1
fi

if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
then
err "either clang or gcc is required"
Expand Down
26 changes: 26 additions & 0 deletions mk/cfg/x86_64-unknown-bitrig.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# x86_64-unknown-bitrig-elf configuration
CC_x86_64-unknown-bitrig=$(CC)
CXX_x86_64-unknown-bitrig=$(CXX)
CPP_x86_64-unknown-bitrig=$(CPP)
AR_x86_64-unknown-bitrig=$(AR)
CFG_LIB_NAME_x86_64-unknown-bitrig=lib$(1).so
CFG_STATIC_LIB_NAME_x86_64-unknown-bitrig=lib$(1).a
CFG_LIB_GLOB_x86_64-unknown-bitrig=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_x86_64-unknown-bitrig=$(1)-*.dylib.dSYM
CFG_JEMALLOC_CFLAGS_x86_64-unknown-bitrig := -m64 -I/usr/include $(CFLAGS)
CFG_GCCISH_CFLAGS_x86_64-unknown-bitrig := -Wall -Werror -fPIC -m64 -I/usr/include $(CFLAGS)
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-bitrig := -shared -pic -pthread -m64 $(LDFLAGS)
CFG_GCCISH_DEF_FLAG_x86_64-unknown-bitrig := -Wl,--export-dynamic,--dynamic-list=
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-pic -Wl,-whole-archive
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-no-whole-archive
CFG_DEF_SUFFIX_x86_64-unknown-bitrig := .bsd.def
CFG_LLC_FLAGS_x86_64-unknown-bitrig :=
CFG_INSTALL_NAME_x86_64-unknown-bitrig =
CFG_EXE_SUFFIX_x86_64-unknown-bitrig :=
CFG_WINDOWSY_x86_64-unknown-bitrig :=
CFG_UNIXY_x86_64-unknown-bitrig := 1
CFG_PATH_MUNGE_x86_64-unknown-bitrig :=
CFG_LDPATH_x86_64-unknown-bitrig :=
CFG_RUN_x86_64-unknown-bitrig=$(2)
CFG_RUN_TARG_x86_64-unknown-bitrig=$(call CFG_RUN_x86_64-unknown-bitrig,,$(2))
CFG_GNU_TRIPLE_x86_64-unknown-bitrig := x86_64-unknown-bitrig
26 changes: 17 additions & 9 deletions mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ FIND_COMPILER = $(word 1,$(1:ccache=))
define CFG_MAKE_TOOLCHAIN
# Prepend the tools with their prefix if cross compiling
ifneq ($(CFG_BUILD),$(1))
CC_$(1)=$(CROSS_PREFIX_$(1))$(CC_$(1))
CXX_$(1)=$(CROSS_PREFIX_$(1))$(CXX_$(1))
CPP_$(1)=$(CROSS_PREFIX_$(1))$(CPP_$(1))
AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(CC_$(1))) \
-C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))

RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
CC_$(1)=$(CROSS_PREFIX_$(1))$(CC_$(1))
CXX_$(1)=$(CROSS_PREFIX_$(1))$(CXX_$(1))
CPP_$(1)=$(CROSS_PREFIX_$(1))$(CPP_$(1))
AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(CC_$(1))) \
-C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))

RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
endif

CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
Expand Down Expand Up @@ -179,11 +179,19 @@ define CFG_MAKE_TOOLCHAIN

ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)

# On Bitrig, we need the relocation model to be PIC for everthing
ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
LLVM_MC_RELOCATION_MODEL="pic"
else
LLVM_MC_RELOCATION_MODEL="default"
endif

# We're using llvm-mc as our assembler because it supports
# .cfi pseudo-ops on mac
CFG_ASSEMBLE_$(1)=$$(CPP_$(1)) -E $$(CFG_DEPEND_FLAGS) $$(2) | \
$$(LLVM_MC_$$(CFG_BUILD)) \
-assemble \
-relocation-model=$$(LLVM_MC_RELOCATION_MODEL) \
-filetype=obj \
-triple=$(1) \
-o=$$(1)
Expand All @@ -192,7 +200,7 @@ define CFG_MAKE_TOOLCHAIN
# For the ARM, AARCH64, MIPS and POWER crosses, use the toolchain assembler
# FIXME: We should be able to use the LLVM assembler
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
$$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
$$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)

endif

Expand Down
1 change: 1 addition & 0 deletions src/compiletest/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[
("linux", "linux"),
("freebsd", "freebsd"),
("dragonfly", "dragonfly"),
("bitrig", "bitrig"),
("openbsd", "openbsd"),
];

Expand Down
4 changes: 2 additions & 2 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2188,8 +2188,8 @@ The following configurations must be defined by the implementation:
`"unix"` or `"windows"`. The value of this configuration option is defined
as a configuration itself, like `unix` or `windows`.
* `target_os = "..."`. Operating system of the target, examples include
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"` or
`"openbsd"`.
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
`"bitrig"` or `"openbsd"`.
* `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit
pointers.
Expand Down
2 changes: 1 addition & 1 deletion src/etc/local_stage0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LIB_PREFIX=lib

OS=`uname -s`
case $OS in
("Linux"|"FreeBSD"|"DragonFly"|"OpenBSD")
("Linux"|"FreeBSD"|"DragonFly"|"Bitrig"|"OpenBSD")
BIN_SUF=
LIB_SUF=.so
;;
Expand Down
11 changes: 10 additions & 1 deletion src/etc/mklldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ def run(args):
args.extend(components)
out = run(args)
for lib in out.strip().replace("\n", ' ').split(' '):
lib = lib.strip()[2:] # chop of the leading '-l'
if len(lib) == 0:
continue
# in some cases we get extra spaces in between libs so ignore those
if len(lib) == 1 and lib == ' ':
continue
# not all libs strictly follow -lfoo, on Bitrig, there is -pthread
if lib[0:2] == '-l':
lib = lib.strip()[2:]
elif lib[0] == '-':
lib = lib.strip()[1:]
f.write("#[link(name = \"" + lib + "\"")
# LLVM libraries are all static libraries
if 'LLVM' in lib:
Expand Down
4 changes: 3 additions & 1 deletion src/etc/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def scrub(b):
"winnt": ["bin/rustc.exe"],
"freebsd": ["bin/rustc"],
"dragonfly": ["bin/rustc"],
"bitrig": ["bin/rustc"],
"openbsd": ["bin/rustc"],
}

winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll", "libstdc++-6.dll"]
winnt_runtime_deps_64 = ["libgcc_s_seh-1.dll", "libstdc++-6.dll"]


def parse_line(n, line):
global snapshotfile

Expand Down Expand Up @@ -101,6 +101,8 @@ def get_kernel(triple):
return "freebsd"
if os_name == "dragonfly":
return "dragonfly"
if os_name == "bitrig":
return "bitrig"
if os_name == "openbsd":
return "openbsd"
return "linux"
Expand Down
4 changes: 2 additions & 2 deletions src/libbacktrace/configure
Original file line number Diff line number Diff line change
Expand Up @@ -5650,7 +5650,7 @@ else
lt_cv_sys_max_cmd_len=8192;
;;
netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
netbsd* | freebsd* | openbsd* | darwin* | dragonfly* | bitrig*)
# This has been around since 386BSD, at least. Likely further.
if test -x /sbin/sysctl; then
lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
Expand Down Expand Up @@ -9332,7 +9332,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
;;
# FreeBSD 3 and greater uses gcc -shared to do shared libraries.
freebsd* | dragonfly* | openbsd*)
freebsd* | dragonfly* | bitrig* | openbsd*)
archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
Expand Down
2 changes: 1 addition & 1 deletion src/libbacktrace/ltmain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4741,7 +4741,7 @@ func_mode_link ()
# These systems don't actually have a C library (as such)
test "X$arg" = "X-lc" && continue
;;
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
# Do not include libc due to us having libc/libc_r.
test "X$arg" = "X-lc" && continue
;;
Expand Down
Loading

0 comments on commit 2b01a37

Please sign in to comment.