Bug 100461 - [11/12 Regression] mingw build broken due to change of rdtsc implementation
Summary: [11/12 Regression] mingw build broken due to change of rdtsc implementation
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.1.0
: P3 normal
Target Milestone: 11.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-06 20:14 UTC by Daniel Starke
Modified: 2022-05-14 07:07 UTC (History)
1 user (show)

See Also:
Host: mingw
Target: mingw-w64
Build: mingw-w64
Known to work: 10.3.0
Known to fail: 11.1.0
Last reconfirmed: 2021-05-06 00:00:00


Attachments
rdtsc.c (387 bytes, text/x-csrc)
2021-05-07 04:25 UTC, Daniel Starke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Starke 2021-05-06 20:14:40 UTC
GCC 11.1.0 build for mingw-w64 is broken now. Up to 10.3.0 the following was used in gcc/config/i386/ia32intrin.h:
    extern __inline unsigned long long
    __attribute__((__gnu_inline__, __always_inline__, __artificial__))
    __rdtsc (void)
    {
      return __builtin_ia32_rdtsc ();
    }
    
    extern __inline unsigned long long
    __attribute__((__gnu_inline__, __always_inline__, __artificial__))
    __rdtscp (unsigned int *__A)
    {
      return __builtin_ia32_rdtscp (__A);
    }
but now we have just
    #define __rdtsc()               __builtin_ia32_rdtsc ()
    #define __rdtscp(a)             __builtin_ia32_rdtscp (a)
Changing this back fixes the build.
See also mingw-w64 7.0.0 at mingw-w64-crt/intrincs/rdtsc.c.
Comment 1 Uroš Bizjak 2021-05-06 20:54:19 UTC
CC author.
Comment 2 Andrew Pinski 2021-05-06 22:29:24 UTC
To me this looks like a bug in mingw-w64-crt rather than a bug in GCC.
A simple fix to the mingw-w64-crt sources is just do:

unsigned __int64 (__rdtsc)(void)
Comment 3 H.J. Lu 2021-05-06 22:54:52 UTC
What is in mingw-w64-crt/intrincs/rdtsc.c?
Comment 4 Daniel Starke 2021-05-07 04:25:24 UTC
Created attachment 50772 [details]
rdtsc.c

Please find attached the mingw-w64 file.
Comment 5 H.J. Lu 2021-05-07 12:11:44 UTC
(In reply to Daniel Starke from comment #4)
> Created attachment 50772 [details]
> rdtsc.c
> 
> Please find attached the mingw-w64 file.

Please change

#if !__has_builtin(__rdtsc)

to

#if !__has_builtin(__rdtsc) && !defined __rdtsc
Comment 6 Daniel Starke 2021-05-07 17:13:48 UTC
Thank you for the suggestion, however, I am not involved in the mingw-w64 project. Furthermore, the fact that this regression remains against all versions of mingw-w64 known to date does not change.
It is also unclear to me why only these two intrinsics are handled differently now. What was the purpose of this change? Do we break existing code if the change is reverted?
Comment 7 H.J. Lu 2021-05-07 19:49:00 UTC
(In reply to Daniel Starke from comment #6)
> Thank you for the suggestion, however, I am not involved in the mingw-w64
> project. Furthermore, the fact that this regression remains against all
> versions of mingw-w64 known to date does not change.

It doesn't make what mingw-w64 did is correct.

> It is also unclear to me why only these two intrinsics are handled
> differently now. What was the purpose of this change? Do we break existing
> code if the change is reverted?

See PR target/99744.
Comment 8 Daniel Starke 2022-05-14 06:22:46 UTC
This bug was fixes in mingw-w64. The bug fix is included since versions 8.0.1.
See https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/bb03f15f-db70-a511-a10d-396fbd8cf3c1%40126.com/#msg37259429
The bug report here can be closed.
Comment 9 Jonathan Wakely 2022-05-14 07:07:51 UTC
It was already closed a year ago.