Skip to content

Commit d36b86a

Browse files
authored
Merge pull request #4320 from ChipKerchner/fixOldGCCPower
Fix older versions of gcc - missing __has_builtin, cpuid and no support of P10.
2 parents 46440a0 + d99aad8 commit d36b86a

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Makefile.power

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ endif
1111

1212
ifeq ($(CORE), POWER10)
1313
ifneq ($(C_COMPILER), PGI)
14+
ifeq ($(C_COMPILER), GCC))
15+
ifeq ($(GCCVERSIONGTEQ10), 1)
1416
CCOMMON_OPT += -Ofast -mcpu=power10 -mtune=power10 -mvsx -fno-fast-math
17+
else ifneq ($(GCCVERSIONGT4), 1)
18+
$(warning your compiler is too old to fully support POWER9, getting a newer version of gcc is recommended)
19+
CCOMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -fno-fast-math
20+
else
21+
$(warning your compiler is too old to fully support POWER10, getting a newer version of gcc is recommended)
22+
CCOMMON_OPT += -Ofast -mcpu=power9 -mtune=power9 -mvsx -fno-fast-math
23+
endif
24+
else
25+
CCOMMON_OPT += -Ofast -mcpu=power10 -mtune=power10 -mvsx -fno-fast-math
26+
endif
1527
ifeq ($(F_COMPILER), IBM)
1628
FCOMMON_OPT += -O2 -qrecur -qnosave -qarch=pwr10 -qtune=pwr10 -qfloat=nomaf -qzerosize
1729
else

driver/others/dynamic_power.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static int cpuid(void)
6666
#endif
6767
return CPU_UNKNOWN;
6868
}
69-
#else
70-
#if defined(C_PGI) || defined(__clang__)
69+
#elif defined(C_PGI) || defined(__clang__)
7170
/*
7271
* NV HPC compilers do not yet implement __builtin_cpu_is().
7372
* Fake a version here for use in the CPU detection code below.
@@ -196,13 +195,21 @@ static int cpuid(void)
196195
cpu_type = pvrPOWER[i].cpu_type;
197196
return (int)(cpu_type);
198197
}
199-
#endif /* C_PGI */
198+
#elif !defined(__BUILTIN_CPU_SUPPORTS__)
199+
static int cpuid(void)
200+
{
201+
return CPU_UNKNOWN;
202+
}
200203
#endif /* _AIX */
201204

202205
#ifndef __BUILTIN_CPU_SUPPORTS__
203206
#include <string.h>
204207

205-
#if defined(_AIX) || (defined(__has_builtin) && !__has_builtin(__builtin_cpu_is))
208+
#ifndef __has_builtin
209+
#define __has_builtin(x) 0
210+
#endif
211+
212+
#if defined(_AIX) || !__has_builtin(__builtin_cpu_is)
206213
static int __builtin_cpu_is(const char *arg)
207214
{
208215
static int ipinfo = -1;
@@ -227,7 +234,7 @@ static int __builtin_cpu_is(const char *arg)
227234
}
228235
#endif
229236

230-
#if defined(_AIX) || (defined(__has_builtin) && !__has_builtin(__builtin_cpu_supports))
237+
#if defined(_AIX) || !__has_builtin(__builtin_cpu_supports)
231238
static int __builtin_cpu_supports(const char *arg)
232239
{
233240
return 0;

0 commit comments

Comments
 (0)