-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
patch-gcc7-tiger-intel.diff
104 lines (94 loc) · 2.91 KB
/
patch-gcc7-tiger-intel.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
--- Makefile.in.orig 2018-04-15 11:27:24.000000000 -0700
+++ Makefile.in 2018-04-15 11:31:29.000000000 -0700
@@ -356,7 +356,7 @@
# Flags to pass to stage2 and later makes. They are defined
# here so that they can be overridden by Makefile fragments.
-BOOT_CFLAGS= -g -O2
+BOOT_CFLAGS= -g -O2 -mmacosx-version-min=10.4
BOOT_LDFLAGS=
BOOT_ADAFLAGS= -gnatpg
@@ -403,7 +403,7 @@
GNATMAKE = @GNATMAKE@
CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@
+LDFLAGS = @LDFLAGS@ -mmacosx-version-min=10.4
LIBCFLAGS = $(CFLAGS)
CXXFLAGS = @CXXFLAGS@
LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
@@ -421,7 +421,7 @@
# Defaults for stage 1; some are overridden below.
-STAGE1_CFLAGS = $(STAGE_CFLAGS)
+STAGE1_CFLAGS = $(STAGE_CFLAGS) -mmacosx-version-min=10.4
STAGE1_CXXFLAGS = $(CXXFLAGS)
@if target-libstdc++-v3-bootstrap
# Override the above if we're bootstrapping C++.
@@ -568,8 +568,8 @@
COMPILER_LD_FOR_TARGET=@COMPILER_LD_FOR_TARGET@
COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_TARGET@
-CFLAGS_FOR_TARGET = @CFLAGS_FOR_TARGET@
-CXXFLAGS_FOR_TARGET = @CXXFLAGS_FOR_TARGET@
+CFLAGS_FOR_TARGET = @CFLAGS_FOR_TARGET@ -mmacosx-version-min=10.4
+CXXFLAGS_FOR_TARGET = @CXXFLAGS_FOR_TARGET@ -mmacosx-version-min=10.4
LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
--- libcilkrts/runtime/sysdep-unix.c.orig 2018-04-15 15:19:32.000000000 -0700
+++ libcilkrts/runtime/sysdep-unix.c 2018-04-15 15:58:16.000000000 -0700
@@ -102,6 +102,46 @@
# include <vxCpuLib.h>
#endif
+#ifdef __APPLE__
+#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
+#include <Availability.h>
+#else
+#include <AvailabilityMacros.h>
+#endif
+#endif //#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
+
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#define _SC_NPROCESSORS_ONLN 58
+
+long tigersysconf(int name){
+
+ if (name == _SC_NPROCESSORS_ONLN) {
+ int nm[2];
+ size_t len = 4;
+ uint32_t count;
+
+ nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
+ sysctl(nm, 2, &count, &len, NULL, 0);
+
+ if (count < 1) {
+ nm[1] = HW_NCPU;
+ sysctl(nm, 2, &count, &len, NULL, 0);
+ if (count < 1) { count = 1; }
+ }
+
+ return (long)count;
+ }
+ return -1;
+}
+#endif //#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#endif //#ifdef __APPLE__
+
+
+
struct global_sysdep_state
{
pthread_t *threads; ///< Array of pthreads for system workers
@@ -695,7 +735,13 @@
#ifdef __VXWORKS__
fprintf(fp, "System cores: %d\n", (int)__builtin_popcount(vxCpuEnabledGet()));
#else
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ fprintf(fp, "System cores: %d\n", (int)tigersysconf(_SC_NPROCESSORS_ONLN));
+#else
fprintf(fp, "System cores: %d\n", (int)sysconf(_SC_NPROCESSORS_ONLN));
+#endif //__MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+
#endif
fprintf(fp, "Cilk workers requested: %d\n", n);