1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-16 09:53:17 +00:00
nixpkgs/pkgs/development/compilers/ocaml/mips64.patch
Lluís Batlle i Rossell a95eb06e26 Updating the patch for ocaml on mips.
Reported by rixed@happyleptic.org

svn path=/nixpkgs/branches/stdenv-updates/; revision=24476
2010-10-25 21:13:05 +00:00

241 lines
9.4 KiB
Diff

http://caml.inria.fr/mantis/view.php?id=4849
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 =
match Config.system with
- "ultrix" -> false
+ "ultrix" | "gnu" -> false
| "irix" -> true
| _ -> fatal_error "Arch_mips.big_endian"
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`;
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 *)
`{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`;
liveregs i live_25;
- ` 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`
@@ -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`; (* Rxd: put before gp restore *)
if !uses_gp then
` 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`;
liveregs i live_25;
` j $25\n`
end
@@ -305,8 +305,13 @@
begin match chunk with
Double_u ->
(* Destination is not 8-aligned, hence cannot use l.d *)
+ 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`;
+ ` 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`
+ end;
` dmtc1 $24, {emit_reg dest}\n`
| Single ->
` 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`;
+ 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`
+ end else begin
+ ` 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,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. *)
+ 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`;
@@ -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 -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 /* 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 */
@@ -254,7 +254,7 @@
sw $0, caml_last_return_address
/* Call the Caml code */
move $25, $24
- jal $24
+ jal $25 /* Rxd: 24 replaced by 25 */
$104:
/* Pop the trap frame, restoring caml_exception_pointer */
lw $24, 0($sp)
@@ -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
withsharedlibs=yes
-gcc_warnings="-Wall"
+gcc_warnings="-W -Wall"
partialld="ld -r"
# Try to turn internationalization off, can cause config.guess to malfunction!
@@ -292,6 +292,9 @@
# (For those who want to force "cc -64")
# Turn off warning "unused library"
bytecclinkopts="-Wl,-woff,84";;
+ gcc*,mips64el-*)
+ bytecccompopts=""
+ bytecclinkopts="-fno-defer-pop $gcc_warnings -Wl,-O1 -Wl,--as-needed";;
*,alpha*-*-unicos*)
# For the Cray T3E
bytecccompopts="-DUMK";;
@@ -468,6 +471,8 @@
echo "64-bit integers must be doubleword-aligned."
echo "#define ARCH_ALIGN_INT64" >> m.h
fi;;
+ mips64el-*)
+ echo "#define ARCH_ALIGN_INT64" >> m.h;;
*)
sh ./runtest int64align.c
case $? in
@@ -636,6 +641,7 @@
fi;;
i[3456]86-*-gnu*) arch=i386; system=gnu;;
mips-*-irix6*) arch=mips; system=irix;;
+ mips*-gnu*) arch=mips; system=gnu;;
hppa1.1-*-hpux*) arch=hppa; system=hpux;;
hppa2.0*-*-hpux*) arch=hppa; system=hpux;;
hppa*-*-linux*) arch=hppa; system=linux;;
@@ -672,7 +678,7 @@
if test -z "$ccoption"; then
case "$arch,$system,$cc" in
alpha,digital,gcc*) nativecc=cc;;
- mips,*,gcc*) nativecc=cc;;
+ mips,irix,gcc*) nativecc=cc;;
*) nativecc="$bytecc";;
esac
else
@@ -687,6 +693,9 @@
alpha,cc*,digital,*) nativecccompopts=-std1;;
mips,cc*,irix,*) nativecccompopts=-n32
nativecclinkopts="-n32 -Wl,-woff,84";;
+ mips,gcc*,gnu,mips64el-*)
+ nativecccompopts="$gcc_warnings -fPIC"
+ nativecclinkopts="--as-needed";;
*,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
nativecclinkopts="-posix";;
*,*,rhapsody,*darwin[1-5].*)
@@ -725,6 +734,8 @@
aspp='gcc -c -Wa,-xexplicit';;
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 ?
power,*,elf) as='as -u -m ppc'
aspp='gcc -c';;
power,*,bsd) as='as'
@@ -756,6 +767,7 @@
case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
amd64,*,linux) profiling='prof';;
amd64,*,gnu) profiling='prof';;
+ 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