-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Win32 build #118
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
Win32 build #118
Conversation
This uses the gcc versions of gmtime_s and localtime_s instead of the MS versions when __GNUC__ is defined.
Still failing for me. I can't open the ticket at the moment, but I think it fails at a later point with a similar error. So your fix may be correct but it may have to be applied in more places:
|
Hmmm, that's a big strike against the idea of using mingw... It supports neither MSVC's gmtime_s nor gcc's gmtime_r, only allowing for the ancient non-threadsafe gmtime. Is it necessary to support mingw? This is rather bad. |
According to http://gcc.gnu.org/ml/fortran/2009-05/msg00348.html it should be threadsafe for MinGW. And yes, we do need to support it. It's still the default open source solution on Windows. We build our Windows binaries with it. |
There's a patch which should hopefully work on mingw, let me know what it does. |
Next problem:
Full build log attached on #1909 |
Those warnings suggest that -fno-strict-aliasing should be added to the compiler flags. Python 3+ allows for the removal of that compiler option, but I don't think that has been rigorously checked with NumPy. |
These functions allegedly use thread-local storage on mingw, so hopefully it's ok.
I've updated the patch to fix the error that was in the logfile. |
Builds fine, that's progress. Not sure what to do about the MinGW issues though (see #1909). |
That's ugly, it would be better to use the gmtime_s variant like in the original patch, since it is in msvcr90.dll. I'll give you a patch with an attempted hack. - on second thought, the error was happening at link-time, so would probably have to use whatever localtime_s and gmtime_s translate to at the binary level, like _localtime32_s or _localtime64_s. |
There's a new commit for you to try. |
Looks like we're back to the original problem:
|
Can you use some dumping tools to symbol dump msvcr90.dll or msvcr90.lib and find what the actual exported symbols are for the localtime and gmtime functions? |
Full dump attached to #1909.
|
That seems to indicate that I got the signature right. In your latest build error, there is: multiarraymodule_onefile.c:(.text+0x7b1d): undefined reference to `_localtime64_s' which is in the objdump output. One thing which is sometimes tricky is that C adds an '_' at the beginning of normal functions, however objdump appears to be stripping that as can be seen starting from symbol [1205] abort. Maybe the .lib file being used to describe the symbols in msvcr90.dll is the the default mingw uses, which doesn't have these symbols? In that case, perhaps that .lib file could be regenerated specifically for msvcr90.dll to include these symbols? |
That's what I understood to be the problem from http://bugs.python.org/issue3308, and regenerating the .lib file worked for one user: http://article.gmane.org/gmane.comp.gnu.mingw.user/27013. This is not a nice fix though, it may work for me but we can hardly tell all MinGW users to do this. It is possible that this is fixed in a later gcc version, I see 4.5.2 is available on SF. If that works, also with g77 for scipy, perhaps we should just clearly state that the default gcc that comes with MinGW (3.4.5) is too old and won't work for numpy >1.6. |
I'm unable to think of a better option than using a .lib file which matches the linked version of msvcr. The datetime stuff needs these functions to work properly with local times. |
I'll try to test gcc 4.5.2, but that not going to be before Sunday. If that works without problems I'd be okay switching to that. Otherwise a .lib file would be okay, we could just put it under tools/ somewhere. |
"... a .lib file would be okay..." IIRC, I once had to do that to get mingw working. I don't think it is a bad solution to a bad situation as long as keeping the .lib file current doesn't become a hassle. |
What is the status of this? |
I haven't tried with gcc 4.5 yet - will try to make time for that soon. |
MinGW is missing the declarations for |
Ahh, that was only half the story -- sorry! If MinGW doesn't find the correct entries in msvcr90.dll, I don't know.. |
I believe this is because mingw includes a .lib version based on visual c++ 6.0. It looks like what is needed is an updated .lib file generated from msvcr90.dll. |
Do you happen to know if that's still the case for gcc 4.5.2 in MinGW? If not, I'll finally make time for testing that. |
I'll have to check it at work.. I downloaded its latest MinGW version from sourceforge[1], but I didn't check the actual compiler version. [1] http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/ |
Yes, I checked, the compiler version is 4.5.2. |
Good news! Creating a customized To make it work in my specific case, I had to add to
And hacked the original
(See this Gist for the source(s): https://gist.github.com/1167840#file_msvcrt90.def , I basically stripped the original The resulting file can be placed in |
The method is not very portable, though, you have to do a lot of extra steps as user to make it work, and I haven't looked at the debug versions, the other compiler versions, or the header file. It would be nicest if MinGW supported these functions out of the box, but http://old.nabble.com/Need-localtime_s-td13087586.html seems to indicate they wont.. |
In the patch 0ed2d56 above, I put code in for calling _localtime64_s (which should be available on both 32-bit and 64-bit platforms). Can you try it with that instead of the 32-bit one, since it's prefereable to always use the 64-bit time_t? |
I can try the above patch to see if it works, but it seems a bit complicated? I think, if one has access to the time.h definitions and the .a files needed to link with msvcrt[x].dll, it should work. The time.h definitions could be included in the source directly if necessary, you need the time struct and timestamp types. Only, not every version of visual c has the *_s definitions I believe. I'll put in _localtime64_s and see how it goes. |
Works on WinXP 32 (with VC9 dll and modified mingw lib). |
I was thinking, would it be an idea to make one inlined function to handle all the different cases? There is a distinction between:
|
Sounds like a good idea to me. I think the MinGW one should be fixed up to always use localtime_s, especially since that's what the official Windows binaries are made with. |
Is there a way to detect at runtime if a certain dll-function can be found? That would make it easier for the different MinGW paths. Also, should non-threadsafe function calls be wrapped with the GIL? |
Ok, I made a pull request which should fix these issues. Would you want to take a look at it? I tested it against Python 2.6, the Python 2.5 build crashed for MinGW on an unrelated issue. I am not completely sure on the thread-safety of the fallback mechanism, which uses the plain |
Han's pull request works for me now (at least on py2.6, will test some more). I haven't tried that in combination with the commits in this pull request, but they look unrelated. |
This can be tested again as soon as Han's pull request goes in. |
I think the commits here are not necessary anymore.. |
Should I close the pull request then? |
Closing. If needed the fixes can be submitted again. |
feat: Add vclz_s8
Commit from Christoph Gohlke, and fix for http://projects.scipy.org/numpy/ticket/1909.
I don't have easy access to a win32 build machine at the moment, so this needs testing before it goes in.