Skip to content
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

--with-default-msvcrt=ucrt breaks libgomp build #520

Closed
Prince213 opened this issue Aug 12, 2020 · 21 comments
Closed

--with-default-msvcrt=ucrt breaks libgomp build #520

Prince213 opened this issue Aug 12, 2020 · 21 comments

Comments

@Prince213
Copy link
Contributor

Command: ./build --mode=gcc-10.2.0 --buildroot=/e/mingw1020 --no-multilib --no-extras --jobs=6 --rt-version=v7.0.0 --with-default-msvcrt=ucrt --enable-languages=c,c++ --threads=posix --exceptions=seh --arch=x86_64 --bin-compress
Log:

../../../../../src/gcc-10.2.0/libgomp/env.c: In function 'handle_omp_display_env':
../../../../../src/gcc-10.2.0/libgomp/env.c:1285:24: error: unknown conversion type character 'l' in format [-Werror=format=]
 1285 |       fprintf (stderr, "  GOMP_SPINCOUNT = '%"PRIu64"'\n",
      |                        ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../../../../src/gcc-10.2.0/libgomp/env.c:40:
E:/mingw1020/x86_64-1020-posix-seh-rt_v700/mingw64/mingw/include/inttypes.h:36:18: note: format string is defined here
   36 | #define PRIu64 "llu"
      |                  ^
../../../../../src/gcc-10.2.0/libgomp/env.c:1285:24: error: too many arguments for format [-Werror=format-extra-args]
 1285 |       fprintf (stderr, "  GOMP_SPINCOUNT = '%"PRIu64"'\n",
      |                        ^~~~~~~~~~~~~~~~~~~~~~~
@niXman
Copy link
Owner

niXman commented Aug 12, 2020

@Prince213
Copy link
Contributor Author

Well, I think the problem is caused by _UCRT...

@Prince213
Copy link
Contributor Author

/* 7.8.1 Macros for format specifiers
 * 
 * MS runtime does not yet understand C9x standard "ll"
 * length specifier. It appears to treat "ll" as "l".
 * The non-standard I64 length specifier causes warning in GCC,
 * but understood by MS runtime functions.
 */
#if defined(_UCRT) || __USE_MINGW_ANSI_STDIO
#define PRId64 "lld"
#define PRIi64 "lli"
#define PRIo64 "llo"
#define PRIu64 "llu"
#define PRIx64 "llx"
#define PRIX64 "llX"
#else
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#endif

@niXman
Copy link
Owner

niXman commented Aug 12, 2020

I think it should be #if defined(_UCRT) && !defined(__USE_MINGW_ANSI_STDIO), right?

@Prince213
Copy link
Contributor Author

IDK :( . the second answer to the Stack Overflow question says:

If you must use %llu, define __USE_MINGW_ANSI_STDIO macro before including stdio.h. Be aware that if you do this, MS type %I64* format will no longer work.

@niXman
Copy link
Owner

niXman commented Aug 12, 2020

ah right

@niXman
Copy link
Owner

niXman commented Sep 19, 2020

@Biswa96
Copy link

Biswa96 commented Sep 22, 2020

Try with this patch https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gcc/0020-libgomp-Don-t-hard-code-MS-printf-attributes.patch

@niXman niXman mentioned this issue Nov 9, 2020
@Prince213
Copy link
Contributor Author

Errors related to env.c now disappears, but new ones come:

In file included from ../../../../../src/gcc-10.2.0/libgomp/config/mingw32/affinity-fmt.c:68:
E:/mingw1020/src/gcc-10.2.0/libgomp/affinity-fmt.c: In function 'gomp_display_affinity':
E:/mingw1020/src/gcc-10.2.0/libgomp/affinity-fmt.c:388:22: error: unknown conversion type character 'l' in format [-Werror=format=]
  388 |        sprintf (buf, "0x%" PRIx64, (uint64_t) gomp_integral (handle));
      |                      ^~~~~
In file included from ../../../../../src/gcc-10.2.0/libgomp/config/mingw32/affinity-fmt.c:34:
E:/mingw1020/x86_64-1020-posix-seh-rt_v800/mingw64/mingw/include/inttypes.h:37:18: note: format string is defined here
   37 | #define PRIx64 "llx"
      |                  ^
In file included from ../../../../../src/gcc-10.2.0/libgomp/config/mingw32/affinity-fmt.c:68:
E:/mingw1020/src/gcc-10.2.0/libgomp/affinity-fmt.c:388:22: error: too many arguments for format [-Werror=format-extra-args]
  388 |        sprintf (buf, "0x%" PRIx64, (uint64_t) gomp_integral (handle));
      |                      ^~~~~

@lurobi
Copy link
Contributor

lurobi commented Feb 8, 2021

Just some extra information: I think I ran into a related issue. I got: unknown conversion type character 'l' in format" in gomp_fatal

My build was: ./build --no-extras --mode=gcc-9.3.0 --arch=x86_64 --exceptions=seh --buildroot=.... (From mingw-builds:master) and it would not complete until I applied the patch noted by @Biswa96

@niXman
Copy link
Owner

niXman commented Feb 8, 2021

@lurobi please try develop branch

@niXman
Copy link
Owner

niXman commented Feb 8, 2021

@Prince213 any ideas?

@Prince213
Copy link
Contributor Author

@lurobi @niXman 7de159b should fix it, which is already on develop.

@niXman
Copy link
Owner

niXman commented Feb 11, 2021

@Prince213 thank you!

@lurobi can you confirm please?

@lurobi
Copy link
Contributor

lurobi commented Feb 12, 2021 via email

@Prince213
Copy link
Contributor Author

@lurobi Please try with --with-default-msvcrt=ucrt as this problem is probably related to UCRT.

@lurobi
Copy link
Contributor

lurobi commented Feb 12, 2021

I am unable to compile gcc using --with-default-msvcrt=ucrt on develop on windows through MSYS2. I am using a1c154f plus my fix for the binutils heredoc.

Command: ./build --mode=gcc-10.2.0 --buildroot=/home/luker/mingw1020 --no-multilib --no-extras --jobs=6 --rt-version=v7.0.0 --with-default-msvcrt=ucrt --enable-languages=c,c++,fortran --threads=posix --exceptions=seh --arch=x86_64 --bin-compress

../../../../../src/gcc-10.2.0/libgomp/env.c: In function 'handle_omp_display_env':
../../../../../src/gcc-10.2.0/libgomp/env.c:1285:24: error: unknown conversion type character 'l' in format [-Werror=format=]
 1285 |       fprintf (stderr, "  GOMP_SPINCOUNT = '%"PRIu64"'\n",
      |                        ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../../../../src/gcc-10.2.0/libgomp/env.c:40:
C:/msys64/home/luker/mingw1020/x86_64-1020-posix-seh-rt_v700/mingw64/mingw/include/inttypes.h:36:18: note: format string is defined here
   36 | #define PRIu64 "llu"
      |                  ^
../../../../../src/gcc-10.2.0/libgomp/env.c:1285:24: error: too many arguments for format [-Werror=format-extra-args]
 1285 |       fprintf (stderr, "  GOMP_SPINCOUNT = '%"PRIu64"'\n",
      |                        ^~~~~~~~~~~~~~~~~~~~~~~

@Biswa96
Copy link

Biswa96 commented Mar 31, 2021

To disable -Werror for UCRT GCC build, some workaround are added in this commit msys2/MINGW-packages@5d82e17

@lazka
Copy link

lazka commented Apr 8, 2021

Here is the upstream fix: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c51f1e7427e6a5ae2a6d82b5a790df77a3adc99a

@sfan5
Copy link

sfan5 commented Apr 13, 2021

Seeing the same errors with gcc 10.3.0 and UCRT:

In file included from /home/build/mingw-w64-gcc/gcc/libgomp/config/mingw32/affinity-fmt.c:68:
/home/build/mingw-w64-gcc/gcc/libgomp/config/mingw32/../../affinity-fmt.c: In function 'gomp_display_affinity':
/home/build/mingw-w64-gcc/gcc/libgomp/config/mingw32/../../affinity-fmt.c:388:22: error: unknown conversion type character 'l' in format [-Werror=format=]
  388 |        sprintf (buf, "0x%" PRIx64, (uint64_t) gomp_integral (handle));
      |                      ^~~~~
In file included from /home/build/mingw-w64-gcc/gcc/libgomp/config/mingw32/affinity-fmt.c:34:
/usr/i686-w64-mingw32/include/inttypes.h:37:18: note: format string is defined here
   37 | #define PRIx64 "llx"
      |                  ^
In file included from /home/build/mingw-w64-gcc/gcc/libgomp/config/mingw32/affinity-fmt.c:68:
/home/build/mingw-w64-gcc/gcc/libgomp/config/mingw32/../../affinity-fmt.c:388:22: error: too many arguments for format [-Werror=format-extra-args]
  388 |        sprintf (buf, "0x%" PRIx64, (uint64_t) gomp_integral (handle));
      |                      ^~~~~

Looking at gcc-10.3.0/gcc/config/i386/msformat-c.c I don't see the changes that should be there.
So it seems that the fix hasn't made it into gcc 10.3. Anyone know why?

@jrmoore
Copy link

jrmoore commented Jul 27, 2021

Seeing the same error over here when not using --static-gcc trying to build with the following command line:

./build --jobs=1 --mode=gcc-9.4.0 --rt-version=v8.0.0 --with-default-msvcrt=ucrt --arch=x86_64 --buildroot=/builds \
--exceptions=seh --threads=win32 --enable-languages=c,c++ --no-multilib --no-extras

It seems another patch is necessary for that configuration to build, not that I'm interested in it, I'm trying to find the culprit for #498 and stumbled upon this, right now I can't find a way to build a toolchain using UCRT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants