[GHC] #7603: Bad magic in static (FFI) object (7.6.1 for x86_64-apple-darwin)
GHC
cvs-ghc at haskell.org
Fri Jan 18 01:38:42 CET 2013
#7603: Bad magic in static (FFI) object (7.6.1 for x86_64-apple-darwin)
-------------------------------+--------------------------------------------
Reporter: morabbin | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.6.1 | Keywords:
Os: MacOS X | Architecture: x86_64 (amd64)
Failure: Compile-time crash | Blockedby:
Blocking: | Related:
-------------------------------+--------------------------------------------
Comment(by thoughtpolice):
Template Haskell is not the problem.
The Mach-O file format has a special 'magic number' in the head of all
object files to identify them; the runtime linker then checks this magic
number for sanity, when it loads object files at runtime.
The definition of the Mach-O format and some relative constants is
[http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/EXTERNAL_HEADERS/mach-o/loader.h
here]. We see:
{{{
/*
* The 32-bit mach header appears at the very beginning of the object file
for
* 32-bit architectures.
*/
struct mach_header {
uint32_t magic; /* mach magic number identifier */
...
};
/* Constant for the magic field of the mach_header (32-bit architectures)
*/
#define MH_MAGIC 0xfeedface /* the mach magic number */
#define MH_CIGAM 0xcefaedfe /* NXSwapInt(MH_MAGIC) */
/*
* The 64-bit mach header appears at the very beginning of object files
for
* 64-bit architectures.
*/
struct mach_header_64 {
uint32_t magic; /* mach magic number identifier */
...
};
/* Constant for the magic field of the mach_header_64 (64-bit
architectures) */
#define MH_MAGIC_64 0xfeedfacf /* the 64-bit mach magic number */
#define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */
}}}
In a nutshell, this means your ```HOC_cbits``` was compiled as a 32-bit
object file, but your GHC is 64bit. Therefore, loading the C bits is
impossible. You likely need to recompile it properly (I don't know how the
HOC binding takes care of this, but it's probably worth looking around in
any makefiles if they exist, or something.) So I don't think this has
anything to do with GHC.
(I am also a little confused by the output you pasted. I assume in-between
every ```cabal build``` step you fixed the errors?)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7603#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list