[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 François Dumont changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |fdumont at gcc dot gnu.org --- Comment #9 from François Dumont --- Fix with rev 242055 which simply remove format_word method.
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 --- Comment #8 from François Dumont --- Ok, at least it confirms what I thought about builtins. So the problem is rather a buggy target. Even if so I'll try to find an alternative approach to avoid snprintf usage.
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 --- Comment #7 from Jonathan Wakely --- (In reply to François Dumont from comment #6) > Created attachment 39984 [details] > Stop using __builtin_snprintf until __has_builtin is supported. > > Could you try this patch ? Until we have __has_builtin support I propose to > simulate __builtin_snprintf with __builtin_sprint. This patch is wrong in several ways. GCC always supports __builtin_snprintf, so even if we supported __has_builtin (which is "if" not "until") the test would not be right. What happens when it's not supported by the target is a linker error, not a missing builtin. The patch adds complexity and pessimizes targets that do support snprintf.
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 --- Comment #6 from François Dumont --- Created attachment 39984 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39984=edit Stop using __builtin_snprintf until __has_builtin is supported. Could you try this patch ? Until we have __has_builtin support I propose to simulate __builtin_snprintf with __builtin_sprint.
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 --- Comment #5 from Georg Koppen --- No, it is still broken after applying the patch to 6.2.0: ../src/c++11/.libs/libc++11convenience.a(debug.o): In function `format_word': /home/ubuntu/build/gcc/i686-w64-mingw32/libstdc++-v3/src/c++11/../../../../gcc-6.2.0/libstdc++-v3/src/c++11/debug.cc:536: undefined reference to `snprintf' /home/ubuntu/build/gcc/i686-w64-mingw32/libstdc++-v3/src/c++11/../../../../gcc-6.2.0/libstdc++-v3/src/c++11/debug.cc:536: undefined reference to `snprintf' /home/ubuntu/build/gcc/i686-w64-mingw32/libstdc++-v3/src/c++11/../../../../gcc-6.2.0/libstdc++-v3/src/c++11/debug.cc:536: undefined reference to `snprintf' collect2: error: ld returned 1 exit status
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 --- Comment #4 from Jonathan Wakely --- Does this help? --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -540,10 +540,25 @@ namespace using _Error_formatter = __gnu_debug::_Error_formatter; using _Parameter = __gnu_debug::_Error_formatter::_Parameter; +#ifdef _GLIBCXX_USE_C99_STDIO template int format_word(char* buf, int n, const char* fmt, _Tp s) { return std::min(__builtin_snprintf(buf, n, fmt, s), n - 1); } +#else +int +format_word(char* buf, int n, const char* fmt, const char* s) +{ + if ((int)__builtin_strlen(s) >= n) + s = "???"; + return std::min(__builtin_sprintf(buf, fmt, s), n - 1); +} + + template +int +format_word(char* buf, int n, const char* fmt, _Tp s) +{ return std::min(__builtin_sprintf(buf, fmt, s), n - 1); } +#endif void get_max_length(std::size_t& max_length)
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 --- Comment #3 from Georg Koppen --- (In reply to Jonathan Wakely from comment #2) > It's 2016, how can snprintf not be supported still? I asked about that problem in #mingw-w64 a while ago and got the following answer: M$ does not provide `snprintf()` despite their non-standard extension `_snprintf()`. With mingw-w64, if the macro `__USE_MINGW_ANSI_STDIO` is defined to `1`, `snprintf` is a macro that redirects calls to `snprintf` to `__mingw_snprintf` instead. Not sure if that helps debugging/fixing.
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 --- Comment #2 from Jonathan Wakely --- It's 2016, how can snprintf not be supported still?
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 Georg Koppen changed: What|Removed |Added CC||fdumont at gcc dot gnu.org --- Comment #1 from Georg Koppen --- FWIW: backing out r227885 (and r227888) "fixes" this problem for me.
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459 Andrew Pinski changed: What|Removed |Added Target Milestone|--- |6.3