From 6466795a70df56f89405df1ed438c8f8b58fed3a Mon Sep 17 00:00:00 2001 From: Rob Arnold Date: Wed, 9 Feb 2011 10:23:07 -0800 Subject: [PATCH] Add FreeBSD_x86_elf target to rustboot --- src/boot/driver/lib.ml | 4 ++++ src/boot/driver/main.ml | 29 +++++++++++++++++++++++------ src/boot/fe/cexp.ml | 1 + src/boot/util/common.ml | 1 + 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/boot/driver/lib.ml b/src/boot/driver/lib.ml index a4769e83ed1..00b1b8341f5 100644 --- a/src/boot/driver/lib.ml +++ b/src/boot/driver/lib.ml @@ -249,6 +249,7 @@ let get_ar Win32_x86_pe -> Pe.sniff | MacOS_x86_macho -> Macho.sniff | Linux_x86_elf -> Elf.sniff + | FreeBSD_x86_elf -> Elf.sniff in sniff sess filename end @@ -270,6 +271,7 @@ let get_sects Win32_x86_pe -> Pe.get_sections | MacOS_x86_macho -> Macho.get_sections | Linux_x86_elf -> Elf.get_sections + | FreeBSD_x86_elf -> Elf.get_sections in Some (ar, (get_sections sess ar)) end @@ -350,6 +352,7 @@ let get_mod Win32_x86_pe -> ".dll" | MacOS_x86_macho -> ".dylib" | Linux_x86_elf -> ".so" + | FreeBSD_x86_elf -> ".so" in let rec meta_matches i f_meta = if i >= (Array.length meta) @@ -447,6 +450,7 @@ let infer_lib_name Win32_x86_pe -> ident ^ ".dll" | MacOS_x86_macho -> "lib" ^ ident ^ ".dylib" | Linux_x86_elf -> "lib" ^ ident ^ ".so" + | FreeBSD_x86_elf -> "lib" ^ ident ^ ".so" ;; diff --git a/src/boot/driver/main.ml b/src/boot/driver/main.ml index 2bbc832bf04..9705f1ee7b1 100644 --- a/src/boot/driver/main.ml +++ b/src/boot/driver/main.ml @@ -8,12 +8,21 @@ let _ = let (targ:Common.target) = match Sys.os_type with - "Unix" when Unix.system "test `uname -s` = 'Darwin'" = Unix.WEXITED 0 -> - MacOS_x86_macho - | "Unix" -> Linux_x86_elf - | "Win32" -> Win32_x86_pe + + | "Win32" | "Cygwin" -> Win32_x86_pe - | _ -> Linux_x86_elf + + | "Unix" + when Unix.system "test `uname -s` = 'Linux'" = Unix.WEXITED 0 -> + Linux_x86_elf + | "Unix" + when Unix.system "test `uname -s` = 'Darwin'" = Unix.WEXITED 0 -> + MacOS_x86_macho + | "Unix" + when Unix.system "test `uname -s` = 'FreeBSD'" = Unix.WEXITED 0 -> + FreeBSD_x86_elf + | _ -> + Linux_x86_elf ;; let (abi:Abi.abi) = X86.abi;; @@ -96,6 +105,7 @@ let default_output_filename (sess:Session.sess) : filename option = else base ^ (match sess.Session.sess_targ with Linux_x86_elf -> "" + | FreeBSD_x86_elf -> "" | MacOS_x86_macho -> "" | Win32_x86_pe -> ".exe") in @@ -144,16 +154,21 @@ let flag f opt desc = let argspecs = [ - ("-t", Arg.Symbol (["linux-x86-elf"; "win32-x86-pe"; "macos-x86-macho"], + ("-t", Arg.Symbol (["linux-x86-elf"; + "win32-x86-pe"; + "macos-x86-macho"; + "freebsd-x86-elf"], fun s -> (sess.Session.sess_targ <- (match s with "win32-x86-pe" -> Win32_x86_pe | "macos-x86-macho" -> MacOS_x86_macho + | "freebsd-x86-elf" -> FreeBSD_x86_elf | _ -> Linux_x86_elf))), (" target (default: " ^ (match sess.Session.sess_targ with Win32_x86_pe -> "win32-x86-pe" | Linux_x86_elf -> "linux-x86-elf" | MacOS_x86_macho -> "macos-x86-macho" + | FreeBSD_x86_elf -> "freebsd-x86-elf" ) ^ ")")); ("-o", Arg.String (fun s -> sess.Session.sess_out <- Some s), "file to output (default: " @@ -320,6 +335,7 @@ let parse_input_crate let depfile = match sess.Session.sess_targ with Linux_x86_elf + | FreeBSD_x86_elf | MacOS_x86_macho -> outfile ^ ".d" | Win32_x86_pe -> (Filename.chop_extension outfile) ^ ".d" in @@ -473,6 +489,7 @@ let main_pipeline _ = Win32_x86_pe -> Pe.emit_file | MacOS_x86_macho -> Macho.emit_file | Linux_x86_elf -> Elf.emit_file + | FreeBSD_x86_elf -> Elf.emit_file in Session.time_inner "emit" sess (fun _ -> emitter sess crate code data sem_cx dwarf); diff --git a/src/boot/fe/cexp.ml b/src/boot/fe/cexp.ml index 56f3e878ca4..0f216fc2993 100644 --- a/src/boot/fe/cexp.ml +++ b/src/boot/fe/cexp.ml @@ -628,6 +628,7 @@ let parse_crate_file let (os, arch, libc) = match sess.Session.sess_targ with Linux_x86_elf -> ("linux", "x86", "libc.so.6") + | FreeBSD_x86_elf -> ("freebsd", "x86", "libc.so.7") | Win32_x86_pe -> ("win32", "x86", "msvcrt.dll") | MacOS_x86_macho -> ("macos", "x86", "libc.dylib") in diff --git a/src/boot/util/common.ml b/src/boot/util/common.ml index f9b18246c79..c76da0de552 100644 --- a/src/boot/util/common.ml +++ b/src/boot/util/common.ml @@ -56,6 +56,7 @@ type target = Linux_x86_elf | Win32_x86_pe | MacOS_x86_macho + | FreeBSD_x86_elf ;; type ty_mach =