Re: hsc2hs on Mac
On 17/05/2011 03:10, Kazu Yamamoto (山本和彦) wrote: Hello, Not directly. hsc2hs calls the C compiler to determine these numbers. It seems it is calling gcc-4.0 rather than gcc-4.2. It might be a bug that it is calling the wrong compiler, but that might just be misconfiguration in your environment, or in the Haskell Platform. gcc-4.0 says sizeof (struct stat) is 108 while gcc-4.2 (default) says that is 144. It presumably depends on whether you're using the 32 or 64-bit version of GHC. Which is it? % file /Library/Frameworks/GHC.framework/Versions/7.0.3-i386/usr/lib/ghc-7.0.3/ghc /Library/Frameworks/GHC.framework/Versions/7.0.3-i386/usr/lib/ghc-7.0.3/ghc: Mach-O executable i386 So, it's 32bit. (If 64bit, file displays 64bit.) Ok, you are using GHC 32-bit on a system that normally compiles for 64-bit by default. That's fine, and it should work, but you might need to be careful when combining code compiled by gcc with code compiled by GHC. In particular, you should use gcc -m32. Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac
On 13/05/2011 08:20, Malcolm Wallace wrote: hsc2hs converts (#const sizeof(struct stat)) (#peek struct stat, st_mtimespec) to 108 36 but the correct values are 144 32. Is this a bug of hsc2hs? Not directly. hsc2hs calls the C compiler to determine these numbers. It seems it is calling gcc-4.0 rather than gcc-4.2. It might be a bug that it is calling the wrong compiler, but that might just be misconfiguration in your environment, or in the Haskell Platform. gcc-4.0 says sizeof (struct stat) is 108 while gcc-4.2 (default) says that is 144. It presumably depends on whether you're using the 32 or 64-bit version of GHC. Which is it? Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac
Hello, Not directly. hsc2hs calls the C compiler to determine these numbers. It seems it is calling gcc-4.0 rather than gcc-4.2. It might be a bug that it is calling the wrong compiler, but that might just be misconfiguration in your environment, or in the Haskell Platform. gcc-4.0 says sizeof (struct stat) is 108 while gcc-4.2 (default) says that is 144. It presumably depends on whether you're using the 32 or 64-bit version of GHC. Which is it? % file /Library/Frameworks/GHC.framework/Versions/7.0.3-i386/usr/lib/ghc-7.0.3/ghc /Library/Frameworks/GHC.framework/Versions/7.0.3-i386/usr/lib/ghc-7.0.3/ghc: Mach-O executable i386 So, it's 32bit. (If 64bit, file displays 64bit.) --Kazu ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac
hsc2hs converts (#const sizeof(struct stat)) (#peek struct stat, st_mtimespec) to 108 36 but the correct values are 144 32. Is this a bug of hsc2hs? Not directly. hsc2hs calls the C compiler to determine these numbers. It seems it is calling gcc-4.0 rather than gcc-4.2. It might be a bug that it is calling the wrong compiler, but that might just be misconfiguration in your environment, or in the Haskell Platform. gcc-4.0 says sizeof (struct stat) is 108 while gcc-4.2 (default) says that is 144. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
hsc2hs on Mac
Hello, I'm using Haskell Platform 2011.2.0.1 on MacOS (Snow Leapard). hsc2hs converts (#const sizeof(struct stat)) (#peek struct stat, st_mtimespec) to 108 36 but the correct values are 144 32. Is this a bug of hsc2hs? gcc-4.0 says sizeof (struct stat) is 108 while gcc-4.2 (default) says that is 144. --Kazu ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac OS 10.6 unreliable?
On 8 June 2010 22:03, Axel Simon axel.si...@in.tum.de wrote: The offsets that hsc2hs calculates are too large, so it is probably in x86_64 mode. Is it just this problem: http://hackage.haskell.org/trac/ghc/ticket/3400 If you use an older GHC you will need to manually patch the hsc2hs script to pass the right command line options. Cheers, Max ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac OS 10.6 unreliable?
The story on OS X 10.6 with ghc-6.12 on x86 hardware seems to be this: Apple's gcc: Defaults to i386 or ppc on Mac OS X 10.5 and earlier, depending on the CPU type detected at runtime. On Mac OS X 10.6 the default is x86_64 if the CPU supports it, i386 otherwise. Passing -arch i386 or -arch x86_64 explicitly chooses the mode explicitly. Passing BOTH -arch i386 AND -arch x86_64 creates something special which is a universal binary that holds both versions in a single file. MacPorts: The provides an easy way to compile and install a plethora of mostly unix-y software from source. It handles the arch problem by allowing +universal to be specified when installing a package or set by default in /opt/local/etc/macports/variants.conf, which is what I have done. Without +universal the default arch can be specified in /opt/local/etc/macports/macports.conf. gtk: I have build gtk2-2.20.1 with macports as a universal library. ghc: Unlike ghc on Linux, ghc on OS X is not capable of creating x86_64 libraries and programs. Using ghc before 6.12 on OS X 10.6 used to require some small option hacks to explicitly set -arch i386. Now ghc is invoked directly. ( http://hackage.haskell.org/trac/ghc/ticket/2965 ) hsc2hs: On OS 10.6 ghc is calling hsc2hs without any special -arch option, and hsc2hs is calculating offsets in x86_64 mode. This is breaking the interface between ghc and c-structures for various libraries. In particular I ran into this with gtk2hs. It may suffice to get '--cc-flag=-m32 --ld-flag=-m32' to hsc2hs as a work around. While ticket #2965 is not yet fixed it would be better if hsc2hs understood the default arch on OS X 10.6 is not compatible with ghc. -- Chris On 08/06/2010 22:03, Axel Simon wrote: Hi all, we're facing serious problems (the seg'faulting kind) with Gtk2Hs on Mac OS 10.6. Chris has tracked this down to incorrect structure offsets that hsc2hs calculates. The offsets that hsc2hs calculates are too large, so it is probably in x86_64 mode. The offsets with which Gtk+ was compiled are smaller, so it must have been compiled with something like -arch i386. My question is the following: What is the right way to compile unixy software on Mac OS 10.6. Is the Gtk+ library incorrectly compiled or is hsc2hs not producing its C file in the correct way? It seems that a C Gtk+ program works correctly when compiled with no special flags. The only thing we could do is to pass some magic option to hsc2hs when it creates the C program that calculates the offsets. Detecting how Gtk+ was compiled would require some sort of autoconf magic which is beyond a simple cabal file. So I probably cannot hope for an easy fix. Any comments or experience appreciated, cheers, Axel ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac OS 10.6 unreliable?
Chris Kuklewicz schrieb: hsc2hs: On OS 10.6 ghc is calling hsc2hs without any special -arch option, and hsc2hs is calculating offsets in x86_64 mode. This is breaking the interface between ghc and c-structures for various libraries. In particular I ran into this with gtk2hs. It may suffice to get '--cc-flag=-m32 --ld-flag=-m32' to hsc2hs as a work around. While ticket #2965 is not yet fixed it would be better if hsc2hs understood the default arch on OS X 10.6 is not compatible with ghc. Sorry, I'm only on a 32bit Mac, but my (installed) hsc2hs (for ghc-6.12.2.20100521) file contains: HSC2HS_EXTRA=--cflag=-m32 --lflag=-m32 -I... Is this not sufficient for 64bit Macs, too? Cheers Christian ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac OS 10.6 unreliable?
Hi Christian, On 09.06.2010, at 10:30, Christian Maeder wrote: Chris Kuklewicz schrieb: hsc2hs: On OS 10.6 ghc is calling hsc2hs without any special -arch option, and hsc2hs is calculating offsets in x86_64 mode. This is breaking the interface between ghc and c-structures for various libraries. In particular I ran into this with gtk2hs. It may suffice to get '--cc-flag=-m32 --ld-flag=-m32' to hsc2hs as a work around. While ticket #2965 is not yet fixed it would be better if hsc2hs understood the default arch on OS X 10.6 is not compatible with ghc. Sorry, I'm only on a 32bit Mac, but my (installed) hsc2hs (for ghc-6.12.2.20100521) file contains: HSC2HS_EXTRA=--cflag=-m32 --lflag=-m32 -I... Is this not sufficient for 64bit Macs, too? I guess it would be enough, but obiously ghc or cabal should do this correctly themselves. What I would like to get out of this email thread is a set of rules that allows me to hack around this issue. So far: if os(darwin) arch(x86_64) impl(ghc =6.10 =6.12) cpp-options: -DHSC2HS_EXTRA=--cflag=-m32 --lflag=-m32 (although I'm not even sure the above works). Is the above rule correct and future-proof? Cheers, Axel ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs on Mac OS 10.6 unreliable?
That was in the official hsc2hc binary but was commented out in my macports hsc2hs. I have uncommented the line and rebuilt a working gtk2hs. Thanks! On 09/06/2010 09:30, Christian Maeder wrote: Chris Kuklewicz schrieb: hsc2hs: On OS 10.6 ghc is calling hsc2hs without any special -arch option, and hsc2hs is calculating offsets in x86_64 mode. This is breaking the interface between ghc and c-structures for various libraries. In particular I ran into this with gtk2hs. It may suffice to get '--cc-flag=-m32 --ld-flag=-m32' to hsc2hs as a work around. While ticket #2965 is not yet fixed it would be better if hsc2hs understood the default arch on OS X 10.6 is not compatible with ghc. Sorry, I'm only on a 32bit Mac, but my (installed) hsc2hs (for ghc-6.12.2.20100521) file contains: HSC2HS_EXTRA=--cflag=-m32 --lflag=-m32 -I... Is this not sufficient for 64bit Macs, too? Cheers Christian ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
hsc2hs on Mac OS 10.6 unreliable?
Hi all, we're facing serious problems (the seg'faulting kind) with Gtk2Hs on Mac OS 10.6. Chris has tracked this down to incorrect structure offsets that hsc2hs calculates. The offsets that hsc2hs calculates are too large, so it is probably in x86_64 mode. The offsets with which Gtk+ was compiled are smaller, so it must have been compiled with something like -arch i386. My question is the following: What is the right way to compile unixy software on Mac OS 10.6. Is the Gtk+ library incorrectly compiled or is hsc2hs not producing its C file in the correct way? It seems that a C Gtk+ program works correctly when compiled with no special flags. The only thing we could do is to pass some magic option to hsc2hs when it creates the C program that calculates the offsets. Detecting how Gtk + was compiled would require some sort of autoconf magic which is beyond a simple cabal file. So I probably cannot hope for an easy fix. Any comments or experience appreciated, cheers, Axel ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users