Skip to content

Commit

Permalink
patches for building gcc on Apple Silicon
Browse files Browse the repository at this point in the history
By @jannau in #116.
  • Loading branch information
richard-vd committed Dec 13, 2021
1 parent 0f22991 commit a558d3a
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 0 deletions.
18 changes: 18 additions & 0 deletions patches/gcc-5.3.0/0021-apple-silicon.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff -ru a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c
--- a/gcc/config/host-darwin.c 2021-05-14 10:42:08.000000000 +0200
+++ b/gcc/config/host-darwin.c 2021-08-07 22:51:11.000000000 +0200
@@ -22,6 +22,8 @@
#include "coretypes.h"
#include "diagnostic-core.h"
#include "config/host-darwin.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"

/* Yes, this is really supposed to work. */
static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096)));
@@ -75,3 +77,5 @@

return ret;
}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
30 changes: 30 additions & 0 deletions patches/gcc-6.5.0/0026-apple-silicon.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff -ru a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c
--- a/gcc/config/host-darwin.c 2021-05-14 10:42:08.000000000 +0200
+++ b/gcc/config/host-darwin.c 2021-08-07 22:51:11.000000000 +0200
@@ -22,6 +22,8 @@
#include "coretypes.h"
#include "diagnostic-core.h"
#include "config/host-darwin.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"

/* Yes, this is really supposed to work. */
static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096)));
@@ -75,3 +77,5 @@

return ret;
}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff -ru a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
--- a/gcc/config/aarch64/aarch64.h 2018-02-01 22:33:05.000000000 +0100
+++ b/gcc/config/aarch64/aarch64.h 2021-08-10 00:40:48.000000000 +0200
@@ -907,7 +907,7 @@
#define MCPU_TO_MARCH_SPEC_FUNCTIONS \
{ "rewrite_mcpu", aarch64_rewrite_mcpu },

-#if defined(__aarch64__)
+#if defined(__aarch64__) && ! defined(__APPLE__)
extern const char *host_detect_local_cpu (int argc, const char **argv);
# define EXTRA_SPEC_FUNCTIONS \
{ "local_cpu_detect", host_detect_local_cpu }, \
30 changes: 30 additions & 0 deletions patches/gcc-7.5.0/0023-apple-silicon.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff -ru a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c
--- a/gcc/config/host-darwin.c 2021-05-14 10:42:08.000000000 +0200
+++ b/gcc/config/host-darwin.c 2021-08-07 22:51:11.000000000 +0200
@@ -22,6 +22,8 @@
#include "coretypes.h"
#include "diagnostic-core.h"
#include "config/host-darwin.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"

/* Yes, this is really supposed to work. */
static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096)));
@@ -75,3 +77,5 @@

return ret;
}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff -ru a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
--- a/gcc/config/aarch64/aarch64.h 2018-02-01 22:09:06.000000000 +0100
+++ b/gcc/config/aarch64/aarch64.h 2021-08-10 00:50:52.000000000 +0200
@@ -930,7 +930,7 @@
#define MCPU_TO_MARCH_SPEC_FUNCTIONS \
{ "rewrite_mcpu", aarch64_rewrite_mcpu },

-#if defined(__aarch64__)
+#if defined(__aarch64__) && ! defined(__APPLE__)
extern const char *host_detect_local_cpu (int argc, const char **argv);
# define EXTRA_SPEC_FUNCTIONS \
{ "local_cpu_detect", host_detect_local_cpu }, \
30 changes: 30 additions & 0 deletions patches/gcc-8.5.0/0022-apple-silicon.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff -ru a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c
--- a/gcc/config/host-darwin.c 2021-05-14 10:42:08.000000000 +0200
+++ b/gcc/config/host-darwin.c 2021-08-07 22:51:11.000000000 +0200
@@ -22,6 +22,8 @@
#include "coretypes.h"
#include "diagnostic-core.h"
#include "config/host-darwin.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"

/* Yes, this is really supposed to work. */
static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096)));
@@ -75,3 +77,5 @@

return ret;
}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff -ru a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
--- a/gcc/config/aarch64/aarch64.h 2021-05-14 10:42:08.000000000 +0200
+++ b/gcc/config/aarch64/aarch64.h 2021-08-10 00:54:13.000000000 +0200
@@ -1013,7 +1013,7 @@
#define MCPU_TO_MARCH_SPEC_FUNCTIONS \
{ "rewrite_mcpu", aarch64_rewrite_mcpu },

-#if defined(__aarch64__)
+#if defined(__aarch64__) && ! defined(__APPLE__)
extern const char *host_detect_local_cpu (int argc, const char **argv);
#define HAVE_LOCAL_CPU_DETECT
# define EXTRA_SPEC_FUNCTIONS \
30 changes: 30 additions & 0 deletions patches/gcc-9.2.0/0020-apple-silicon.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff -ru a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c
--- a/gcc/config/host-darwin.c 2019-01-01 13:31:55.000000000 +0100
+++ b/gcc/config/host-darwin.c 2021-08-07 19:21:05.000000000 +0200
@@ -22,6 +22,8 @@
#include "coretypes.h"
#include "diagnostic-core.h"
#include "config/host-darwin.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"

/* Yes, this is really supposed to work. */
static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096)));
@@ -75,3 +77,5 @@

return ret;
}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff -ru a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
--- a/gcc/config/aarch64/aarch64.h 2019-07-05 17:06:11.000000000 +0200
+++ b/gcc/config/aarch64/aarch64.h 2021-08-10 00:56:32.000000000 +0200
@@ -1049,7 +1049,7 @@
#define MCPU_TO_MARCH_SPEC_FUNCTIONS \
{ "rewrite_mcpu", aarch64_rewrite_mcpu },

-#if defined(__aarch64__)
+#if defined(__aarch64__) && ! defined(__APPLE__)
extern const char *host_detect_local_cpu (int argc, const char **argv);
#define HAVE_LOCAL_CPU_DETECT
# define EXTRA_SPEC_FUNCTIONS \
30 changes: 30 additions & 0 deletions patches/gcc-9.4.0/0020-apple-silicon.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff -ru a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c
--- a/gcc/config/host-darwin.c 2021-04-08 13:56:28.000000000 +0200
+++ b/gcc/config/host-darwin.c 2021-04-20 23:05:04.000000000 +0200
@@ -22,6 +22,8 @@
#include "coretypes.h"
#include "diagnostic-core.h"
#include "config/host-darwin.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"

/* Yes, this is really supposed to work. */
/* This allows for a pagesize of 16384, which we have on Darwin20, but should
@@ -78,3 +80,5 @@

return ret;
}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff -ru a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
--- a/gcc/config/aarch64/aarch64.h 2021-06-01 09:53:04.000000000 +0200
+++ b/gcc/config/aarch64/aarch64.h 2021-08-10 00:58:25.000000000 +0200
@@ -1083,7 +1083,7 @@
#define MCPU_TO_MARCH_SPEC_FUNCTIONS \
{ "rewrite_mcpu", aarch64_rewrite_mcpu },

-#if defined(__aarch64__)
+#if defined(__aarch64__) && ! defined(__APPLE__)
extern const char *host_detect_local_cpu (int argc, const char **argv);
#define HAVE_LOCAL_CPU_DETECT
# define EXTRA_SPEC_FUNCTIONS \

0 comments on commit a558d3a

Please sign in to comment.