Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetBSD PowerPC & SPARC support for native code compilation #8200

Closed
vicuna opened this issue Jul 9, 2003 · 1 comment
Closed

NetBSD PowerPC & SPARC support for native code compilation #8200

vicuna opened this issue Jul 9, 2003 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 9, 2003

Original bug ID: 1746
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

I made the attached changes to ocaml-3.0.6 to support the
native code compilers on NetBSD PowerPC and SPARC (ELF).
The changes have been fully tested.

Regards,

Jason


diff -Nurab ocaml-3.06.orig/asmcomp/power/arch.ml ocaml-3.06/asmcomp/power/arch.ml
--- ocaml-3.06.orig/asmcomp/power/arch.ml 2002-07-22 17:37:53.000000000 +0100
+++ ocaml-3.06/asmcomp/power/arch.ml 2003-07-09 06:27:55.000000000 +0100
@@ -91,6 +91,5 @@
let toc =
match Config.system with
| "aix" -> true

  • | "elf" -> false
  • | "rhapsody" -> false
  • | "elf" | "rhapsody" | "bsd" -> false
    | _ -> Misc.fatal_error "wrong $(SYSTEM)"
    diff -Nurab ocaml-3.06.orig/asmcomp/power/emit.mlp ocaml-3.06/asmcomp/power/emit.mlp
    --- ocaml-3.06.orig/asmcomp/power/emit.mlp 2002-07-22 17:37:53.000000000 +0100
    +++ ocaml-3.06/asmcomp/power/emit.mlp 2003-07-09 06:27:55.000000000 +0100
    @@ -65,7 +65,7 @@

let emit_symbol =
match Config.system with

  • "aix" | "elf" -> (fun s -> Emitaux.emit_symbol '.' s)
  • "aix" | "elf" | "bsd" -> (fun s -> Emitaux.emit_symbol '.' s)
    | "rhapsody" -> (fun s -> emit_char '_'; Emitaux.emit_symbol '$' s)
    | _ -> assert false

@@ -78,7 +78,7 @@
let label_prefix =
match Config.system with
"aix" -> "L.."

  • | "elf" -> ".L"
  • | "elf" | "bsd" -> ".L"
    | "rhapsody" -> "L"
    | _ -> assert false

@@ -90,21 +90,21 @@
let data_space =
match Config.system with
"aix" -> " .csect .data[RW]\n"

  • | "elf" -> " .section ".data"\n"
  • | "elf" | "bsd" -> " .section ".data"\n"
    | "rhapsody" -> " .data\n"
    | _ -> assert false

let code_space =
match Config.system with
"aix" -> " .csect .text[PR]\n"

  • | "elf" -> " .section ".text"\n"
  • | "elf" | "bsd" -> " .section ".text"\n"
    | "rhapsody" -> " .text\n"
    | _ -> assert false

let rodata_space =
match Config.system with
"aix" -> " .csect .data[RW]\n" (* ?? *)

  • | "elf" -> " .section ".rodata"\n"
  • | "elf" | "bsd" -> " .section ".rodata"\n"
    | "rhapsody" -> " .const\n"
    | _ -> assert false

@@ -157,7 +157,7 @@

let emit_upper emit_fun arg =
match Config.system with

  • "elf" ->
  • "elf" | "bsd" ->
    emit_fun arg; emit_string "@ha"
    | "rhapsody" ->
    emit_string "ha16("; emit_fun arg; emit_string ")"
    @@ -165,7 +165,7 @@

let emit_lower emit_fun arg =
match Config.system with

  • "elf" ->
  • "elf" | "bsd" ->
    emit_fun arg; emit_string "@l"
    | "rhapsody" ->
    emit_string "lo16("; emit_fun arg; emit_string ")"
    @@ -951,7 +951,7 @@
    .csect {emit_symbol fundecl.fun_name}[DS]\n;
    {emit_symbol fundecl.fun_name}:\n;
    .long .{emit_symbol fundecl.fun_name}, TOC[tc0], 0\n
  • | "elf" ->
  • | "elf" | "bsd" ->
    .type {emit_symbol fundecl.fun_name}, @function\n
    | _ -> ()
    end;
    @@ -996,7 +996,7 @@

let declare_global_data s =
.globl {emit_symbol s}\n;

  • if Config.system = "elf" then
  • if Config.system = "elf" || Config.system = "bsd" then
    .type {emit_symbol s}, @object\n

let emit_item = function
diff -Nurab ocaml-3.06.orig/asmcomp/power/proc.ml ocaml-3.06/asmcomp/power/proc.ml
--- ocaml-3.06.orig/asmcomp/power/proc.ml 2002-07-22 17:37:54.000000000 +0100
+++ ocaml-3.06/asmcomp/power/proc.ml 2003-07-09 06:27:55.000000000 +0100
@@ -190,7 +190,7 @@
let loc_external_arguments =
match Config.system with
"aix" | "rhapsody" -> poweropen_external_conventions 0 7 100 112

  • | "elf" -> calling_conventions 0 7 100 107 outgoing 8
  • | "elf" | "bsd" -> calling_conventions 0 7 100 107 outgoing 8
    | _ -> assert false

let extcall_use_push = false
@@ -244,7 +244,7 @@
Ccomp.command ("as -u -m " ^ proc ^ " -o " ^ outfile ^ " " ^ infile)
| "elf" ->
Ccomp.command ("as -u -m ppc -o " ^ outfile ^ " " ^ infile)

  • | "rhapsody" ->
  • | "rhapsody" | "bsd" ->
    Ccomp.command ("as -o " ^ outfile ^ " " ^ infile)
    | _ -> assert false

diff -Nurab ocaml-3.06.orig/asmcomp/sparc/emit.mlp ocaml-3.06/asmcomp/sparc/emit.mlp
--- ocaml-3.06.orig/asmcomp/sparc/emit.mlp 2002-07-22 17:37:55.000000000 +0100
+++ ocaml-3.06/asmcomp/sparc/emit.mlp 2003-07-09 06:27:55.000000000 +0100
@@ -57,11 +57,10 @@
| {loc = Reg r; typ = Float} -> phys_reg (r + 16)
| _ -> fatal_error "Emit.next_in_pair"

-(* Symbols are prefixed with _ under SunOS and BSD but not under Solaris

  • nor Linux )
    +(
    Symbols are prefixed with _ under SunOS *)

let symbol_prefix =

  • if Config.system = "solaris" || Config.system = "linux" then "" else "_"
  • if Config.system = "sunos" then "_" else ""

let emit_symbol s =
if String.length s >= 1 & s.[0] = '.'
@@ -79,7 +78,7 @@
(* Output a label *)

let label_prefix =

  • if Config.system = "solaris" || Config.system = "linux" then ".L" else "L"
  • if Config.system = "sunos" then "L" else ".L"

let emit_label lbl =
emit_string label_prefix; emit_int lbl
diff -Nurab ocaml-3.06.orig/asmrun/signals.c ocaml-3.06/asmrun/signals.c
--- ocaml-3.06.orig/asmrun/signals.c 2002-05-06 13:02:26.000000000 +0100
+++ ocaml-3.06/asmrun/signals.c 2003-07-09 06:27:55.000000000 +0100
@@ -162,6 +162,8 @@
void handle_signal(int sig, struct sigcontext * context)
#elif defined(TARGET_power) && defined(SYS_rhapsody)
void handle_signal(int sig, int code, struct sigcontext * context)
+#elif defined(TARGET_power) && defined(SYS_bsd)
+void handle_signal(int sig, int code, struct sigcontext * context)
#else
void handle_signal(int sig)
#endif
@@ -205,6 +207,10 @@
/* Cached in register 30 */
CONTEXT_GPR(context, 30) = (unsigned long) young_limit;
#endif
+#if defined(TARGET_power) && defined(SYS_bsd)

  •  /* Cached in register 30 */
    
  •  context->sc_frame.fixreg[30] = (unsigned long) young_limit;
    

+#endif
}
}
}
@@ -443,6 +449,17 @@
}
#endif

+#if defined(TARGET_power) && defined(SYS_bsd)
+static void trap_handler(int sig, int code, struct sigcontext * context)
+{

  • /* Recover young_ptr and caml_exception_pointer from registers 31 and 29 */
  • caml_exception_pointer = (char *) context->sc_frame.fixreg[29];
  • young_ptr = (char *) context->sc_frame.fixreg[31];
  • array_bound_error();
    +}
    +#endif

/* Machine- and OS-dependent handling of stack overflow */

#ifdef HAS_STACK_OVERFLOW_DETECTION
diff -Nurab ocaml-3.06.orig/asmrun/sparc.S ocaml-3.06/asmrun/sparc.S
--- ocaml-3.06.orig/asmrun/sparc.S 2002-02-08 16:55:33.000000000 +0000
+++ ocaml-3.06/asmrun/sparc.S 2003-07-09 06:27:55.000000000 +0100
@@ -16,9 +16,9 @@
/* Asm part of the runtime system for the Sparc processor. /
/
Must be preprocessed by cpp */

-/* SunOS 4 and BSD prefix identifiers with _, Solaris and Linux do not /
+/
SunOS 4 prefixes identifiers with _ */

-#if defined(SYS_sunos) || defined(SYS_bsd)
+#if defined(SYS_sunos)

     .common _caml_required_size, 4, "bss"

diff -Nurab ocaml-3.06.orig/configure ocaml-3.06/configure
--- ocaml-3.06.orig/configure 2002-08-07 13:45:00.000000000 +0100
+++ ocaml-3.06/configure 2003-07-09 06:27:55.000000000 +0100
@@ -528,6 +528,7 @@
rs6000--aix) arch=power; model=rs6000; system=aix;;
powerpc--aix) arch=power; model=ppc; system=aix;;
powerpc--linux) arch=power; model=ppc; system=elf;;

  • powerpc--netbsd) arch=power; model=ppc; system=bsd;;
    powerpc--rhapsody) arch=power; model=ppc; system=rhapsody;;
    powerpc--darwin) arch=power; model=ppc; system=rhapsody;;
    arm*--linux) arch=arm; system=linux;;
    @@ -591,6 +592,7 @@
    power,rs6000,aix) asflags='-u -m pwr -w'; asppflags="$asflags";;
    power,ppc,aix) asflags='-u -m ppc -w'; asppflags="$asflags";;
    power,*,elf) aspp='gcc'; asppflags='-c';;
  • power,,bsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
    power,
    ,rhapsody) ;;
    arm,,linux) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';;
    ia64,
    ,linux) asflags=-xexplicit
    @@ -601,6 +603,9 @@
    alpha,,digital) profiling='prof';;
    i386,
    ,linux_elf) profiling='prof';;
    i386,*,bsd_elf) profiling='prof';;
  • power,*,bsd) profiling='prof';;
  • power,*,elf) profiling='prof';;
  • sparc,*,bsd) profiling='prof';;
    *) profiling='noprof';;
    esac


@vicuna
Copy link
Author

vicuna commented Jul 17, 2003

Comment author: administrator

Merged 2003-07-17 by XL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant