Updating the patch for ocaml on mips.
Reported by rixed@happyleptic.org svn path=/nixpkgs/branches/stdenv-updates/; revision=24476
This commit is contained in:
parent
f3da1c5e80
commit
a95eb06e26
@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
|
||||
prePatch = ''
|
||||
CAT=$(type -tp cat)
|
||||
sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
|
||||
patch -p1 -l < ${./mips64.patch}
|
||||
patch -p0 < ${./mips64.patch}
|
||||
'';
|
||||
postBuild = ''
|
||||
ensureDir $out/include
|
||||
|
@ -1,8 +1,8 @@
|
||||
http://www.mail-archive.com/caml-list@yquem.inria.fr/msg04424.html
|
||||
http://caml.inria.fr/mantis/view.php?id=4849
|
||||
|
||||
diff -u -r ocaml-3.11.1/asmcomp/mips/arch.ml my_ocaml/asmcomp/mips/arch.ml
|
||||
--- ocaml-3.11.1/asmcomp/mips/arch.ml 2002-11-29 16:03:36.000000000 +0100
|
||||
+++ my_ocaml/asmcomp/mips/arch.ml 2009-08-09 23:18:31.000000000 +0200
|
||||
diff -bur ocaml-3.11.1/asmcomp/mips/arch.ml my_ocaml/asmcomp/mips/arch.ml
|
||||
--- asmcomp/mips/arch.ml 2002-11-29 16:03:36.000000000 +0100
|
||||
+++ asmcomp/mips/arch.ml 2009-08-09 23:18:31.000000000 +0200
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
let big_endian =
|
||||
@ -12,110 +12,105 @@ diff -u -r ocaml-3.11.1/asmcomp/mips/arch.ml my_ocaml/asmcomp/mips/arch.ml
|
||||
| "irix" -> true
|
||||
| _ -> fatal_error "Arch_mips.big_endian"
|
||||
|
||||
diff -u -r ocaml-3.11.1/asmcomp/mips/emit.mlp my_ocaml/asmcomp/mips/emit.mlp
|
||||
--- ocaml-3.11.1/asmcomp/mips/emit.mlp 2004-01-05 21:25:56.000000000 +0100
|
||||
+++ my_ocaml/asmcomp/mips/emit.mlp 2009-08-23 12:11:58.000000000 +0200
|
||||
diff -bur ocaml-3.11.1/asmcomp/mips/emit.mlp my_ocaml/asmcomp/mips/emit.mlp
|
||||
--- asmcomp/mips/emit.mlp 2004-01-05 21:25:56.000000000 +0100
|
||||
+++ asmcomp/mips/emit.mlp 2009-08-23 12:11:58.000000000 +0200
|
||||
@@ -58,7 +58,7 @@
|
||||
!stack_offset +
|
||||
4 * num_stack_slots.(0) + 8 * num_stack_slots.(1) +
|
||||
(if !contains_calls then if !uses_gp then 8 else 4 else 0) in
|
||||
- Misc.align size 16
|
||||
+ Misc.align size 16 (* n32 require quadword alignment *)
|
||||
|
||||
let slot_offset loc cl =
|
||||
match loc with
|
||||
@@ -252,7 +252,7 @@
|
||||
| Lop(Icall_ind) ->
|
||||
` move $25, {emit_reg i.arg.(0)}\n`;
|
||||
` move $25, {emit_reg i.arg.(0)}\n`;
|
||||
liveregs i live_25;
|
||||
- ` jal {emit_reg i.arg.(0)}\n`;
|
||||
+ ` jal $25\n`; (* {emit_reg i.arg.(0)}\n; Equivalent but avoids "Warning: MIPS PIC call to register other than $25" on GNU as *)
|
||||
- ` jal {emit_reg i.arg.(0)}\n`;
|
||||
+ ` jal $25\n`; (* {emit_reg i.arg.(0)}\n; Equivalent but avoids "Warning: MIPS PIC call to register other than $25" on GNU as *)
|
||||
`{record_frame i.live}\n`
|
||||
| Lop(Icall_imm s) ->
|
||||
liveregs i 0;
|
||||
@@ -269,7 +269,7 @@
|
||||
liveregs i 0;
|
||||
` move $25, {emit_reg i.arg.(0)}\n`;
|
||||
` move $25, {emit_reg i.arg.(0)}\n`;
|
||||
liveregs i live_25;
|
||||
- ` j {emit_reg i.arg.(0)}\n`
|
||||
+ ` j $25\n`
|
||||
- ` j {emit_reg i.arg.(0)}\n`
|
||||
+ ` j $25\n`
|
||||
| Lop(Itailcall_imm s) ->
|
||||
if s = !function_name then begin
|
||||
` b {emit_label !tailrec_entry_point}\n`
|
||||
` b {emit_label !tailrec_entry_point}\n`
|
||||
@@ -277,11 +277,11 @@
|
||||
let n = frame_size() in
|
||||
if !contains_calls then
|
||||
` lw $31, {emit_int(n - 4)}($sp)\n`;
|
||||
+ ` la $25, {emit_symbol s}\n`;
|
||||
` lw $31, {emit_int(n - 4)}($sp)\n`;
|
||||
+ ` la $25, {emit_symbol s}\n`; (* Rxd: put before gp restore *)
|
||||
if !uses_gp then
|
||||
` lw $gp, {emit_int(n - 8)}($sp)\n`;
|
||||
` lw $gp, {emit_int(n - 8)}($sp)\n`;
|
||||
if n > 0 then
|
||||
` addu $sp, $sp, {emit_int n}\n`;
|
||||
- ` la $25, {emit_symbol s}\n`;
|
||||
` addu $sp, $sp, {emit_int n}\n`;
|
||||
- ` la $25, {emit_symbol s}\n`;
|
||||
liveregs i live_25;
|
||||
` j $25\n`
|
||||
` j $25\n`
|
||||
end
|
||||
@@ -305,8 +305,13 @@
|
||||
begin match chunk with
|
||||
Double_u ->
|
||||
(* Destination is not 8-aligned, hence cannot use l.d *)
|
||||
- ` ldl $24, {emit_addressing addr i.arg 0}\n`;
|
||||
- ` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`;
|
||||
+ if big_endian then begin
|
||||
+ ` ldl $24, {emit_addressing addr i.arg 0}\n`;
|
||||
+ ` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`
|
||||
` ldl $24, {emit_addressing addr i.arg 0}\n`;
|
||||
- ` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`;
|
||||
+ ` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`
|
||||
+ end else begin
|
||||
+ ` ldl $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`;
|
||||
+ ` ldr $24, {emit_addressing addr i.arg 0}\n`
|
||||
+ ` ldl $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`;
|
||||
+ ` ldr $24, {emit_addressing addr i.arg 0}\n`
|
||||
+ end;
|
||||
` dmtc1 $24, {emit_reg dest}\n`
|
||||
` dmtc1 $24, {emit_reg dest}\n`
|
||||
| Single ->
|
||||
` l.s {emit_reg dest}, {emit_addressing addr i.arg 0}\n`;
|
||||
` l.s {emit_reg dest}, {emit_addressing addr i.arg 0}\n`;
|
||||
@@ -328,8 +333,13 @@
|
||||
Double_u ->
|
||||
(* Destination is not 8-aligned, hence cannot use l.d *)
|
||||
` dmfc1 $24, {emit_reg src}\n`;
|
||||
- ` sdl $24, {emit_addressing addr i.arg 1}\n`;
|
||||
- ` sdr $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`
|
||||
` dmfc1 $24, {emit_reg src}\n`;
|
||||
+ if big_endian then begin
|
||||
+ ` sdl $24, {emit_addressing addr i.arg 1}\n`;
|
||||
+ ` sdr $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`
|
||||
` sdl $24, {emit_addressing addr i.arg 1}\n`;
|
||||
` sdr $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`
|
||||
+ end else begin
|
||||
+ ` sdl $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`;
|
||||
+ ` sdr $24, {emit_addressing addr i.arg 1}\n`
|
||||
+ ` sdl $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`;
|
||||
+ ` sdr $24, {emit_addressing addr i.arg 1}\n`
|
||||
+ end
|
||||
| Single ->
|
||||
` cvt.s.d $f31, {emit_reg src}\n`;
|
||||
` s.s $f31, {emit_addressing addr i.arg 1}\n`
|
||||
@@ -552,16 +562,18 @@
|
||||
` cvt.s.d $f31, {emit_reg src}\n`;
|
||||
` s.s $f31, {emit_addressing addr i.arg 1}\n`
|
||||
@@ -552,6 +562,7 @@
|
||||
(* There are really two groups of registers:
|
||||
$sp and $30 always point to stack locations
|
||||
$2 - $21 never point to stack locations. *)
|
||||
- ` .noalias $2,$sp; .noalias $2,$30; .noalias $3,$sp; .noalias $3,$30\n`;
|
||||
- ` .noalias $4,$sp; .noalias $4,$30; .noalias $5,$sp; .noalias $5,$30\n`;
|
||||
- ` .noalias $6,$sp; .noalias $6,$30; .noalias $7,$sp; .noalias $7,$30\n`;
|
||||
- ` .noalias $8,$sp; .noalias $8,$30; .noalias $9,$sp; .noalias $9,$30\n`;
|
||||
- ` .noalias $10,$sp; .noalias $10,$30; .noalias $11,$sp; .noalias $11,$30\n`;
|
||||
- ` .noalias $12,$sp; .noalias $12,$30; .noalias $13,$sp; .noalias $13,$30\n`;
|
||||
- ` .noalias $14,$sp; .noalias $14,$30; .noalias $15,$sp; .noalias $15,$30\n`;
|
||||
- ` .noalias $16,$sp; .noalias $16,$30; .noalias $17,$sp; .noalias $17,$30\n`;
|
||||
- ` .noalias $18,$sp; .noalias $18,$30; .noalias $19,$sp; .noalias $19,$30\n`;
|
||||
- ` .noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`;
|
||||
+ if Config.system = "irix" then begin
|
||||
+ ` .noalias $2,$sp; .noalias $2,$30; .noalias $3,$sp; .noalias $3,$30\n`;
|
||||
+ ` .noalias $4,$sp; .noalias $4,$30; .noalias $5,$sp; .noalias $5,$30\n`;
|
||||
+ ` .noalias $6,$sp; .noalias $6,$30; .noalias $7,$sp; .noalias $7,$30\n`;
|
||||
+ ` .noalias $8,$sp; .noalias $8,$30; .noalias $9,$sp; .noalias $9,$30\n`;
|
||||
+ ` .noalias $10,$sp; .noalias $10,$30; .noalias $11,$sp; .noalias $11,$30\n`;
|
||||
+ ` .noalias $12,$sp; .noalias $12,$30; .noalias $13,$sp; .noalias $13,$30\n`;
|
||||
+ ` .noalias $14,$sp; .noalias $14,$30; .noalias $15,$sp; .noalias $15,$30\n`;
|
||||
+ ` .noalias $16,$sp; .noalias $16,$30; .noalias $17,$sp; .noalias $17,$30\n`;
|
||||
+ ` .noalias $18,$sp; .noalias $18,$30; .noalias $19,$sp; .noalias $19,$30\n`;
|
||||
+ ` .noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`
|
||||
` .noalias $2,$sp; .noalias $2,$30; .noalias $3,$sp; .noalias $3,$30\n`;
|
||||
` .noalias $4,$sp; .noalias $4,$30; .noalias $5,$sp; .noalias $5,$30\n`;
|
||||
` .noalias $6,$sp; .noalias $6,$30; .noalias $7,$sp; .noalias $7,$30\n`;
|
||||
@@ -561,7 +572,8 @@
|
||||
` .noalias $14,$sp; .noalias $14,$30; .noalias $15,$sp; .noalias $15,$30\n`;
|
||||
` .noalias $16,$sp; .noalias $16,$30; .noalias $17,$sp; .noalias $17,$30\n`;
|
||||
` .noalias $18,$sp; .noalias $18,$30; .noalias $19,$sp; .noalias $19,$30\n`;
|
||||
- ` .noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`;
|
||||
+ ` .noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`
|
||||
+ end;
|
||||
let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
|
||||
` .data\n`;
|
||||
` .globl {emit_symbol lbl_begin}\n`;
|
||||
diff -u -r ocaml-3.11.1/asmrun/mips.s my_ocaml/asmrun/mips.s
|
||||
--- ocaml-3.11.1/asmrun/mips.s 2004-07-13 14:18:53.000000000 +0200
|
||||
+++ my_ocaml/asmrun/mips.s 2009-08-20 09:34:36.000000000 +0200
|
||||
` .data\n`;
|
||||
` .globl {emit_symbol lbl_begin}\n`;
|
||||
diff -bur ocaml-3.11.1/asmrun/mips.s my_ocaml/asmrun/mips.s
|
||||
--- asmrun/mips.s 2004-07-13 14:18:53.000000000 +0200
|
||||
+++ asmrun/mips.s 2009-08-20 09:34:36.000000000 +0200
|
||||
@@ -187,7 +187,7 @@
|
||||
sw $30, caml_exception_pointer
|
||||
/* Call C function */
|
||||
move $25, $24
|
||||
- jal $24
|
||||
+ jal $25
|
||||
+ jal $25 /* Rxd: $24 replaced by $25 to avoid this "Warning: MIPS PIC call to register other than $25" ? */
|
||||
/* Reload return address, alloc ptr, alloc limit */
|
||||
lw $31, 0($16) /* caml_last_return_address */
|
||||
lw $22, 0($17) /* caml_young_ptr */
|
||||
@ -124,13 +119,22 @@ diff -u -r ocaml-3.11.1/asmrun/mips.s my_ocaml/asmrun/mips.s
|
||||
/* Call the Caml code */
|
||||
move $25, $24
|
||||
- jal $24
|
||||
+ jal $25
|
||||
+ jal $25 /* Rxd: 24 replaced by 25 */
|
||||
$104:
|
||||
/* Pop the trap frame, restoring caml_exception_pointer */
|
||||
lw $24, 0($sp)
|
||||
diff -u -r ocaml-3.11.1/configure my_ocaml/configure
|
||||
--- ocaml-3.11.1/configure 2009-05-20 17:33:09.000000000 +0200
|
||||
+++ my_ocaml/configure 2009-08-23 10:55:44.000000000 +0200
|
||||
@@ -384,3 +384,8 @@
|
||||
.word $104 /* return address into callback */
|
||||
.half -1 /* negative frame size => use callback link */
|
||||
.half 0 /* no roots here */
|
||||
+
|
||||
+#if defined(SYS_linux)
|
||||
+ /* Mark stack as non-executable, PR#4564 */
|
||||
+ .section .note.GNU-stack,"",%progbits
|
||||
+#endif
|
||||
diff -bur ocaml-3.11.1/configure my_ocaml/configure
|
||||
--- configure 2009-05-20 17:33:09.000000000 +0200
|
||||
+++ configure 2009-08-23 10:55:44.000000000 +0200
|
||||
@@ -40,7 +40,7 @@
|
||||
verbose=no
|
||||
withcurses=yes
|
||||
@ -155,7 +159,7 @@ diff -u -r ocaml-3.11.1/configure my_ocaml/configure
|
||||
echo "#define ARCH_ALIGN_INT64" >> m.h
|
||||
fi;;
|
||||
+ mips64el-*)
|
||||
+ echo "#define ARCH_ALIGN_INT64" >> m.h;;
|
||||
+ echo "#define ARCH_ALIGN_INT64" >> m.h;;
|
||||
*)
|
||||
sh ./runtest int64align.c
|
||||
case $? in
|
||||
@ -191,7 +195,7 @@ diff -u -r ocaml-3.11.1/configure my_ocaml/configure
|
||||
mips,*,irix) as='as -n32 -O2 -nocpp -g0'
|
||||
aspp='as -n32 -O2';;
|
||||
+ mips,*,gnu) as='as -KPIC'
|
||||
+ aspp='gcc -c -fPIC';; # got bus error without fPIC ?
|
||||
+ aspp='gcc -c -fPIC';; # got bus error without fPIC ?
|
||||
power,*,elf) as='as -u -m ppc'
|
||||
aspp='gcc -c';;
|
||||
power,*,bsd) as='as'
|
||||
@ -202,3 +206,35 @@ diff -u -r ocaml-3.11.1/configure my_ocaml/configure
|
||||
+ mips,*,gnu) profiling='prof';;
|
||||
*) profiling='noprof';;
|
||||
esac
|
||||
|
||||
diff -bur ocaml-3.11.1/asmcomp/mips/proc.ml my_ocaml/asmcomp/mips/proc.ml
|
||||
--- asmcomp/mips/proc.ml 2007-10-30 13:37:16.000000000 +0100
|
||||
+++ asmcomp/mips/proc.ml 2010-03-18 08:08:06.000000000 +0100
|
||||
@@ -114,7 +114,7 @@
|
||||
incr int
|
||||
end else begin
|
||||
loc.(i) <- stack_slot (make_stack !ofs) ty;
|
||||
- ofs := !ofs + size_int
|
||||
+ ofs := !ofs + 8
|
||||
end
|
||||
| Float ->
|
||||
if !float <= last_float then begin
|
||||
@@ -143,7 +143,7 @@
|
||||
or float regs $f12...$f19. Each argument "consumes" both one slot
|
||||
in the int register file and one slot in the float register file.
|
||||
Extra arguments are passed on stack, in a 64-bits slot, right-justified
|
||||
- (i.e. at +4 from natural address). *)
|
||||
+ (i.e. at +4 from natural address for big endians). *)
|
||||
|
||||
let loc_external_arguments arg =
|
||||
let loc = Array.create (Array.length arg) Reg.dummy in
|
||||
@@ -158,7 +158,7 @@
|
||||
end else begin
|
||||
begin match arg.(i).typ with
|
||||
Float -> loc.(i) <- stack_slot (Outgoing !ofs) Float
|
||||
- | ty -> loc.(i) <- stack_slot (Outgoing (!ofs + 4)) ty
|
||||
+ | ty -> loc.(i) <- stack_slot (Outgoing (!ofs + (if big_endian then 4 else 0))) ty
|
||||
end;
|
||||
ofs := !ofs + 8
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user