[gcc r14-10389] Fix MinGW option -mcrtdll=
https://gcc.gnu.org/g:a8617b5ec39f81a59650193be1db2cfecdd76fb6 commit r14-10389-ga8617b5ec39f81a59650193be1db2cfecdd76fb6 Author: Pali Rohár Date: Sun Jun 23 18:40:59 2024 +0200 Fix MinGW option -mcrtdll= Add missing msvcr40* and msvcrtd* cases to CPP_SPEC and document missing _UCRT macro and msvcr71* case. Fixes commit 453cb585f0f8673a5d69d1b420ffd4b3f53aca00. gcc/ * config/i386/mingw-w64.h (CPP_SPEC): Add missing -mcrtdll= cases: msvcr40*, msvcrtd*. * config/i386/mingw32.h (CPP_SPEC): Add missing -mcrtdll= cases: msvcr40*, msvcrtd*. * doc/invoke.texi: Add missing -mcrtdll= cases: msvcr40*, msvcrtd*, msvcr71*. Express wildcards with *. Document _UCRT. (cherry picked from commit 0de0476e47c774db21c94a75d60485a55ec7b5b4) Signed-off-by: Jonathan Yong <10wa...@gmail.com> Diff: --- gcc/config/i386/mingw-w64.h | 2 ++ gcc/config/i386/mingw32.h | 2 ++ gcc/doc/invoke.texi | 13 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h index dde26413e221..0a9986c44d40 100644 --- a/gcc/config/i386/mingw-w64.h +++ b/gcc/config/i386/mingw-w64.h @@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \ "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \ "%{mcrtdll=msvcrt40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcr40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcrtd*:-D__MSVCRT_VERSION__=0x600} " \ "%{mcrtdll=msvcrt-os*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr70*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr71*:-D__MSVCRT_VERSION__=0x701} " \ diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index 58304fc55f62..7753affd36d4 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -94,6 +94,8 @@ along with GCC; see the file COPYING3. If not see "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \ "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \ "%{mcrtdll=msvcrt40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcr40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcrtd*:-D__MSVCRT_VERSION__=0x600} " \ "%{mcrtdll=msvcrt-os*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr70*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr71*:-D__MSVCRT_VERSION__=0x701} " \ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 67220051a5be..f82f7d2817bb 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -36325,13 +36325,14 @@ enabled by default on those targets. @opindex mcrtdll @item -mcrtdll=@var{library} Preprocess, compile or link with specified C RunTime DLL @var{library}. -This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__} -and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose -start file for CRT @var{library} and link with CRT @var{library}. +This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__}, +@code{_UCRT} and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, +choose start file for CRT @var{library} and link with CRT @var{library}. Recognized CRT library names for proprocessor are: -@code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40}, -@code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90}, -@code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}. +@code{crtdll*}, @code{msvcrt10*}, @code{msvcrt20*}, @code{msvcrt40*}, +@code{msvcr40*}, @code{msvcrtd*}, @code{msvcrt-os*}, +@code{msvcr70*}, @code{msvcr71*}, @code{msvcr80*}, @code{msvcr90*}, +@code{msvcr100*}, @code{msvcr110*}, @code{msvcr120*} and @code{ucrt*}. If this options is not specified then the default MinGW import library @code{msvcrt} is used for linking and no other adjustment for preprocessor is done. MinGW import library @code{msvcrt} is just a
[gcc r15-2140] Do not use caller-saved registers for COMDAT functions
https://gcc.gnu.org/g:5080840d8fbf25a321dd27543a1462d393d338bc commit r15-2140-g5080840d8fbf25a321dd27543a1462d393d338bc Author: LIU Hao Date: Mon Jul 15 16:55:52 2024 +0800 Do not use caller-saved registers for COMDAT functions A reference to a COMDAT function may be resolved to another definition outside the current translation unit, so it's not eligible for `-fipa-ra`. In `decl_binds_to_current_def_p()` there is already a check for weak symbols. This commit checks for COMDAT functions that are not implemented as weak symbols, for example, on *-*-mingw32. gcc/ChangeLog: PR rtl-optimization/115049 * varasm.cc (decl_binds_to_current_def_p): Add a check for COMDAT declarations too, like weak ones. Diff: --- gcc/varasm.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/varasm.cc b/gcc/varasm.cc index beb88709033f..4426e7ce6c65 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -7813,6 +7813,8 @@ decl_binds_to_current_def_p (const_tree decl) for all other declaration types. */ if (DECL_WEAK (decl)) return false; + if (DECL_COMDAT_GROUP (decl)) +return false; if (DECL_COMMON (decl) && (DECL_INITIAL (decl) == NULL || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
[gcc r14-10460] Do not use caller-saved registers for COMDAT functions
https://gcc.gnu.org/g:747c4b58573ea00419f64293a61537eb69f43307 commit r14-10460-g747c4b58573ea00419f64293a61537eb69f43307 Author: LIU Hao Date: Mon Jul 15 16:55:52 2024 +0800 Do not use caller-saved registers for COMDAT functions A reference to a COMDAT function may be resolved to another definition outside the current translation unit, so it's not eligible for `-fipa-ra`. In `decl_binds_to_current_def_p()` there is already a check for weak symbols. This commit checks for COMDAT functions that are not implemented as weak symbols, for example, on *-*-mingw32. gcc/ChangeLog: PR rtl-optimization/115049 * varasm.cc (decl_binds_to_current_def_p): Add a check for COMDAT declarations too, like weak ones. (cherry picked from commit 5080840d8fbf25a321dd27543a1462d393d338bc) Diff: --- gcc/varasm.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 747f74ba1c00..b67a0b524dbf 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -7805,6 +7805,8 @@ decl_binds_to_current_def_p (const_tree decl) for all other declaration types. */ if (DECL_WEAK (decl)) return false; + if (DECL_COMDAT_GROUP (decl)) +return false; if (DECL_COMMON (decl) && (DECL_INITIAL (decl) == NULL || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
[gcc r13-8923] Do not use caller-saved registers for COMDAT functions
https://gcc.gnu.org/g:953bf37690d22de956d75c6aef7a9690ad55b9a7 commit r13-8923-g953bf37690d22de956d75c6aef7a9690ad55b9a7 Author: LIU Hao Date: Mon Jul 15 16:55:52 2024 +0800 Do not use caller-saved registers for COMDAT functions A reference to a COMDAT function may be resolved to another definition outside the current translation unit, so it's not eligible for `-fipa-ra`. In `decl_binds_to_current_def_p()` there is already a check for weak symbols. This commit checks for COMDAT functions that are not implemented as weak symbols, for example, on *-*-mingw32. gcc/ChangeLog: PR rtl-optimization/115049 * varasm.cc (decl_binds_to_current_def_p): Add a check for COMDAT declarations too, like weak ones. (cherry picked from commit 5080840d8fbf25a321dd27543a1462d393d338bc) Diff: --- gcc/varasm.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 9ad41c3dbdb8..e95cef8a7259 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -7632,6 +7632,8 @@ decl_binds_to_current_def_p (const_tree decl) for all other declaration types. */ if (DECL_WEAK (decl)) return false; + if (DECL_COMDAT_GROUP (decl)) +return false; if (DECL_COMMON (decl) && (DECL_INITIAL (decl) == NULL || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
[gcc r12-10625] Do not use caller-saved registers for COMDAT functions
https://gcc.gnu.org/g:2c5f48a43f26223cb8603b826d7c0d52cdbcfb46 commit r12-10625-g2c5f48a43f26223cb8603b826d7c0d52cdbcfb46 Author: LIU Hao Date: Mon Jul 15 16:55:52 2024 +0800 Do not use caller-saved registers for COMDAT functions A reference to a COMDAT function may be resolved to another definition outside the current translation unit, so it's not eligible for `-fipa-ra`. In `decl_binds_to_current_def_p()` there is already a check for weak symbols. This commit checks for COMDAT functions that are not implemented as weak symbols, for example, on *-*-mingw32. gcc/ChangeLog: PR rtl-optimization/115049 * varasm.cc (decl_binds_to_current_def_p): Add a check for COMDAT declarations too, like weak ones. (cherry picked from commit 5080840d8fbf25a321dd27543a1462d393d338bc) Diff: --- gcc/varasm.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/varasm.cc b/gcc/varasm.cc index dc9f733791ab..9fa3a42bf454 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -7621,6 +7621,8 @@ decl_binds_to_current_def_p (const_tree decl) for all other declaration types. */ if (DECL_WEAK (decl)) return false; + if (DECL_COMDAT_GROUP (decl)) +return false; if (DECL_COMMON (decl) && (DECL_INITIAL (decl) == NULL || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
[gcc r14-9528] c-c++-common/Wrestrict.c: fix some typos and enable for LLP64
https://gcc.gnu.org/g:9ee19f9b99ad1f877eb3e93382a437d951f737c8 commit r14-9528-g9ee19f9b99ad1f877eb3e93382a437d951f737c8 Author: Jonathan Yong <10wa...@gmail.com> Date: Sun Feb 11 09:25:25 2024 + c-c++-common/Wrestrict.c: fix some typos and enable for LLP64 Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/testsuite: * c-c++-common/Wrestrict.c: Fix typos in comments and enable for LLP64 testing. Diff: --- gcc/testsuite/c-c++-common/Wrestrict.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/c-c++-common/Wrestrict.c b/gcc/testsuite/c-c++-common/Wrestrict.c index 4d005a618b3..57a3f67e21e 100644 --- a/gcc/testsuite/c-c++-common/Wrestrict.c +++ b/gcc/testsuite/c-c++-common/Wrestrict.c @@ -381,14 +381,14 @@ void test_memcpy_range_exceed (char *d, const char *s) T (d + i, s + 1, 3); /* { dg-warning "accessing 3 bytes at offsets \\\[\[0-9\]+, \[0-9\]+] and 1 overlaps 1 byte" "memcpy" } */ #if __SIZEOF_SIZE_T__ == 8 - /* Verfiy the offset and size computation is correct. The overlap - offset mentioned in the warning plus sthe size of the access must + /* Verify the offset and size computation is correct. The overlap + offset mentioned in the warning plus the size of the access must not exceed DIFF_MAX. */ - T (d, d + i, 5); /* { dg-warning "accessing 5 bytes at offsets 0 and \\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 9223372036854775802" "LP64" { target lp64 } } */ - T (d + i, d, 5); /* { dg-warning "accessing 5 bytes at offsets \\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 9223372036854775802" "LP64" { target lp64 } } */ + T (d, d + i, 5); /* { dg-warning "accessing 5 bytes at offsets 0 and \\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 9223372036854775802" "LP64" { target { lp64 || llp64 } } } */ + T (d + i, d, 5); /* { dg-warning "accessing 5 bytes at offsets \\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 9223372036854775802" "LP64" { target { lp64 || llp64 } } } */ - T (d, s + i, 5); /* { dg-warning "accessing 5 bytes at offsets 0 and \\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 9223372036854775802" "LP64" { target lp64 } } */ - T (d + i, s, 5); /* { dg-warning "accessing 5 bytes at offsets \\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 9223372036854775802" "LP64" { target lp64 } } */ + T (d, s + i, 5); /* { dg-warning "accessing 5 bytes at offsets 0 and \\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 9223372036854775802" "LP64" { target { lp64 || llp64 } } } */ + T (d + i, s, 5); /* { dg-warning "accessing 5 bytes at offsets \\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 9223372036854775802" "LP64" { target { lp64 || llp64 } } } */ #elif __SIZEOF_SIZE_T__ == 4 T (d, d + i, 5); /* { dg-warning "accessing 5 bytes at offsets 0 and \\\[2147483645, 2147483647] overlaps 3 bytes at offset 2147483642" "ILP32" { target ilp32 } } */ T (d + i, d, 5); /* { dg-warning "accessing 5 bytes at offsets \\\[2147483645, 2147483647] and 0 overlaps 3 bytes at offset 2147483642" "ILP32" { target ilp32 } } */
[gcc r15-849] Define which threading model is in use on Windows
https://gcc.gnu.org/g:f6c5f836df44196a7cd3b206af5bb29df6c7c225 commit r15-849-gf6c5f836df44196a7cd3b206af5bb29df6c7c225 Author: TheShermanTanker Date: Mon May 27 12:57:33 2024 +0800 Define which threading model is in use on Windows gcc: * config/mingw/mingw32.h: Add new define for POSIX threads. Signed-off-by: TheShermanTanker Diff: --- gcc/config/mingw/mingw32.h | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h index 08f1b5f0696..fa6e307476c 100644 --- a/gcc/config/mingw/mingw32.h +++ b/gcc/config/mingw/mingw32.h @@ -34,8 +34,12 @@ along with GCC; see the file COPYING3. If not see | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \ | MASK_MS_BITFIELD_LAYOUT) -#ifndef TARGET_USING_MCFGTHREAD -#define TARGET_USING_MCFGTHREAD 0 +#ifdef TARGET_USING_MCFGTHREAD +#define DEFINE_THREAD_MODEL builtin_define ("__USING_MCFGTHREAD__"); +#elif defined(TARGET_USE_PTHREAD_BY_DEFAULT) +#define DEFINE_THREAD_MODEL builtin_define ("__USING_POSIXTHREAD__"); +#else +#define DEFINE_THREAD_MODEL #endif /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS @@ -56,8 +60,7 @@ along with GCC; see the file COPYING3. If not see builtin_define_std ("WIN64"); \ builtin_define ("_WIN64");\ } \ - if (TARGET_USING_MCFGTHREAD) \ - builtin_define ("__USING_MCFGTHREAD__");\ + DEFINE_THREAD_MODEL \ } \ while (0) @@ -190,7 +193,7 @@ along with GCC; see the file COPYING3. If not see #else #define SHARED_LIBGCC_SPEC " -lgcc " #endif -#if TARGET_USING_MCFGTHREAD +#ifdef TARGET_USING_MCFGTHREAD #define MCFGTHREAD_SPEC " -lmcfgthread -lkernel32 -lntdll " #else #define MCFGTHREAD_SPEC ""
[gcc r15-1354] diagnostics: Enable escape sequence processing on windows consoles
https://gcc.gnu.org/g:e943a5da40cd4799908d3d29001e1325eb00b755 commit r15-1354-ge943a5da40cd4799908d3d29001e1325eb00b755 Author: Peter Damianov Date: Mon Jun 3 10:07:08 2024 -0700 diagnostics: Enable escape sequence processing on windows consoles Since windows 10 release v1511, the windows console has had support for VT100 escape sequences. We should try to enable this, and utilize it where possible. gcc/ChangeLog: * diagnostic-color.cc (should_colorize): Enable processing of VT100 escape sequences on windows consoles Signed-off-by: Peter Damianov Diff: --- gcc/diagnostic-color.cc | 21 - 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gcc/diagnostic-color.cc b/gcc/diagnostic-color.cc index cbe57ce763f2..261a14b6c5f2 100644 --- a/gcc/diagnostic-color.cc +++ b/gcc/diagnostic-color.cc @@ -300,12 +300,23 @@ should_colorize (void) pp_write_text_to_stream() in pretty-print.cc calls fputs() on that stream. However, the code below for non-Windows doesn't seem to care about it either... */ - HANDLE h; - DWORD m; + HANDLE handle; + DWORD mode; + BOOL isconsole = false; - h = GetStdHandle (STD_ERROR_HANDLE); - return (h != INVALID_HANDLE_VALUE) && (h != NULL) - && GetConsoleMode (h, &m); + handle = GetStdHandle (STD_ERROR_HANDLE); + + if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL)) +isconsole = GetConsoleMode (handle, &mode); + + if (isconsole) +{ + /* Try to enable processing of VT100 escape sequences */ + mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode (handle, mode); +} + + return isconsole; #else char const *t = getenv ("TERM"); /* emacs M-x shell sets TERM="dumb". */
[gcc r15-1355] diagnostics: Don't hardcode auto_enable_urls to false for mingw hosts
https://gcc.gnu.org/g:5c662a3a5724b75ceb06496d9c64137d59c89d39 commit r15-1355-g5c662a3a5724b75ceb06496d9c64137d59c89d39 Author: Peter Damianov Date: Mon Jun 3 10:07:09 2024 -0700 diagnostics: Don't hardcode auto_enable_urls to false for mingw hosts Windows terminal and mintty both have support for link escape sequences, and so auto_enable_urls shouldn't be hardcoded to false. For older versions of the windows console, mingw_ansi_fputs's console API translation logic does mangle these sequences, but there's nothing useful it could do even if this weren't the case, so check if the ansi escape sequences are supported at all. conhost.exe doesn't support link escape sequences, but printing them does not cause any problems. gcc/ChangeLog: * diagnostic-color.cc (auto_enable_urls): Don't hardcode to return false on mingw hosts. (auto_enable_urls): Return true if console supports ansi escape sequences. Signed-off-by: Peter Damianov Diff: --- gcc/diagnostic-color.cc | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gcc/diagnostic-color.cc b/gcc/diagnostic-color.cc index 261a14b6c5f2..184419cea367 100644 --- a/gcc/diagnostic-color.cc +++ b/gcc/diagnostic-color.cc @@ -384,9 +384,6 @@ parse_env_vars_for_urls () static bool auto_enable_urls () { -#ifdef __MINGW32__ - return false; -#else const char *term, *colorterm; /* First check the terminal is capable of printing color escapes, @@ -394,6 +391,21 @@ auto_enable_urls () if (!should_colorize ()) return false; +#ifdef __MINGW32__ + HANDLE handle; + DWORD mode; + + handle = GetStdHandle (STD_ERROR_HANDLE); + if ((handle == INVALID_HANDLE_VALUE) || (handle == NULL)) +return false; + + /* If ansi escape sequences aren't supported by the console, then URLs will + print mangled from mingw_ansi_fputs's console API translation. It wouldn't + be useful even if this weren't the case. */ + if (GetConsoleMode (handle, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)) +return false; +#endif + /* xfce4-terminal is known to not implement URLs at this time. Recently new installations (0.8) will safely ignore the URL escape sequences, but a large number of legacy installations (0.6.3) print @@ -428,7 +440,6 @@ auto_enable_urls () return false; return true; -#endif } /* Determine if URLs should be enabled, based on RULE,
[gcc r15-1356] pretty-print: Don't translate escape sequences to windows console API
https://gcc.gnu.org/g:bc630d613db94eb50687a009ae6b45098ab02db5 commit r15-1356-gbc630d613db94eb50687a009ae6b45098ab02db5 Author: Peter Damianov Date: Mon Jun 3 10:07:10 2024 -0700 pretty-print: Don't translate escape sequences to windows console API Modern versions of windows (after windows 10 v1511) support VT100 escape sequences, so translation for them is not necessary. The translation also mangles embedded warning documentation links. gcc/ChangeLog: * pretty-print.cc (mingw_ansi_fputs): Don't translate escape sequences if the console has ENABLE_VIRTUAL_TERMINAL_PROCESSING. Signed-off-by: Peter Damianov Diff: --- gcc/pretty-print.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index 639e2b881586..ec44172f24df 100644 --- a/gcc/pretty-print.cc +++ b/gcc/pretty-print.cc @@ -674,8 +674,9 @@ mingw_ansi_fputs (const char *str, FILE *fp) /* Don't mess up stdio functions with Windows APIs. */ fflush (fp); - if (GetConsoleMode (h, &mode)) -/* If it is a console, translate ANSI escape codes as needed. */ + if (GetConsoleMode (h, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)) +/* If it is a console, and doesn't support ANSI escape codes, translate + them as needed. */ for (;;) { if ((esc_code = find_esc_head (&prefix_len, &esc_head, read)) == 0)
[gcc r15-1581] Fix MinGW option -mcrtdll=
https://gcc.gnu.org/g:0de0476e47c774db21c94a75d60485a55ec7b5b4 commit r15-1581-g0de0476e47c774db21c94a75d60485a55ec7b5b4 Author: Pali Rohár Date: Sun Jun 23 18:40:59 2024 +0200 Fix MinGW option -mcrtdll= Add missing msvcr40* and msvcrtd* cases to CPP_SPEC and document missing _UCRT macro and msvcr71* case. Fixes commit 453cb585f0f8673a5d69d1b420ffd4b3f53aca00. gcc/ * config/i386/mingw-w64.h (CPP_SPEC): Add missing -mcrtdll= cases: msvcr40*, msvcrtd*. * config/mingw/mingw32.h (CPP_SPEC): Add missing -mcrtdll= cases: msvcr40*, msvcrtd*. * doc/invoke.texi: Add missing -mcrtdll= cases: msvcr40*, msvcrtd*, msvcr71*. Express wildcards with *. Document _UCRT. Diff: --- gcc/config/i386/mingw-w64.h | 2 ++ gcc/config/mingw/mingw32.h | 2 ++ gcc/doc/invoke.texi | 13 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h index dde26413e22..0a9986c44d4 100644 --- a/gcc/config/i386/mingw-w64.h +++ b/gcc/config/i386/mingw-w64.h @@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \ "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \ "%{mcrtdll=msvcrt40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcr40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcrtd*:-D__MSVCRT_VERSION__=0x600} " \ "%{mcrtdll=msvcrt-os*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr70*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr71*:-D__MSVCRT_VERSION__=0x701} " \ diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h index fa6e307476c..da8e1e8949e 100644 --- a/gcc/config/mingw/mingw32.h +++ b/gcc/config/mingw/mingw32.h @@ -99,6 +99,8 @@ along with GCC; see the file COPYING3. If not see "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \ "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \ "%{mcrtdll=msvcrt40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcr40*:-D__MSVCRT_VERSION__=0x400} " \ +"%{mcrtdll=msvcrtd*:-D__MSVCRT_VERSION__=0x600} " \ "%{mcrtdll=msvcrt-os*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr70*:-D__MSVCRT_VERSION__=0x700} " \ "%{mcrtdll=msvcr71*:-D__MSVCRT_VERSION__=0x701} " \ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 580232a76a6..23d90db2925 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -36462,13 +36462,14 @@ enabled by default on those targets. @opindex mcrtdll @item -mcrtdll=@var{library} Preprocess, compile or link with specified C RunTime DLL @var{library}. -This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__} -and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose -start file for CRT @var{library} and link with CRT @var{library}. +This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__}, +@code{_UCRT} and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, +choose start file for CRT @var{library} and link with CRT @var{library}. Recognized CRT library names for proprocessor are: -@code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40}, -@code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90}, -@code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}. +@code{crtdll*}, @code{msvcrt10*}, @code{msvcrt20*}, @code{msvcrt40*}, +@code{msvcr40*}, @code{msvcrtd*}, @code{msvcrt-os*}, +@code{msvcr70*}, @code{msvcr71*}, @code{msvcr80*}, @code{msvcr90*}, +@code{msvcr100*}, @code{msvcr110*}, @code{msvcr120*} and @code{ucrt*}. If this options is not specified then the default MinGW import library @code{msvcrt} is used for linking and no other adjustment for preprocessor is done. MinGW import library @code{msvcrt} is just a
[gcc r15-9032] gcc/mingw: Align `.refptr.` to 8-byte boundaries for 64-bit targets
https://gcc.gnu.org/g:8d42378acdf1a011420ba78685f7a6c79808c881 commit r15-9032-g8d42378acdf1a011420ba78685f7a6c79808c881 Author: LIU Hao Date: Sat Mar 29 22:47:54 2025 +0800 gcc/mingw: Align `.refptr.` to 8-byte boundaries for 64-bit targets Windows only requires sections to be aligned on a 4-byte boundary. This used to work because in binutils the `.rdata` section is over-aligned to a 16-byte boundary, which will be fixed in the future. This matches the output of Clang. Signed-off-by: LIU Hao Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/ChangeLog: * config/mingw/winnt.cc (mingw_pe_file_end): Add `.p2align`. Diff: --- gcc/config/mingw/winnt.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/mingw/winnt.cc b/gcc/config/mingw/winnt.cc index adaa6dfa3cff..08a761d3a6d4 100644 --- a/gcc/config/mingw/winnt.cc +++ b/gcc/config/mingw/winnt.cc @@ -819,6 +819,7 @@ mingw_pe_file_end (void) } fprintf (asm_out_file, "\t.section\t.rdata$%s, \"dr\"\n" + "\t.p2align\t3, 0\n" "\t.globl\t%s\n" "\t.linkonce\tdiscard\n", oname, oname); fprintf (asm_out_file, "%s:\n\t.quad\t%s\n", oname, name);
[gcc r15-9337] deref-before-check-pr113253.c: Fix bogus warnings on lp32
https://gcc.gnu.org/g:9ea6bdac02af61f360b5741bef978be02924252d commit r15-9337-g9ea6bdac02af61f360b5741bef978be02924252d Author: Jonathan Yong <10wa...@gmail.com> Date: Mon Apr 7 15:40:05 2025 + deref-before-check-pr113253.c: Fix bogus warnings on lp32 Warnings about pointer sizes cause the test to fail incorrectly. A dummy return value is also added to set_marker_internal for completeness to suppress a -Wreturn-type warning even though gcc does not issue it by default. Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/testsuite/ChangeLog: PR analyzer/113253 * gcc.dg/analyzer/deref-before-check-pr113253.c: (ptrdiff_t): use stddef.h type. (uintptr_t): ditto. (EMACS_INT): ditto. (set_marker_internal): Add dummy 0 to suppress -Wreturn-type. Diff: --- gcc/testsuite/gcc.dg/analyzer/deref-before-check-pr113253.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.dg/analyzer/deref-before-check-pr113253.c b/gcc/testsuite/gcc.dg/analyzer/deref-before-check-pr113253.c index d9015accd6ab..1890312cc1ab 100644 --- a/gcc/testsuite/gcc.dg/analyzer/deref-before-check-pr113253.c +++ b/gcc/testsuite/gcc.dg/analyzer/deref-before-check-pr113253.c @@ -5,12 +5,12 @@ /* { dg-additional-options "-O2 -g" } */ -typedef long int ptrdiff_t; -typedef unsigned long int uintptr_t; -typedef long int EMACS_INT; +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __UINTPTR_TYPE__ uintptr_t; +typedef __PTRDIFF_TYPE__ EMACS_INT; enum { - EMACS_INT_WIDTH = 64, + EMACS_INT_WIDTH = sizeof(EMACS_INT) * 8, VALBITS = EMACS_INT_WIDTH - 3, }; typedef struct Lisp_X* Lisp_Word; @@ -151,4 +151,5 @@ set_marker_internal(Lisp_Object position, Lisp_Object buffer) struct buffer* b = live_buffer(buffer); if (NILP(position) || (MARKERP(position) && !XMARKER(position)->buffer) || !b) /* { dg-bogus "Wanalyzer-deref-before-check" } */ unchain_marker(); + return 0; }
[gcc r15-9148] switch-3.c: Fix llp64 warnings
https://gcc.gnu.org/g:e7912d4a81cf34e05c7ded70910069b691a8bb15 commit r15-9148-ge7912d4a81cf34e05c7ded70910069b691a8bb15 Author: Jonathan Yong <10wa...@gmail.com> Date: Wed Apr 2 11:18:21 2025 + switch-3.c: Fix llp64 warnings mtrr_ioctl() uses long and casts it to a pointer. Fix warnings for llp64 platforms. Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/testsuite/ChangeLog: * gcc.dg/analyzer/torture/switch-3.c: Fix llp64 warnings. Diff: --- gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c b/gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c index 57b8acdb2929..b40be664d389 100644 --- a/gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c +++ b/gcc/testsuite/gcc.dg/analyzer/torture/switch-3.c @@ -68,7 +68,7 @@ extern void check_init_u32 (__u32 v); /* Adapted/reduced from arch/x86/kernel/cpu/mtrr/if.c: mtrr_ioctl, which is GPL-2.0 */ -long mtrr_ioctl(unsigned int cmd, unsigned long __arg) { +long mtrr_ioctl(unsigned int cmd, __UINTPTR_TYPE__ __arg) { int err = 0; struct mtrr_sentry sentry; struct mtrr_gentry gentry;
[gcc r15-9373] bf-ms-attrib.c: Fix expected struct size
https://gcc.gnu.org/g:7e6255edeb5a01d6ae1c2fa5bed391a836726229 commit r15-9373-g7e6255edeb5a01d6ae1c2fa5bed391a836726229 Author: Jonathan Yong <10wa...@gmail.com> Date: Wed Apr 9 14:29:39 2025 + bf-ms-attrib.c: Fix expected struct size Both gcc and msvc agree that the struct size should be 12, gcc is already correct. Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/testsuite/ChangeLog: PR target/113633 * gcc.dg/bf-ms-attrib.c: Fix expected __ms_struct__ layout size. Diff: --- gcc/testsuite/gcc.dg/bf-ms-attrib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/bf-ms-attrib.c b/gcc/testsuite/gcc.dg/bf-ms-attrib.c index 2da4f0320d6a..5208c7f882fb 100644 --- a/gcc/testsuite/gcc.dg/bf-ms-attrib.c +++ b/gcc/testsuite/gcc.dg/bf-ms-attrib.c @@ -32,7 +32,7 @@ main() /* As long as the sizes are as expected, we know attributes are working. bf-ms-layout.c makes sure the right thing happens when the attribute is on. */ -if (sizeof(struct one_ms) != 8) +if (sizeof(struct one_ms) != 12) abort(); if (sizeof(struct one_gcc) != 8) abort();
[gcc r15-9372] realloc-1.c: accept long long in warning for llp64
https://gcc.gnu.org/g:f4cdbd619d89147cf5767ddbb10fbeee8f1b0cbc commit r15-9372-gf4cdbd619d89147cf5767ddbb10fbeee8f1b0cbc Author: Jonathan Yong <10wa...@gmail.com> Date: Wed Apr 9 14:21:22 2025 + realloc-1.c: accept long long in warning for llp64 llp64 targets like mingw-w64 will print: warning: ignoring return value of ‘void* __builtin_realloc(void*, long long unsigned int)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] Change the regex pattern to accept it. Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/testsuite/ChangeLog: * c-c++-common/analyzer/realloc-1.c: Make diagnostic accept long long for __builtin_realloc warning. Diff: --- gcc/testsuite/c-c++-common/analyzer/realloc-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/c-c++-common/analyzer/realloc-1.c b/gcc/testsuite/c-c++-common/analyzer/realloc-1.c index 04925cfe5adc..0bb846c62497 100644 --- a/gcc/testsuite/c-c++-common/analyzer/realloc-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/realloc-1.c @@ -92,5 +92,5 @@ void test_9 (void *p) void test_10 (char *s, int n) { __builtin_realloc(s, n); /* { dg-warning "ignoring return value of '__builtin_realloc' declared with attribute 'warn_unused_result'" "" { target c } } */ - /* { dg-warning "ignoring return value of 'void\\* __builtin_realloc\\(void\\*, (long )?unsigned int\\)' declared with attribute 'warn_unused_result'" "" { target c++ } .-1 } */ + /* { dg-warning "ignoring return value of 'void\\* __builtin_realloc\\(void\\*, (long )*unsigned int\\)' declared with attribute 'warn_unused_result'" "" { target c++ } .-1 } */ } /* { dg-warning "leak" } */
[gcc r15-9480] Wbuiltin-declaration-mismatch-4.c: accept long long in warning for llp64
https://gcc.gnu.org/g:039b566f2f03699676d31b681d1595bddc94a774 commit r15-9480-g039b566f2f03699676d31b681d1595bddc94a774 Author: Jonathan Yong <10wa...@gmail.com> Date: Sun Apr 13 02:41:36 2025 + Wbuiltin-declaration-mismatch-4.c: accept long long in warning for llp64 llp64 targets like mingw-w64 will print: gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-4.c:80:17: warning: ‘memset’ argument 3 promotes to ‘ptrdiff_t’ {aka ‘long long int’} where ‘long long unsigned int’ is expected in a call to built-in function declared without prototype [- Wbuiltin-declaration-mismatch] Change the regex pattern to accept it. Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/testsuite/ChangeLog: * gcc.dg/Wbuiltin-declaration-mismatch-4.c: Make diagnostic accept long long. Diff: --- gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-4.c b/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-4.c index c48fe5fcf300..09665b49 100644 --- a/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-4.c +++ b/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-4.c @@ -77,9 +77,9 @@ void test_integer_conversion_memset (void *d) /* Passing a ptrdiff_t where size_t is expected may not be unsafe but because GCC may emits suboptimal code for such calls warning for them helps improve efficiency. */ - memset (d, 0, diffi); /* { dg-warning ".memset. argument 3 promotes to .ptrdiff_t. {aka .\(long \)?\(int\)?\(__int20\)?.} where .\(long \)?\(__int20 \)?unsigned\( int\)?. is expected" } */ + memset (d, 0, diffi); /* { dg-warning ".memset. argument 3 promotes to .ptrdiff_t. {aka .\(long \)*\(int\)?\(__int20\)?.} where .\(long \)*\(__int20 \)?unsigned\( int\)?. is expected" } */ - memset (d, 0, 2.0); /* { dg-warning ".memset. argument 3 type is .double. where '\(long \)?\(__int20 \)?unsigned\( int\)?' is expected" } */ + memset (d, 0, 2.0); /* { dg-warning ".memset. argument 3 type is .double. where '\(long \)*\(__int20 \)?unsigned\( int\)?' is expected" } */ /* Verify that the same call as above but to the built-in doesn't trigger a warning. */
[gcc r16-27] ref-temp1.C: Enable some tests for PE targets
https://gcc.gnu.org/g:b986ed16c2546674256b8c892541a8fdb6a97202 commit r16-27-gb986ed16c2546674256b8c892541a8fdb6a97202 Author: Jonathan Yong <10wa...@gmail.com> Date: Tue Apr 15 11:41:36 2025 + ref-temp1.C: Enable some tests for PE targets Test for expected PE values. Signed-off-by: Jonathan Yong <10wa...@gmail.com> gcc/testsuite/ChangeLog: * g++.dg/abi/ref-temp1.C: Replicate some test based on PE expectations. * lib/target-supports.exp: New check_effective_target_pe. Diff: --- gcc/testsuite/g++.dg/abi/ref-temp1.C | 13 + gcc/testsuite/lib/target-supports.exp | 10 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/g++.dg/abi/ref-temp1.C b/gcc/testsuite/g++.dg/abi/ref-temp1.C index 70c9a7a431c2..b02dcf610427 100644 --- a/gcc/testsuite/g++.dg/abi/ref-temp1.C +++ b/gcc/testsuite/g++.dg/abi/ref-temp1.C @@ -7,11 +7,16 @@ struct B { const A (&x)[2]; }; template B &&b = { { { { 1, 2, 3 } }, { { 4, 5, 6 } } } }; B &temp = b; -// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE_" } } -// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE0_" } } -// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE1_" } } -// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE2_" } } +// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE_" { target { ! pe } } } } +// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE0_" { target { ! pe } } } } +// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE1_" { target { ! pe } } } } +// { dg-final { scan-assembler ".weak\(_definition\)?\[ \t\]_?_ZGR1bIvE2_" { target { ! pe } } } } +// { dg-final { scan-assembler "\.section\t\.data\\\$_ZGR1bIvE_,\"w\"\n\t\.linkonce same_size" { target pe } } } +// { dg-final { scan-assembler "\.section\t\.rdata\\\$_ZGR1bIvE0_,\"dr\"\n\t\.linkonce same_size" { target pe } } } +// { dg-final { scan-assembler "\.section\t\.rdata\\\$_ZGR1bIvE1_,\"dr\"\n\t\.linkonce same_size" { target pe } } } +// { dg-final { scan-assembler "\.section\t\.rdata\\\$_ZGR1bIvE2_,\"dr\"\n\t\.linkonce same_size" { target pe } } } +// // { dg-final { scan-assembler "_ZGR1bIvE_:\n\[^\n]+_ZGR1bIvE0_" } } // { dg-final { scan-assembler "_ZGR1bIvE0_:\n\[^\n]+_ZGR1bIvE1_" } } // { dg-final { scan-assembler "_ZGR1bIvE1_:\n\[^\n]+\[ \t\]1" } } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index a62f459ad7ed..869d1501c383 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -562,6 +562,16 @@ proc check_effective_target_elf { } { } } +# Returns 1 if the target uses the PE/COFF object format, 0 otherwise. + +proc check_effective_target_pe { } { +if { [gcc_target_object_format] == "pe" } { +return 1; +} else { +return 0; +} +} + # Returns 1 if the target toolchain supports ifunc, 0 otherwise. proc check_ifunc_available { } {