-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cannot build on Mac OS X 32-bit with Xcode 4.0.2 #5268
Comments
Comment author: jhowarth The darwin linker developer had the following observations on this problem... The problem is in ocamlbuild_pack.o. There is a wacky relocation: [/tmp/ocaml_bug]> otool -rv ocamlbuild_pack.o | grep -A4 'Relocation information (__DATA,__data)' Segment : 301288 (vmaddr 0x0 fileoff 424) The reloc 0xDC bytes into the __DATA/__data section references 0x04028458 which you can see (via size -l output) is not a valid address in the object file. Interestingly, if you lop of the high bit (to become 0x00028458), the address is valid. Is this a single bit error somewhere? ...later analyzing the component object files making up ocamlbuild_pack.o, he observed... [/tmp/ocaml_bug_pt2]> otool -rv discard_printf.o
0000001c False long False VANILLA False 1 (__TEXT,__text) [/tmp/ocaml_bug_pt2]> otool -s __DATA __data discard_printf.o The issue is at _camlOcamlbuild_pack__Discard_printf__frametable + 16. There is a sect-diff reloc at that address (0x70 = __data + 0x28). The problem is the content |
Comment author: jhowarth Further analysis of the offending discard_printf.o by adding -S to ../ocamlcompopt.sh and executing... [MacPro-2:ocaml-3.12.0-2/ocaml-3.12.0/_build] root# ../ocamlcompopt.sh -nostdlib -c -g -annot -rectypes -warn-error A -w L -w R -w Z -I ../otherlibs/unix -for-pack Ocamlbuild_pack -I ocamlbuild -I stdlib -o ocamlbuild/discard_printf.cmx ocamlbuild/discard_printf.ml ...by the darwin linker maintainer is that... The issue is this:
L200000: The label L200000 is 8 bytes ahead, and (.) means current location, so (L200000 - . ) means 8. But the assembler does not know this a assembly time constant, so passes it on to the linker. The linker bug is in handling a degenerate relocation which is the difference of the same location plus a huge constant. |
Comment author: jhowarth Uploaded assembly file for discard_printf.s from i386 darwin which contains the offending assembly. |
Comment author: jeffsco I'm trying to build a 32-bit version of 3.12.0 under Xcode 4.0.2, and I see the same problem exactly. I'd love to see this problem resolved. I'm running OCaml code in the iPhone Simulator, for which I need 32-bit code. In the meantime I'll downgrade to previous Xcode (3.2.5), which seems to be working. |
Comment author: jhowarth Am I correct to assume that it is impossible to get ocamlopt to produce a preprocessed source file rather than just the assembly file? I was hoping a preprocessed source file would contain clues to why...
L200000: this is present in the generated assembly. |
Comment author: @xavierleroy I very much hope this regression in Xcode will be fixed, since we have here a useful idiom that has been working flawlessy with earlier versions of Xcode and indeed with any other assembler/linker combination we've tested on other systems. FYI, "what it is trying to do here" is to store debugging information that is carefully packed in a 64-bit word according to the pseudo-C-struct-with-bitfields below: struct debuginfo { The "filename_offset" field encodes a pointer to a string literal, but to save bits it contains the difference between the string literal and the beginning of the struct. In pseudo-C again, the debugging info 'file "foo.ml", line 15, characters 25-65' would be initialized as follows: char filename[] = "foo.ml"; struct debuginfo dbg1 = { In assembly, that gives: dbg1: Two things surprise me in the explanations given in previous notes: |
Comment author: jhowarth The response from the darwin linker developer was... It is a linker bug. I've already fixed it. It may just take awhile to make it way into a release. There is a work around, the assembly could be changed to: dbg1: The .set directive forces the delta value to be computed at assembly time. |
Comment author: @xavierleroy Thanks for the info.
That's good to know. Would it make a difference if Lfilename was defined before "Lfilename - . + 0x40000000" is computed? That would be easy to arrange and might help reducing the number of relocs on other platforms as well. (Wild guess.) |
Comment author: @xavierleroy A follow-up on the two workarounds proposed so far: 1- Define Lfilename before "Lfilename - . + 0x40000000" is computed. 2- Use ".set Ldelta, Lfilename - . ; .long Ldelta + 0x4000000". So I'm afraid we are stuck for the moment. The few OCaml users who need to compile it in 32 bits under MacOS X will have to wait for an upgrade to XCode 4.0.2 or downgrade to an earlier version of XCode. |
Comment author: @damiendoligez It looks like Apple fixed their linker: OCaml 3.12.1 works on Mac OS 10.7 (Lion) with XCode 4.1 after applying the patch found in #4863. |
Comment author: Pascal Cuoq Thanks everyone involved in this report for documenting the trail. For whoever will pass next, if, say, you have tasted the command-line tools for Snow Leopard (https://github.com/kennethreitz/osx-gcc-installer/ ) and are loath to download the four and a half Gigabytes that is Xcode 3.2.6, solution 2 in comment 0006002 can be implemented in OCaml 4.00.1 with the patch below. OCaml 4.00.1, thus patched, compiled with the command-line tools at https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg , works fine to the best of my testing. macbook:ocaml-4.00.1 pascal$ diff -u asmcomp/i386/emit.mlp{
|
Original bug ID: 5268
Reporter: brendan
Assigned to: @damiendoligez
Status: closed (set by @xavierleroy on 2015-12-11T18:08:32Z)
Resolution: not a bug
Priority: normal
Severity: crash
Version: 3.12.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: jeffsco "Pascal Cuoq"
Bug description
Ocaml 3.12.0 builds fine on Mac OS X (10.6.7) with Xcode 4.0.2 in 64-bit mode. Attempting to build it in 32-bit mode results in:
../ocamlcompopt.sh -nostdlib unix.cmxa -g -I stdlib -I ../otherlibs/unix ocamlbuild/ocamlbuild_executor.cmx ocamlbuild/ocamlbuild_pack.cmx ocamlbuild/ocamlbuild_unix_plugin.cmx ocamlbuild/ocamlbuild.cmx -o ocamlbuild/ocamlbuild.native
ld: in ocamlbuild/ocamlbuild_pack.o, in section __DATA,__data reloc 1: sectionForAddress(0x4028458) address not in any section for architecture i386
I've tried -cc "gcc-4.0 -m32" -as "as -arch i386" -aspp "gcc-4.0 -m32 -c" as well as gcc-4.2
File attachments
The text was updated successfully, but these errors were encountered: