Re: Year 2038 problem in GHC 6.4.2 runtime
Bulat, I am afraid I would need the new Time library a little earlier than 2038, because I am working on financial software where it is not uncommon to have contracts over 30 years long. Is the new Time library available for download? Regards, Cyril ___ Bulat Ziganshin wrote: there is new Time library, which is supposed to replace old System.Time. we hope that it will happen before 2038 :D ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Year 2038 problem in GHC 6.4.2 runtime
As far as I can see, the current (6.4.2) GHC runtime suffers the year 2038 problem; that is, the System.Time module does not support dates from 2038 onwards (the code below reproduces the problem). Is this bug scheduled to be fixed in the near future (my search in Trac yielded nothing) ? Regards, Cyril ___ The following code reproduces the problem with the Windows distribution of GHC 6.4.2: module Main where import System.Time main = putStrLn $ show $ toClockTime $ CalendarTime 2038 January 31 12 0 0 0 Sunday 0 GMT 0 False ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Linking error in GHC 6.4.2 snapshot of 21 April (mingw).
When I downloaded and unpacked the latest GHC snapshot of the STABLE branch for Windows (ghc-6.4.2.20060421-i386-unknown-mingw32.tar.gz), I got the following error trying to start GHCi: ___ ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.4.2, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \/\/ /_/\/|_| Type :? for help. Loading package base-1.0 ... linking ... : c:/ghc/GHC-64~1.2/HSbase1.o: unknown symbol `_sqrtf' : unable to load package `base-1.0' ___ The complaint about _sqrtf also shows up when I try to compile/link anything with ghc; so the problem is bigger than just not being able to use GHCi. The GHC is installed in c:\ghc\ghc-6.4.2, the PATH begins with c:\ghc\ghc-6.4.2;c:\ghc\ghc-6.4.2\bin;c:\ghc\ghc-6.4.2\gcc-lib; LIBRARY_PATH is set to c:\ghc\ghc-6.4.2\gcc-lib I know for sure that the 6.4.2 snapshot of a couple of weeks ago worked fine, so I wonder what might be wrong with the latest one. I would appreciate any hints. Cheers, Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Linking error in GHC 6.4.2 snapshot of 21 April (mingw).
This solves the problem, thanks! Cyril Simon Marlow wrote: Cyril Schmidt wrote: When I downloaded and unpacked the latest GHC snapshot of the STABLE branch for Windows (ghc-6.4.2.20060421-i386-unknown-mingw32.tar.gz), I got the following error trying to start GHCi: Loading package base-1.0 ... linking ... : c:/ghc/GHC-64~1.2/HSbase1.o: unknown symbol `_sqrtf' : unable to load package `base-1.0' Sigbjorn's candidate installer doesn't have this problem: http://www.haskell.org/ghc/dist/stable/dist/ghc-6-4-2-20060421.msi It's a bug in 6.4.2, sadly. Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: GHC 6.4.1 and Win32 DLLs: Bug in shutdownHaskell?
Michael, - How to generate an import library at all? Check this out: http://www.haskell.org/haskellwiki/GHC/FAQ#How_do_I_link_Haskell_with_C.2B.2B_code_compiled_by_Visual_Studio.3F - Assuming I have obtained an import library, how to use in the Microsoft world, i.e. how to bridge the gap from .a to .lib? See above. - Is Visual Studio 7 able to process the header files included from the stub header files generated by ghc? Visual Studio 6 has a lot of problems, e.g. it knows nothing about the type long long. I could not make Visual Studio 7 understand those, but I didn't try really hard. - Didn't you have problems with mangled names? Haskell would not understand mangled names. You have to declare the Haskell functions as extern C in the C++ code. This, of course, does not count for functions that are passed to/from Haskell via a function pointer. - What is the principal difference between using the import library and writing one on my own? Does the import library do anything else than loading the library and delegating the calls? I don't know :( Just one more piece of advice: if you can compile your C++ code with gcc, you probably can link it statically to the Haskell code, thus avoiding this DLL nightmare. Hope this helps. Cheers Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: GHC 6.4.1 and Win32 DLLs: Bug in shutdownHaskell?
Michael, Sorry, I might have had wrong assumptions about what you want to do. I presume you have a C++ application compiled via Visual Studio 6 that invokes a Haskell DLL. If that's correct, read on; if not, please tell me again what your setting is. To link your Haskell DLL with the C++ application: 1. Create a .def file for your DLL. Say, your Haskell library is HaskellLib.dll, so your .def file will be HaskelLib.def. Suppose the Haskell finction that you want to call from C++ is myHaskellFunc, then the .def file might look like LIBRARY HASKELLLIB EXPORTS myHaskellFunc 2. Create an import library using Visual Studio's lib.exe: lib /DEF:HaskellLib.def /OUT:HaskellLib.lib 3. Add HaskellLib.lib to your Visual Studio project and link. Cheers, Cyril Cyril, I know the Haskell Wiki page you pointed to; it does not answer my specific questions. The decision which compiler to use is not up to me and, as the Wiki page points out, there is no other way to use Haskell modules from within a Visual Studio C++ compiled application than via a DLL: The Windows distribution of GHC comes bundled with the GCC compiler, which is used as backend. That's why linking Haskell with Visual C++ is no different from linking GCC-generated code with the code generated by Visual C++. One cannot statically link together object files produced by those two compilers, but they can be linked dynamically: an executable produced by Visual C++ can invoke a DLL produced by GCC, and vice versa. Michael ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: GHC 6.4.1 and Win32 DLLs: Bug in shutdownHaskell?
Did you try to link the DLL statically (i.e. via import library) and remove the call to shutdownHaskell() ? It worked for me (I am using Visual Studio 7, though). Cheers, Cyril ___ I wrapped up some Haskell modules in a Win32 DLL. Loading the DLL dynamically (with LoadLibrary) works fine. However, whether I actually use the library or not, the program (an application with MFC GUI) crashes upon termination. To find the reason for the crash, I added a new function for unloading the DLL using FreeLibrary. FreeLibrary works fine, however the program crashes when it returns to the main event loop. Interestingly, when I reload the library (FreeLibrary followed by LoadLibrary) the program continues working. However, every reload cycle causes the virtual size of the process to increase by about 300K and the fourth reload fails with the error message getMBlock: VirtualAlloc failed with: 8 (appears in a message window) accompanied by many repetitions of the message Timer proc: wait failed -- error code: 6 (appears on stderr) and followed by the message getMBlocks: misaligned block returned (again in a message window). Then the programm crashes. Development takes place on Windows XP Professional using MS Visual Studio 6.0 SP 5 and ghc 6.4.1. There are no references from the C++ side to the Haskell heap. I build the DLL using the command ghc --mk-dll -optdll--def -optdllFoo.def -o Foo.dll Foo.o Foo_stub.o dllMain.c dllMain.c looks as follows: #include windows.h #include Rts.h extern void __stginit_EUzu3820zu85(void); static char* args[] = { ghcDll, NULL }; /* N.B. argv arrays must end with NULL */ BOOL STDCALL DllMain(HANDLE hModule, DWORD reason, void* reserved) { if (reason == DLL_PROCESS_ATTACH) { /* By now, the RTS DLL should have been hoisted in, but we need to start it up. */ startupHaskell(1, args, __stginit_Foo); return TRUE; } else if (reason == DLL_PROCESS_DETACH) { shutdownHaskell(); } return TRUE; } I played around with hs_exit instead of shutdownHaskell, I moved initialization and clean-up from DllMain to my library loader, nothing helps. Even doing no clean-up whatsoever does not change the behaviour. Any ideas? Michael -- Message: 2 Date: Wed, 01 Mar 2006 12:06:27 -0800 From: Ashley Yakeley [EMAIL PROTECTED] Subject: Re: Missing Folder in ghc? To: glasgow-haskell-users@haskell.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed Simon Marlow wrote: The configure script has mis-detected your GHC version somehow. Could you look through the output of configure, and see what it says about GHC? Nothing special: checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu Canonicalised to: i386-unknown-linux checking for path to top of build tree... /home/ashley/Projects/Collected/Haskell/ghc checking for ghc... /usr/bin/ghc checking version of ghc... 6.4 checking for nhc... no checking for nhc98... no checking for hbc... no Also look in mk/config.mk, at the value of GhcCanonVersion. GHC = /usr/bin/ghc GhcDir = $(dir $(GHC)) GhcVersion = 6.4 GhcMajVersion = 6 GhcMinVersion = 4 GhcPatchLevel = 0 # Canonicalised ghc version number, used for easy (integer) version # comparisons. We must expand $(GhcMinVersion) to two digits by # adding a leading zero if necessary: ifneq $(findstring $(GhcMinVersion), 0 1 2 3 4 5 6 7 8 9) GhcCanonVersion = $(GhcMajVersion)0$(GhcMinVersion) else GhcCanonVersion = $(GhcMajVersion)$(GhcMinVersion) endif Maybe you switched GHC versions but didn't reconfigure? I think the problem is that I called autoconf etc. before I called darcs-all get, but not after. Calling autoreconf fixed the problem. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: GHC 6.4.1 crash on Windows XP
Can you tell which process is crashing? Is it the GHC process that is interpreting Setup.hs, or the process invoked by Setup.hs to build the package? I suspect it is the GHC process that is invoked by Setup.hs, but I do not have any hard evidence to support this. One thing you could try is compiling Setup.hs to a binary, and running that instead. That worked! I think this counts as evidence for the above. Also, if you could run Setup like this and send us the output: $ ./setup build -v (or the runhaskell version, if that's the only one that crashes) I did it via runhaskell: runhaskell Setup.hs build -v Preprocessing library Vasicek-0.3... Building Vasicek-0.3... This is all what it said before the crash... Just about 15 minutes ago I fixed the problem (at least I hope I did) by installing the snapshot of GHC 6.4.2 of February 27 (BTW, the cc1.exe is missing from the tar file). I also found at least one difference between the PC where the problem showed up and the one where it did not. Both PCs had Cygwin installed. On the PC where the problem did not show up, the Cygwin executables shadowed the Windows programs with the same name: e.g. if I type 'find' in Windows command prompt, I get the UNIX find. On the PC where the problem did show up, it was the other way: I get the Windows find (of course, from the bash shell I always get the UNIX find). I do not know, though, if this is linked in any way to the GHC problem. I spent some time playing with PATH to try to make the two PCs behave the same, but I could not (I do not have Admin priviledges). The GHC was always started from the Windows prompt, never from bash. Anyway, as the problem is solved by moving from 6.4.1 to 6.4.2, we can conclude that it was caused by one of the bugs fixed after 6.4.1, and close the issue for now. If you, however, would like to continue investigation, please let me know -- I can easily reproduce the problem, and I'll be happy to get any extra information for you (once I know how to get it). I will keep version 6.4.1 for the time being. Thank you very much for the help. Cheers, Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
GHC 6.4.1 crash on Windows XP
A freshly installed GHC 6.4.1 on my colleague's PC crashes when I try to build a package: runhaskell Setup.hs build The effect is easily reproduceable (it shows up on *any* package that I try to build). Does anyone have any idea of what might be wrong here? Cyril ___ For the record, the information given by Windows at the point of crash: Exception Information Code: 0xc005Flags: 0x0 Record: 0x0 Address: 0x0 System Information Windows NT 5.1 Build: 2600 Module 1 ghc.exe Image Base: 0x0040 Image Size: 0x0 Checksum: 0x0088d2bdTime Stamp: 0x433058b8 (The IP and SP already point somewhere inside Dr. Watson, as far as I can see, so I don't think the registers and stack contents are of any use at this point.) ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Passing a matrix from C to Haskell
Simon Marlow wrote: Bulat Ziganshin wrote: [...] i think we should define secret door to construct StorableArray from a pointer to allow to use full power of MArray interface on foreign arrays You mean this? -- |Construct a 'StorableArray' from an arbitrary 'ForeignPtr'. It is -- the caller's responsibility to ensure that the 'ForeignPtr' points to -- an area of memory sufficient for the specified bounds. unsafeForeignPtrToStorableArray :: ForeignPtr e - (i,i) - IO (StorableArray i e) It looks like this function is not available in GHC 6.4.1 (see http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Data-Array-Storable.html ) It is, however, documented at http://www.haskell.org/HOpenGL/newAPI/base/Foreign-Storable.html but I don't know which version of GHC it applies to. Cheers, Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Passing a matrix from C to Haskell
Chris Kuklewicz wrote: Cyril Schmidt wrote: I need to pass a big 2-dimensional array of doubles from a legacy C code to a Haskell module. Of this huge array, the Haskell code will actually use only a few elements (say, 10 out of 100x20 matrix). Unfortunately, the C code does not know which data are actually needed in the Haskell module. You probably want Foreign.Marshal.Array http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Foreign-Marshal-Array.html peekArray :: Storable a = Int - Ptr a - IO [a] This works, but peekArray is very slow. Cheers Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Passing a matrix from C to Haskell
It is, however, documented at http://www.haskell.org/HOpenGL/newAPI/base/Foreign-Storable.html but I don't know which version of GHC it applies to. Sorry, I meant at http://www.haskell.org/HOpenGL/newAPI/base/Data-Array-Storable.html Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Passing a matrix from C to Haskell
I need to pass a big 2-dimensional array of doubles from a legacy C code to a Haskell module. Of this huge array, the Haskell code will actually use only a few elements (say, 10 out of 100x20 matrix). Unfortunately, the C code does not know which data are actually needed in the Haskell module. What would be a good way to pass the array to Haskell and, once the data are handed over, what is the fastest way to fetch these elements? I was thinking of something like passing the array as Ptr Int#, but how do I fetch the elements that I am interested in? Cheers, Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Linking with C++ produced by Visual Studio .NET on Windows XP?
I added this to the FAQ list; please feel free to elaborate and correct. Linking to Visual Studio-generated code would be much easier if GHC were able to use Visual C++ as backend, instead of gcc (even Visual Haskell at the moment relies on gcc for C compilation). I have no idea, though, how much work it would be to make GHC able to compile via Visual C++. Cheers, Cyril ___ Simon Peyton-Jones wrote: GHC now makes it easy for all users to contribute new documentation about GHC to help other users, by adding to the GHC documentation wiki. See the Collaborative documentation heading on http://haskell.org/haskellwiki/GHC:Documentation Linking to C++ would be an ideal topic. It's a regular question, and not one of our strengths at GHC HQ! ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Linking with C++ produced by Visual Studio .NET on Windows XP?
Brian Hulley wrote: Thanks. The only problem is that dlltool doesn't work because I don't have cygwin installed. dlltool usually comes with the Windows distribution of GHC (at least GHC 6.4 and 6.4.1 have it; check gcc-lib directory). Cheers Cyril ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Linking with C++ produced by Visual Studio .NET on Windows XP?
I am far from being an expert, but I have seen no answer to your question so far, so I'll tell how I'd do it (however ugly that might be). I don't have a sample project, but it should be fairly easy to make it. 1. Make a DLL project in Visual Studio. VS will create a .vcproj and .sln files for you. Add your C++ source files to this project. 2. Create a .def file for your DLL. It might look like LIBRARY MyDLL EXPORTS function1 function2 where function1 and function2 are the names of the C++ functions that you want to invoke from Haskell (there can be more of them, of course), MyDLL is the name of your DLL. 3. Create an import library that can be used by ghc: dlltool -d MyDLL.def -l libMyDLL.a where MyDLL.def is the name of the .def file, libMyDLL.a is the import library. 4. Link your Haskell project, adding the library: ghc --make main.hs -optl-lMyDLL -optl-L. (-optl switch passes its argument as an option to the linker). Hope this helps. Cheers, Cyril ___ Hi - I'm wondering if anyone has a simple Visual Studio .NET C++ project that would demonstrate how to link C++ with Haskell (or vice versa). Ie a .sln, .vcproj, .cpp, and .h file containing one C++ function and a Haskell file main.hs that calls this function, so that if I click on the .sln file and hit F6 the VS project will build then on the command line if I type ghc --make main.hs the Haskell program will be built so that when I type main on the command line it will run and call the C++ function. Sorry if this all sounds too basic but I don't know how to compile C++ from the command line at all or how to use make files, and I need to use the Visual Studio compiler because my own C++ code relies on Microsoft extensions... Thanks, Brian. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users