diff mbox series

[2/6] AArch64: Add GCC_CPUINFO override

Message ID 20200709095445.GA31010@arm.com
State New
Headers show
Series [1/6] AArch64: Fix bugs in -mcpu=native detection. | expand

Commit Message

Tamar Christina July 9, 2020, 9:54 a.m. UTC
Hi All,

This adds an in intentionally undocumented environment variable
GCC_CPUINFO which can be used to test -mcpu=native.

Tests using this are added later on.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for master, GCC 10, 9 and 8?

Thanks,
Tamar

gcc/ChangeLog:

	* config/aarch64/driver-aarch64.c (host_detect_local_cpu):
	Add GCC_CPUINFO.

--

Comments

Kyrylo Tkachov July 9, 2020, 12:10 p.m. UTC | #1
> -----Original Message-----
> From: Tamar Christina <Tamar.Christina@arm.com>
> Sent: 09 July 2020 10:55
> To: gcc-patches@gcc.gnu.org
> Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>;
> Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov
> <Kyrylo.Tkachov@arm.com>; Richard Sandiford
> <Richard.Sandiford@arm.com>
> Subject: [PATCH 2/6] AArch64: Add GCC_CPUINFO override
> 
> Hi All,
> 
> This adds an in intentionally undocumented environment variable
> GCC_CPUINFO which can be used to test -mcpu=native.
> 
> Tests using this are added later on.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> 
> Ok for master, GCC 10, 9 and 8?
> 

I like the idea. I'm a bit wary of using a non-aarch64-namespaced name for the variable, but it looks like it could be useful for other targets testing if they wished to. In any case, as it's internal-only and non-documented we won't make any promises on its compatibility.

So ok if the testsuite parts are approved.
Thanks,
Kyrill

> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	* config/aarch64/driver-aarch64.c (host_detect_local_cpu):
> 	Add GCC_CPUINFO.
> 
> --
diff mbox series

Patch

diff --git a/gcc/config/aarch64/driver-aarch64.c b/gcc/config/aarch64/driver-aarch64.c
index 78616379189e80e75a28973f6b90ca4ca287e4bc..498350f5588e1109472ed95a61f1021d697eb057 100644
--- a/gcc/config/aarch64/driver-aarch64.c
+++ b/gcc/config/aarch64/driver-aarch64.c
@@ -230,6 +230,7 @@  host_detect_local_cpu (int argc, const char **argv)
   uint64_t extension_flags = 0;
   uint64_t default_flags = 0;
   std::string buf;
+  char *fcpu_info;
 
   gcc_assert (argc);
 
@@ -247,7 +248,11 @@  host_detect_local_cpu (int argc, const char **argv)
   if (!arch && !tune && !cpu)
     goto not_found;
 
-  f = fopen ("/proc/cpuinfo", "r");
+  fcpu_info = getenv ("GCC_CPUINFO");
+  if (fcpu_info)
+    f = fopen (fcpu_info, "r");
+  else
+    f = fopen ("/proc/cpuinfo", "r");
 
   if (f == NULL)
     goto not_found;