[PATCH] configure: Enable MinGW-w64's implementation of vsnprintf and pals
As of r5799 in MinGW-w64's trunk, which is he upcoming major version 3, the POSIX-compliant vsnprintf implementation is disabled by default. Enable it for this version. Keep using out own implementation for prior versions, because it is broken in them. Relevant Reference Thread: http://article.gmane.org/gmane.comp.gnu.mingw.w64.general/7133 Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index e5f47b0..7be050a 100755 --- a/configure +++ b/configure @@ -3514,6 +3514,8 @@ elif check_header _mingw.h; then __MINGW64_VERSION_MAJOR < 3"; then add_compat msvcrt/snprintf.o add_cflags "-include $source_path/compat/msvcrt/snprintf.h" + elif + add_cppflags -D__USE_MINGW_ANSI_STDIO=1 fi elif check_func_headers stdlib.h _get_doserrno; then libc_type=msvcrt -- 1.7.10.4
On 2013-04-20 5:54 PM, Derek Buitenhuis wrote:
+ elif + add_cppflags -D__USE_MINGW_ANSI_STDIO=1
Shit, this should be an else statement. You get the idea tho. Review and comments welcome. - Derek
On Sat, Apr 20, 2013 at 05:57:49PM -0400, Derek Buitenhuis wrote:
On 2013-04-20 5:54 PM, Derek Buitenhuis wrote:
+ elif + add_cppflags -D__USE_MINGW_ANSI_STDIO=1
Shit, this should be an else statement.
You get the idea tho. Review and comments welcome.
if thats what is needed for mingw w64 3 (iam no user of it so i dont know) then patch should be fine [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
On 2013-04-21 7:38 PM, Michael Niedermayer wrote:
if thats what is needed for mingw w64 3 (iam no user of it so i dont know) then patch should be fine
Will double check the testing and push tomorrow. - Derek
On Sat, Apr 20, 2013 at 05:54:51PM -0400, Derek Buitenhuis wrote:
As of r5799 in MinGW-w64's trunk, which is he upcoming major version 3, the POSIX-compliant vsnprintf implementation is disabled by default. Enable it for this version. Keep using out own implementation for prior versions, because it is broken in them.
Is it worth it? I mean, for consistency wouldn't it make kind of more sense if we have all Windows builds use the same code, namely our own implementation? It seems to me like this will just add variation that makes debugging harder without any gains?
On 2013-04-24 12:45 PM, Reimar Döffinger wrote:
Is it worth it? I mean, for consistency wouldn't it make kind of more sense if we have all Windows builds use the same code, namely our own implementation? It seems to me like this will just add variation that makes debugging harder without any gains?
Our implementation relies on _vsnprintf at its core, which doesn't support things like %zu (we use it in a few logs). MinGW's does support this. Anyway, I haven't pushed this because there is ongoing discussing over at MinGW-w64, and they may change how this is handled /again/. - Derek
On 2013-04-24 1:58 PM, Derek Buitenhuis wrote:
Our implementation relies on _vsnprintf at its core, which doesn't support things like %zu (we use it in a few logs). MinGW's does support this.
Anyway, I haven't pushed this because there is ongoing discussing over at MinGW-w64, and they may change how this is handled /again/.
It seems they'll stick with this, so I will push this tomorrow if there are no objections. - Derek
On Wed, Apr 24, 2013 at 01:58:15PM -0400, Derek Buitenhuis wrote:
On 2013-04-24 12:45 PM, Reimar Döffinger wrote:
Is it worth it? I mean, for consistency wouldn't it make kind of more sense if we have all Windows builds use the same code, namely our own implementation? It seems to me like this will just add variation that makes debugging harder without any gains?
Our implementation relies on _vsnprintf at its core, which doesn't support things like %zu (we use it in a few logs). MinGW's does support this.
Isn't that make my point all the stronger and an extra good reason to _not_ use two implementations? If anything this would be an argument to use a wrapper even on Linux/Unix to make sure we do not use %zu by accident, since it's not going to work on some systems after all.
On 2013-05-17 2:14 AM, Reimar Döffinger wrote:
Isn't that make my point all the stronger and an extra good reason to _not_ use two implementations? If anything this would be an argument to use a wrapper even on Linux/Unix to make sure we do not use %zu by accident, since it's not going to work on some systems after all.
We do use %zu, and (certain) people seem dead set against removing its use, since it is the "most correct" thing to use for size_t prints. As it stands MSVC and old MinGW are the only platforms which do not have a proper vsnprintf implementation. Also, our implementation is very Windows-specific -- it won't work on anything else, and it's silly to use it anywhere else. Thirdly, the usual "system implementations are likely more optimzied" argument. IMHO, the "most correct" thing to do is only provide it for platforms that need it. You don't see us providing llrint() on platforms that have it, do you? - Derek
Derek Buitenhuis <derek.buitenhuis@gmail.com> wrote:
On 2013-05-17 2:14 AM, Reimar Döffinger wrote:
Isn't that make my point all the stronger and an extra good reason to _not_ use two implementations? If anything this would be an argument to use a wrapper even on Linux/Unix to make sure we do not use %zu by accident, since it's not going to work on some systems after all.
We do use %zu, and (certain) people seem dead set against removing its use, since it is the "most correct" thing to use for size_t prints.
Is that still the case? Because I find it very hard to argue that broken code would be "most correct". In addition using some macro would still allow using zu on Linux.
As it stands MSVC and old MinGW are the only platforms which do not have a proper vsnprintf implementation. Also, our implementation is very Windows-specific -- it won't work on anything else, and it's silly to use it anywhere else. Thirdly, the usual "system implementations are likely more optimzied" argument.
I very much hope performance isn't relevant, otherwise using printf is a mistake in the first place.
IMHO, the "most correct" thing to do is only provide it for platforms that need it. You don't see us providing llrint() on platforms that have it, do you?
I know of no issues where the platform or our re-implementation requires special care in how we use it. It just seems to me that special-casing newer mingw is additional effort that at best hides bugs in our code that still will affect some users. And how easy will it be to find out which printf variant was used by the ffmpeg some user used in a bug report? I admit I argued far longer than I care about it (and Windows in general), but my gut tells me it's a rather bad idea.
On 2013-05-24 3:37 AM, Reimar Döffinger wrote:
We do use %zu, and (certain) people seem dead set against removing its use, since it is the "most correct" thing to use for size_t prints.
Is that still the case? Because I find it very hard to argue that broken code would be "most correct". In addition using some macro would still allow using zu on Linux.
It is the case. It's arguable since %zu (and %Iu with MSVC) is the correct way to print a variable of type size_t in C99, according to the spec. Both host tools, and target code use %zu currently. (It doesn't help that we have no real host feature detection system.) This patch is semi-related, but never pushed (due to Libav folks wanting to write a real host feature detection system): http://ffmpeg.org/pipermail/ffmpeg-devel/2013-January/137460.html
As it stands MSVC and old MinGW are the only platforms which do not have a proper vsnprintf implementation. Also, our implementation is very Windows-specific -- it won't work on anything else, and it's silly to use it anywhere else. Thirdly, the usual "system implementations are likely more optimzied" argument.
I very much hope performance isn't relevant, otherwise using printf is a mistake in the first place.
Yeah I know. That's why I put it in quotes.
IMHO, the "most correct" thing to do is only provide it for platforms that need it. You don't see us providing llrint() on platforms that have it, do you?
I know of no issues where the platform or our re-implementation requires special care in how we use it.
This may or may not be due to the very strong flaming that went along with adding MSVC compatibility. ("Don't you DARE ruin our lovely codebase for the sake of MSVC!" -- Double Standards)
It just seems to me that special-casing newer mingw is additional effort that at best hides bugs in our code that still will affect some users.
What "bugs"? Using C99 is a bug now? Also, it will only affect people using a certain range of MinGW-w64 SVN trunk. No actual release is affected. I don't consider this an issue.
And how easy will it be to find out which printf variant was used by the ffmpeg some user used in a bug report?
As easy as "please attach your config.log".
I admit I argued far longer than I care about it (and Windows in general), but my gut tells me it's a rather bad idea.
I wouldn't call it arguing, as much as healthy debate. :) - Derek
On 24.05.2013, at 22:45, Derek Buitenhuis <derek.buitenhuis@gmail.com> wrote:
On 2013-05-24 3:37 AM, Reimar Döffinger wrote:
It just seems to me that special-casing newer mingw is additional effort that at best hides bugs in our code that still will affect some users.
What "bugs"? Using C99 is a bug now?
"Bug" is anything that makes the code not work as intended or desired (on a supported system one could add for clarity). That does mean that using C99 can be a bug, yes.
Also, it will only affect people using a certain range of MinGW-w64 SVN trunk. No actual release is affected. I don't consider this an issue.
I don't think everyone uses -w64 yet? What about MSVC? Or am I missing the point (I should probably have re-read the patch before answering).
And how easy will it be to find out which printf variant was used by the ffmpeg some user used in a bug report?
As easy as "please attach your config.log".
Wishful thinking I believe :-) You'd be lucky if they compiled themselves.
I admit I argued far longer than I care about it (and Windows in general), but my gut tells me it's a rather bad idea.
I wouldn't call it arguing, as much as healthy debate. :)
I didn't mean "argue" as a negative word, but I certainly wouldn't want to be at fault for dragging this out to a point where it wouldn't count as "healthy debate" anymore, that wouldn't be a good deal.
On 2013-05-24 6:30 PM, Reimar Döffinger wrote:
What "bugs"? Using C99 is a bug now?
"Bug" is anything that makes the code not work as intended or desired (on a supported system one could add for clarity). That does mean that using C99 can be a bug, yes.
I think a macro would better handle it than not using %zu, but that is out of the scope of this patch.
Also, it will only affect people using a certain range of MinGW-w64 SVN trunk. No actual release is affected. I don't consider this an issue.
I don't think everyone uses -w64 yet? What about MSVC? Or am I missing the point (I should probably have re-read the patch before answering).
This patch is only relevant to future MinGW-w64 releases, which have a working vsnprintf, etc. implementation. Regular MinGW, MSVC, and MinGW-w64 version 2 and earlier, will continue to work the same, and correctly.
As easy as "please attach your config.log".
Wishful thinking I believe :-) You'd be lucky if they compiled themselves.
Perhaps we could add the MinGW runtime version to the "compiler version" output under the 'ffmpeg -version' output? That would in a lot more cases than this.
I wouldn't call it arguing, as much as healthy debate. :)
I didn't mean "argue" as a negative word, but I certainly wouldn't want to be at fault for dragging this out to a point where it wouldn't count as "healthy debate" anymore, that wouldn't be a good deal.
"Bikeshedding" ? ;) - Derek
participants (3)
-
Derek Buitenhuis -
Michael Niedermayer -
Reimar Döffinger