Bug 96238 - [i386] cpuid.h header needs include guards
Summary: [i386] cpuid.h header needs include guards
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: patch
Depends on:
Blocks:
 
Reported: 2020-07-17 23:12 UTC by Thiago Macieira
Modified: 2020-11-11 02:55 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-07-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Macieira 2020-07-17 23:12:31 UTC
$ cat x.c
#include <cpuid.h>
#include <cpuid.h>
$ gcc -c x.c
/usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:228:1: error: redefinition of ‘__get_cpuid_max’
  228 | __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
      | ^~~~~~~~~~~~~~~
In file included from <command-line>:32:
/usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:228:1: note: previous definition of ‘__get_cpuid_max’ was here
  228 | __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
      | ^~~~~~~~~~~~~~~
/usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:283:1: error: redefinition of ‘__get_cpuid’
  283 | __get_cpuid (unsigned int __leaf,
      | ^~~~~~~~~~~
/usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:283:1: note: previous definition of ‘__get_cpuid’ was here
  283 | __get_cpuid (unsigned int __leaf,
      | ^~~~~~~~~~~
/usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:300:1: error: redefinition of ‘__get_cpuid_count’
  300 | __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
      | ^~~~~~~~~~~~~~~~~
/usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:300:1: note: previous definition of ‘__get_cpuid_count’ was here
  300 | __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
      | ^~~~~~~~~~~~~~~~~
Comment 1 H.J. Lu 2020-07-18 11:55:57 UTC
A patch is posted at

https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550244.html
Comment 2 GCC Commits 2020-07-19 11:21:15 UTC
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:29e1039ca211c4e3f1053925eda0a81c57cbcb0c

commit r11-2216-g29e1039ca211c4e3f1053925eda0a81c57cbcb0c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jul 18 04:43:10 2020 -0700

    x86: Add __cpuidex and include guard to <cpuid.h>
    
    Add
    
    void __cpuidex (int __cpuid_info[4], int __leaf, int __subleaf);
    
    as well as include guard to <cpuid.h>.
    
    gcc/
    
            PR target/95973
            PR target/96238
            * config/i386/cpuid.h: Add include guard.
            (__cpuidex): New.
    
    gcc/testsuite/
    
            PR target/95973
            PR target/96238
            * gcc.target/i386/pr95973.c: New test.
Comment 3 H.J. Lu 2020-07-19 12:26:43 UTC
Fixed for GCC 11.
Comment 4 Roland McGrath 2020-11-11 02:55:19 UTC
Can at least the header guard fix be backported to 10?