Skip to content

Commit 2b01a37

Browse files
committed
Auto merge of #21959 - dhuseby:bitrig-support, r=brson
This patch adds the necessary pieces to support rust on Bitrig https://bitrig.org
2 parents 522d09d + 5513040 commit 2b01a37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+773
-150
lines changed

Diff for: configure

+12-1
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,12 @@ case $CFG_OSTYPE in
374374
CFG_OSTYPE=unknown-dragonfly
375375
;;
376376

377+
Bitrig)
378+
CFG_OSTYPE=unknown-bitrig
379+
;;
380+
377381
OpenBSD)
378-
CFG_OSTYPE=unknown-openbsd
382+
CFG_OSTYPE=unknown-openbsd
379383
;;
380384

381385
Darwin)
@@ -747,6 +751,13 @@ then
747751
CFG_ENABLE_CLANG=1
748752
fi
749753

754+
# Force bitrig to build with clang; gcc doesn't like us there
755+
if [ $CFG_OSTYPE = unknown-bitrig ]
756+
then
757+
step_msg "on Bitrig, forcing use of clang"
758+
CFG_ENABLE_CLANG=1
759+
fi
760+
750761
if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
751762
then
752763
err "either clang or gcc is required"

Diff for: mk/cfg/x86_64-unknown-bitrig.mk

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# x86_64-unknown-bitrig-elf configuration
2+
CC_x86_64-unknown-bitrig=$(CC)
3+
CXX_x86_64-unknown-bitrig=$(CXX)
4+
CPP_x86_64-unknown-bitrig=$(CPP)
5+
AR_x86_64-unknown-bitrig=$(AR)
6+
CFG_LIB_NAME_x86_64-unknown-bitrig=lib$(1).so
7+
CFG_STATIC_LIB_NAME_x86_64-unknown-bitrig=lib$(1).a
8+
CFG_LIB_GLOB_x86_64-unknown-bitrig=lib$(1)-*.so
9+
CFG_LIB_DSYM_GLOB_x86_64-unknown-bitrig=$(1)-*.dylib.dSYM
10+
CFG_JEMALLOC_CFLAGS_x86_64-unknown-bitrig := -m64 -I/usr/include $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_x86_64-unknown-bitrig := -Wall -Werror -fPIC -m64 -I/usr/include $(CFLAGS)
12+
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-bitrig := -shared -pic -pthread -m64 $(LDFLAGS)
13+
CFG_GCCISH_DEF_FLAG_x86_64-unknown-bitrig := -Wl,--export-dynamic,--dynamic-list=
14+
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-pic -Wl,-whole-archive
15+
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-no-whole-archive
16+
CFG_DEF_SUFFIX_x86_64-unknown-bitrig := .bsd.def
17+
CFG_LLC_FLAGS_x86_64-unknown-bitrig :=
18+
CFG_INSTALL_NAME_x86_64-unknown-bitrig =
19+
CFG_EXE_SUFFIX_x86_64-unknown-bitrig :=
20+
CFG_WINDOWSY_x86_64-unknown-bitrig :=
21+
CFG_UNIXY_x86_64-unknown-bitrig := 1
22+
CFG_PATH_MUNGE_x86_64-unknown-bitrig :=
23+
CFG_LDPATH_x86_64-unknown-bitrig :=
24+
CFG_RUN_x86_64-unknown-bitrig=$(2)
25+
CFG_RUN_TARG_x86_64-unknown-bitrig=$(call CFG_RUN_x86_64-unknown-bitrig,,$(2))
26+
CFG_GNU_TRIPLE_x86_64-unknown-bitrig := x86_64-unknown-bitrig

Diff for: mk/platform.mk

+17-9
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ FIND_COMPILER = $(word 1,$(1:ccache=))
144144
define CFG_MAKE_TOOLCHAIN
145145
# Prepend the tools with their prefix if cross compiling
146146
ifneq ($(CFG_BUILD),$(1))
147-
CC_$(1)=$(CROSS_PREFIX_$(1))$(CC_$(1))
148-
CXX_$(1)=$(CROSS_PREFIX_$(1))$(CXX_$(1))
149-
CPP_$(1)=$(CROSS_PREFIX_$(1))$(CPP_$(1))
150-
AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
151-
RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(CC_$(1))) \
152-
-C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))
153-
154-
RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
147+
CC_$(1)=$(CROSS_PREFIX_$(1))$(CC_$(1))
148+
CXX_$(1)=$(CROSS_PREFIX_$(1))$(CXX_$(1))
149+
CPP_$(1)=$(CROSS_PREFIX_$(1))$(CPP_$(1))
150+
AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
151+
RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(call FIND_COMPILER,$$(CC_$(1))) \
152+
-C ar=$$(call FIND_COMPILER,$$(AR_$(1))) $(RUSTC_CROSS_FLAGS_$(1))
153+
154+
RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
155155
endif
156156

157157
CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
@@ -179,11 +179,19 @@ define CFG_MAKE_TOOLCHAIN
179179

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

182+
# On Bitrig, we need the relocation model to be PIC for everthing
183+
ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
184+
LLVM_MC_RELOCATION_MODEL="pic"
185+
else
186+
LLVM_MC_RELOCATION_MODEL="default"
187+
endif
188+
182189
# We're using llvm-mc as our assembler because it supports
183190
# .cfi pseudo-ops on mac
184191
CFG_ASSEMBLE_$(1)=$$(CPP_$(1)) -E $$(CFG_DEPEND_FLAGS) $$(2) | \
185192
$$(LLVM_MC_$$(CFG_BUILD)) \
186193
-assemble \
194+
-relocation-model=$$(LLVM_MC_RELOCATION_MODEL) \
187195
-filetype=obj \
188196
-triple=$(1) \
189197
-o=$$(1)
@@ -192,7 +200,7 @@ define CFG_MAKE_TOOLCHAIN
192200
# For the ARM, AARCH64, MIPS and POWER crosses, use the toolchain assembler
193201
# FIXME: We should be able to use the LLVM assembler
194202
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
195-
$$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
203+
$$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
196204

197205
endif
198206

Diff for: src/compiletest/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[
2323
("linux", "linux"),
2424
("freebsd", "freebsd"),
2525
("dragonfly", "dragonfly"),
26+
("bitrig", "bitrig"),
2627
("openbsd", "openbsd"),
2728
];
2829

Diff for: src/doc/reference.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2188,8 +2188,8 @@ The following configurations must be defined by the implementation:
21882188
`"unix"` or `"windows"`. The value of this configuration option is defined
21892189
as a configuration itself, like `unix` or `windows`.
21902190
* `target_os = "..."`. Operating system of the target, examples include
2191-
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"` or
2192-
`"openbsd"`.
2191+
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
2192+
`"bitrig"` or `"openbsd"`.
21932193
* `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
21942194
for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit
21952195
pointers.

Diff for: src/etc/local_stage0.sh

+1-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"|"DragonFly"|"OpenBSD")
21+
("Linux"|"FreeBSD"|"DragonFly"|"Bitrig"|"OpenBSD")
2222
BIN_SUF=
2323
LIB_SUF=.so
2424
;;

Diff for: src/etc/mklldeps.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,16 @@ def run(args):
5757
args.extend(components)
5858
out = run(args)
5959
for lib in out.strip().replace("\n", ' ').split(' '):
60-
lib = lib.strip()[2:] # chop of the leading '-l'
60+
if len(lib) == 0:
61+
continue
62+
# in some cases we get extra spaces in between libs so ignore those
63+
if len(lib) == 1 and lib == ' ':
64+
continue
65+
# not all libs strictly follow -lfoo, on Bitrig, there is -pthread
66+
if lib[0:2] == '-l':
67+
lib = lib.strip()[2:]
68+
elif lib[0] == '-':
69+
lib = lib.strip()[1:]
6170
f.write("#[link(name = \"" + lib + "\"")
6271
# LLVM libraries are all static libraries
6372
if 'LLVM' in lib:

Diff for: src/etc/snapshot.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def scrub(b):
4646
"winnt": ["bin/rustc.exe"],
4747
"freebsd": ["bin/rustc"],
4848
"dragonfly": ["bin/rustc"],
49+
"bitrig": ["bin/rustc"],
4950
"openbsd": ["bin/rustc"],
5051
}
5152

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

55-
5656
def parse_line(n, line):
5757
global snapshotfile
5858

@@ -101,6 +101,8 @@ def get_kernel(triple):
101101
return "freebsd"
102102
if os_name == "dragonfly":
103103
return "dragonfly"
104+
if os_name == "bitrig":
105+
return "bitrig"
104106
if os_name == "openbsd":
105107
return "openbsd"
106108
return "linux"

Diff for: src/libbacktrace/configure

+2-2
Original file line numberDiff line numberDiff line change
@@ -5650,7 +5650,7 @@ else
56505650
lt_cv_sys_max_cmd_len=8192;
56515651
;;
56525652
5653-
netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
5653+
netbsd* | freebsd* | openbsd* | darwin* | dragonfly* | bitrig*)
56545654
# This has been around since 386BSD, at least. Likely further.
56555655
if test -x /sbin/sysctl; then
56565656
lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -9332,7 +9332,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
93329332
;;
93339333
93349334
# FreeBSD 3 and greater uses gcc -shared to do shared libraries.
9335-
freebsd* | dragonfly* | openbsd*)
9335+
freebsd* | dragonfly* | bitrig* | openbsd*)
93369336
archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
93379337
hardcode_libdir_flag_spec='-R$libdir'
93389338
hardcode_direct=yes

Diff for: src/libbacktrace/ltmain.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4741,7 +4741,7 @@ func_mode_link ()
47414741
# These systems don't actually have a C library (as such)
47424742
test "X$arg" = "X-lc" && continue
47434743
;;
4744-
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4744+
*-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
47454745
# Do not include libc due to us having libc/libc_r.
47464746
test "X$arg" = "X-lc" && continue
47474747
;;

0 commit comments

Comments
 (0)