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

Incorrect code for alpha #3912

Closed
vicuna opened this issue Dec 8, 2005 · 3 comments
Closed

Incorrect code for alpha #3912

vicuna opened this issue Dec 8, 2005 · 3 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Dec 8, 2005

Original bug ID: 3912
Reporter: anonymous
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2011-06-04T15:59:38Z)
Resolution: won't fix
Priority: normal
Severity: crash
Version: 3.09.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @glondu gildor smimram jcristau

Bug description

OCaml native code programs crash when used with recent versions of GNU ld on alpha. This appears to be because ld now implements global optimizations on the gp register (relaxing). The code generator signifies to the linker when this is safe via .prologue commands. However, these appear to be generated incorrectly by OCaml at times. For instance, the code for caml_apply2 is:
caml_apply2:
...
.prologue 0
...
mov $1, $27
.livereg 0x4007e030, 0x00000000
jmp ($1)

As I understand it, a .prologue value of 0 means that the gp register ($27) is unused by the function, however it is clearly used here. Indeed setting the value >0 avoids the segfault (at least until the next function with .prologue incorrectly set to 0). I'm not an alpha assembly expert (most of my knowledge was learned via searching for this bug!), but it looks like the instr_needs_gp function in alpha/emit.mlp needs to at least check for Imov when one operand is $29. This would require some restructuring, so I don't have a patch at the moment, but if you're interested, I can probably come up with one.

This behavior is present in the current binutils package (2.16.1cvs20051117-1) in Debian's unstable distribution. Although this package is based on a CVS snapshot of binutils, the behavior will be included in the next release which shouldn't be too far away. I don't have a small example to reproduce this, buf if you rebuild OCaml on alpha, then ocamlopt.opt will segfault at startup. A temporary workaround is to pass -Wl,--no-relax to gcc which turns off the optimization.

Cheers,
Mike Furr (mfurr at debian.org)

@vicuna
Copy link
Author

vicuna commented Dec 8, 2005

Comment author: anonymous

err, that second register should also be $27, not $29... sorry.

Also, the original Debian bug report is here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=338148
Julien Cristau and Steve Langasek were instrumental in finding its cause.

@vicuna
Copy link
Author

vicuna commented Jan 10, 2006

Comment author: jcristau

Adding -Wl,--no-relax to bytecclinkopts and nativecclinkopts in configure breaks ocamlopt -output-obj and ocamlopt -pack, which call "ld" directly with these options.
Is it possible to change the toplevel Makefile to use "gcc -nostdlib -Wl,-r" instead of "ld -r" in PARTIALLD and PACKLD, to make it possible to give the same options to native_pack_linker, native_c_linker and native_partial_linker?

See http://buildd.debian.org/fetch.php?&pkg=camomile&ver=0.6.3-2&arch=alpha&stamp=1136386763&file=log&as=raw
for what happens when native_pack_linker = "ld -r -Wl,--no-relax "

@vicuna
Copy link
Author

vicuna commented Jun 4, 2011

Comment author: @xavierleroy

Six years (!) after this PR was opened, it appears that the Alpha port of ocamlopt is dead for good. Debian wisely elected to a bytecode-only ocaml package on Alpha, we (Caml dev team) got no other requests to keep that port alive, and we also retired our last Alpha servers after 12 years of service. So, allow me to close this PR and declare ocamlopt/Alpha officially dead. RIP.

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

2 participants