Skip to content

Commit 6466795

Browse files
robarnoldgraydon
authored andcommitted
Add FreeBSD_x86_elf target to rustboot
1 parent 6e39102 commit 6466795

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

src/boot/driver/lib.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ let get_ar
249249
Win32_x86_pe -> Pe.sniff
250250
| MacOS_x86_macho -> Macho.sniff
251251
| Linux_x86_elf -> Elf.sniff
252+
| FreeBSD_x86_elf -> Elf.sniff
252253
in
253254
sniff sess filename
254255
end
@@ -270,6 +271,7 @@ let get_sects
270271
Win32_x86_pe -> Pe.get_sections
271272
| MacOS_x86_macho -> Macho.get_sections
272273
| Linux_x86_elf -> Elf.get_sections
274+
| FreeBSD_x86_elf -> Elf.get_sections
273275
in
274276
Some (ar, (get_sections sess ar))
275277
end
@@ -350,6 +352,7 @@ let get_mod
350352
Win32_x86_pe -> ".dll"
351353
| MacOS_x86_macho -> ".dylib"
352354
| Linux_x86_elf -> ".so"
355+
| FreeBSD_x86_elf -> ".so"
353356
in
354357
let rec meta_matches i f_meta =
355358
if i >= (Array.length meta)
@@ -447,6 +450,7 @@ let infer_lib_name
447450
Win32_x86_pe -> ident ^ ".dll"
448451
| MacOS_x86_macho -> "lib" ^ ident ^ ".dylib"
449452
| Linux_x86_elf -> "lib" ^ ident ^ ".so"
453+
| FreeBSD_x86_elf -> "lib" ^ ident ^ ".so"
450454
;;
451455

452456

src/boot/driver/main.ml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ let _ =
88

99
let (targ:Common.target) =
1010
match Sys.os_type with
11-
"Unix" when Unix.system "test `uname -s` = 'Darwin'" = Unix.WEXITED 0 ->
12-
MacOS_x86_macho
13-
| "Unix" -> Linux_x86_elf
14-
| "Win32" -> Win32_x86_pe
11+
12+
| "Win32"
1513
| "Cygwin" -> Win32_x86_pe
16-
| _ -> Linux_x86_elf
14+
15+
| "Unix"
16+
when Unix.system "test `uname -s` = 'Linux'" = Unix.WEXITED 0 ->
17+
Linux_x86_elf
18+
| "Unix"
19+
when Unix.system "test `uname -s` = 'Darwin'" = Unix.WEXITED 0 ->
20+
MacOS_x86_macho
21+
| "Unix"
22+
when Unix.system "test `uname -s` = 'FreeBSD'" = Unix.WEXITED 0 ->
23+
FreeBSD_x86_elf
24+
| _ ->
25+
Linux_x86_elf
1726
;;
1827

1928
let (abi:Abi.abi) = X86.abi;;
@@ -96,6 +105,7 @@ let default_output_filename (sess:Session.sess) : filename option =
96105
else
97106
base ^ (match sess.Session.sess_targ with
98107
Linux_x86_elf -> ""
108+
| FreeBSD_x86_elf -> ""
99109
| MacOS_x86_macho -> ""
100110
| Win32_x86_pe -> ".exe")
101111
in
@@ -144,16 +154,21 @@ let flag f opt desc =
144154

145155
let argspecs =
146156
[
147-
("-t", Arg.Symbol (["linux-x86-elf"; "win32-x86-pe"; "macos-x86-macho"],
157+
("-t", Arg.Symbol (["linux-x86-elf";
158+
"win32-x86-pe";
159+
"macos-x86-macho";
160+
"freebsd-x86-elf"],
148161
fun s -> (sess.Session.sess_targ <-
149162
(match s with
150163
"win32-x86-pe" -> Win32_x86_pe
151164
| "macos-x86-macho" -> MacOS_x86_macho
165+
| "freebsd-x86-elf" -> FreeBSD_x86_elf
152166
| _ -> Linux_x86_elf))),
153167
(" target (default: " ^ (match sess.Session.sess_targ with
154168
Win32_x86_pe -> "win32-x86-pe"
155169
| Linux_x86_elf -> "linux-x86-elf"
156170
| MacOS_x86_macho -> "macos-x86-macho"
171+
| FreeBSD_x86_elf -> "freebsd-x86-elf"
157172
) ^ ")"));
158173
("-o", Arg.String (fun s -> sess.Session.sess_out <- Some s),
159174
"file to output (default: "
@@ -320,6 +335,7 @@ let parse_input_crate
320335
let depfile =
321336
match sess.Session.sess_targ with
322337
Linux_x86_elf
338+
| FreeBSD_x86_elf
323339
| MacOS_x86_macho -> outfile ^ ".d"
324340
| Win32_x86_pe -> (Filename.chop_extension outfile) ^ ".d"
325341
in
@@ -473,6 +489,7 @@ let main_pipeline _ =
473489
Win32_x86_pe -> Pe.emit_file
474490
| MacOS_x86_macho -> Macho.emit_file
475491
| Linux_x86_elf -> Elf.emit_file
492+
| FreeBSD_x86_elf -> Elf.emit_file
476493
in
477494
Session.time_inner "emit" sess
478495
(fun _ -> emitter sess crate code data sem_cx dwarf);

src/boot/fe/cexp.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ let parse_crate_file
628628
let (os, arch, libc) =
629629
match sess.Session.sess_targ with
630630
Linux_x86_elf -> ("linux", "x86", "libc.so.6")
631+
| FreeBSD_x86_elf -> ("freebsd", "x86", "libc.so.7")
631632
| Win32_x86_pe -> ("win32", "x86", "msvcrt.dll")
632633
| MacOS_x86_macho -> ("macos", "x86", "libc.dylib")
633634
in

src/boot/util/common.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type target =
5656
Linux_x86_elf
5757
| Win32_x86_pe
5858
| MacOS_x86_macho
59+
| FreeBSD_x86_elf
5960
;;
6061

6162
type ty_mach =

0 commit comments

Comments
 (0)