Skip to content

Instantly share code, notes, and snippets.

@eschnett
Created March 28, 2019 22:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eschnett/f912c6b791e29c83477575017271db16 to your computer and use it in GitHub Desktop.
Save eschnett/f912c6b791e29c83477575017271db16 to your computer and use it in GitHub Desktop.
Make gcc 8.3.0 build on MacOS 10.14.4
diff -ruN gcc-8.3.0-old/fixincludes/fixincl.x gcc-8.3.0/fixincludes/fixincl.x
--- gcc-8.3.0-old/fixincludes/fixincl.x 2018-02-22 11:12:26.000000000 -0500
+++ gcc-8.3.0/fixincludes/fixincl.x 2019-03-28 15:59:33.000000000 -0400
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed February 22, 2018 at 03:46:51 PM by AutoGen 5.18
+ * It has been AutoGen-ed March 28, 2019 at 03:59:33 PM by AutoGen 5.18.16
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Feb 22 15:46:51 UTC 2018
+/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Mar 28 15:59:33 EDT 2019
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -15,7 +15,7 @@
* certain ANSI-incompatible system header files which are fixed to work
* correctly with ANSI C and placed in a directory that GNU C will search.
*
- * This file contains 249 fixup descriptions.
+ * This file contains 250 fixup descriptions.
*
* See README for more information.
*
@@ -2584,6 +2584,50 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
+ * Description of Darwin_Ucred__Atomic fix
+ */
+tSCC zDarwin_Ucred__AtomicName[] =
+ "darwin_ucred__Atomic";
+
+/*
+ * File name selection pattern
+ */
+tSCC zDarwin_Ucred__AtomicList[] =
+ "sys/ucred.h\0";
+/*
+ * Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_Ucred__AtomicMachs[] = {
+ "*-*-darwin18.5.*",
+ (const char*)NULL };
+
+/*
+ * content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_Ucred__AtomicSelect0[] =
+ "_Atomic";
+
+#define DARWIN_UCRED__ATOMIC_TEST_CT 1
+static tTestDesc aDarwin_Ucred__AtomicTests[] = {
+ { TT_EGREP, zDarwin_Ucred__AtomicSelect0, (regex_t*)NULL }, };
+
+/*
+ * Fix Command Arguments for Darwin_Ucred__Atomic
+ */
+static const char* apzDarwin_Ucred__AtomicPatch[] = {
+ "wrap",
+ "\n\
+#if defined(__cplusplus) && __cplusplus >= 201103L\n\
+# define _Atomic volatile\n\
+#endif\n",
+ "\n\
+#if defined(__cplusplus) && __cplusplus >= 201103L\n\
+# undef _Atomic\n\
+#endif\n",
+ (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
* Description of Darwin_9_Long_Double_Funcs_2 fix
*/
tSCC zDarwin_9_Long_Double_Funcs_2Name[] =
@@ -10099,9 +10143,9 @@
*
* List of all fixes
*/
-#define REGEX_COUNT 287
+#define REGEX_COUNT 288
#define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT 249
+#define FIX_COUNT 250
/*
* Enumerate the fixes
@@ -10168,6 +10212,7 @@
CTRL_QUOTES_USE_FIXIDX,
CXX_UNREADY_FIXIDX,
DARWIN_AVAILABILITYINTERNAL_FIXIDX,
+ DARWIN_UCRED__ATOMIC_FIXIDX,
DARWIN_9_LONG_DOUBLE_FUNCS_2_FIXIDX,
DARWIN_EXTERNC_FIXIDX,
DARWIN_GCC4_BREAKAGE_FIXIDX,
@@ -10664,6 +10709,11 @@
DARWIN_AVAILABILITYINTERNAL_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aDarwin_AvailabilityinternalTests, apzDarwin_AvailabilityinternalPatch, 0 },
+ { zDarwin_Ucred__AtomicName, zDarwin_Ucred__AtomicList,
+ apzDarwin_Ucred__AtomicMachs,
+ DARWIN_UCRED__ATOMIC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aDarwin_Ucred__AtomicTests, apzDarwin_Ucred__AtomicPatch, 0 },
+
{ zDarwin_9_Long_Double_Funcs_2Name, zDarwin_9_Long_Double_Funcs_2List,
apzDarwin_9_Long_Double_Funcs_2Machs,
DARWIN_9_LONG_DOUBLE_FUNCS_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff -ruN gcc-8.3.0-old/fixincludes/inclhack.def gcc-8.3.0/fixincludes/inclhack.def
--- gcc-8.3.0-old/fixincludes/inclhack.def 2018-02-22 11:12:26.000000000 -0500
+++ gcc-8.3.0/fixincludes/inclhack.def 2019-03-28 15:59:18.739714124 -0400
@@ -1268,6 +1268,36 @@
};
/*
+ * macOS 10.14.4 <sys/ucred.h> uses the C _Atomic keyword in C++ code.
+ */
+fix = {
+ hackname = darwin_ucred__Atomic;
+ mach = "*-*-darwin18.5.*";
+ files = sys/ucred.h;
+ select = "_Atomic";
+
+ c_fix = wrap;
+
+ c_fix_arg = <<- _EOArg_
+
+ #if defined(__cplusplus) && __cplusplus >= 201103L
+ # define _Atomic volatile
+ #endif
+
+ _EOArg_;
+
+ c_fix_arg = <<- _EOArg_
+
+ #if defined(__cplusplus) && __cplusplus >= 201103L
+ # undef _Atomic
+ #endif
+
+ _EOArg_;
+
+ test_text = "#include <sys/sysctl.h>\n";
+};
+
+/*
* For the AAB_darwin7_9_long_double_funcs fix to be useful,
* you have to not use "" includes.
*/
diff -ruN gcc-8.3.0-old/gcc/config/darwin-driver.c gcc-8.3.0/gcc/config/darwin-driver.c
--- gcc-8.3.0-old/gcc/config/darwin-driver.c 2018-01-03 05:03:58.000000000 -0500
+++ gcc-8.3.0/gcc/config/darwin-driver.c 2019-03-28 16:05:19.856598766 -0400
@@ -27,7 +27,9 @@
#include "diagnostic-core.h"
#ifndef CROSS_DIRECTORY_STRUCTURE
+#define _Atomic volatile
#include <sys/sysctl.h>
+#undef _Atomic
#include "xregex.h"
static char *
@simonranjith
Copy link

Hi,
How do you use this patch file? From the link below I see that you need to apply this patch to the source code of GCC. But how?
https://apple.stackexchange.com/questions/355049/compilation-error-with-mojave-error-atomic-does-not-name-a-type/355103

Could you give me the steps please? Thanks.

@dehengxu
Copy link

Hi,
How do you use this patch file? From the link below I see that you need to apply this patch to the source code of GCC. But how?
https://apple.stackexchange.com/questions/355049/compilation-error-with-mojave-error-atomic-does-not-name-a-type/355103

Could you give me the steps please? Thanks.

  1. you download this path content into a file , as named: gcc_10.14.4.diff
  2. get into gcc-8.3.0 directory, input git apply path/to/gcc_10.14.4.diff

@fqassemi
Copy link

fqassemi commented Aug 6, 2019

I have the very same problem with the recent Mojave installation. It is 10.14.5 version. I have changed all the 10.14.4 to 10.14.5 and changed darwin18.5. to darwin18.6 but it does not work yet! It says fixincludes/fixincl.x: patch does not apply. Any comment/suggestion is appreciated.

@deadmarshal
Copy link

deadmarshal commented Feb 6, 2022

I did this command in the root folder of gcc:
git apply ~/headers-10.14.4-fix.path
errors on MacOS Mojave 10.14.6:
error: patch failed: fixincludes/fixincl.x:2
error: fixincludes/fixincl.x: patch does not apply
error: patch failed: fixincludes/inclhack.def:1268
error: fixincludes/inclhack.def: patch does not apply
error: gcc/config/darwin-driver.c: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment