'_Atomic' does not name a type: GCC8 should be updated/patched

(gdolsson) #1

So I am trying to compile some software using gcc under macOS 10.14.4 (Xcode 10.2) that apparently depends on c+±11 (I think) and this does not work with the homebrew version of gcc8 (8.3) that I am trying to use. My compilation breaks with the following error:

CXX StringRoutines.cpp
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/sysctl.h:83,
from StringRoutines.cpp:14:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/ucred.h:94:2: error: '_Atomic' does not name a type
_Atomic u_long cr_ref; /* reference count */
^~~~~~~
make[4]: *** [StringRoutines.o] Error 1
make[3]: *** [install] Error 2
make[2]: *** [build_cpptraj] Error 2
make[1]: *** [serial] Error 2
make: *** [install] Error 2

I did some digging around and found that this issue arises from compiling GCC on macOS due to some headers or something. Apparently this should be resolved by applying this patch though this was not the case for me.

Trying to build gcc8 produces this error even after patching for me:

In file included from /usr/include/sys/sysctl.h:83,
                 from ../../gcc/config/darwin-driver.c:30:
/usr/include/sys/ucred.h:94:2: error: ‘_Atomic’ does not name a type
  _Atomic u_long          cr_ref;  /* reference count */
  ^~~~~~~
make[3]: *** [darwin-driver.o] Error 1
make[3]: *** Waiting for unfinished jobs....
rm gcc.pod gfortran.pod
make[2]: *** [all-stage2-gcc] Error 2
make[1]: *** [stage2-bubble] Error 2
make: *** [all] Error 2

Anyone else having any issues and potentially a solution?

Best regards
// Gustaf

4 Likes

(R) #2

I’m currently having exactly the same issue and have not yet found a solution

0 Likes

(gdolsson) #3

This really sucks, wish I’d become a coder/programmer instead of a chemist right now.

0 Likes

(Jeliashi) #4

I fixed this by installing the latest version of xcode CLT:
https://developer.apple.com/download/more/

Search for: “Command Line Tools (macOS 10.14) for XCode 10.2” and install the subsequent .dmg file

AFTER:
run
$brew install gcc

and then all should be good… I hope

2 Likes

(gdolsson) #5

Sorry friend, no luck for me.

I was under the impression that the CLTs were updated along with Xcode and this seems to be the case as I was forced to re-install the missing header files after upgrading to Xcode 10.2.

Reinstalling GCC8 after re-installing the CLTs sadly makes no difference on compiling the modelling software and I have not yet tried to build GCC8 from source so I can’t really say if this makes a difference.

0 Likes

#6

Same problem. It’s pretty frustrating as I can’t build certain libraries or gcc itself.

0 Likes

(gdolsson) #7

Well, it seems that this issue is gaining some momentum at least:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89864

Problem is that there seems to be no simple solution to this issue rather than downgrading to Xcode 10.0/10.1 at the moment.

0 Likes

(Izaak Beekman) #8

I was just bitten by this as well. I’ll see about patching GCC.

0 Likes

(Izaak Beekman) #9

OK, nm, they’re still debating appropriate patches. We’ll have to wait until they finish.

0 Likes

(Akikazu Yoshikawa) #10

Hi,

I succeeded to install current gcc formula by applying Iain Sandoe’s patch:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89864#c43

Unfortunately, this patch couldn’t be applied directly in current gcc formula.
So, I applied it manually and I publish the patched gcc formula repository.

You can install this patched gcc by:

brew tap androidports/patch

and

brew install androidports/patch/gcc

0 Likes

(gdolsson) #11

Sorry for potentially asking a dumb question though I just want to make sure I get it. Did compile gcc from source or do you mean that this patch applies directly to the installed binary version of gcc8.3 via homebrew?

I’m asking since brew installing gcc8.3 was never an issue for me rather trying to compile c++/g++ code using the brew installed version of gcc8.3 (as well as gcc5, 6 and 7).

0 Likes

(Akikazu Yoshikawa) #12

Hi,

Did compile gcc from source or do you mean that this patch applies directly to the installed binary version of gcc8.3 via homebrew?

I mean I apply this patch to source code version of gcc of homebrew.
Sorry, I might misunderstand what you want.

If you installed binary version of gcc via homebrew, you don’t need this patch.

0 Likes

(gdolsson) #13

Well hold on, that might be exactly what I need. So apply the patch and compile from source using homebrew?

If that compilation of GCC8 using macOS clang works then maybe the “_Atomic” error goes away? So remove the binary version, get the source version, apply patch and compile?

0 Likes

(Akikazu Yoshikawa) #14

Yes, that’s right. “_Atomic” error goes away in gcc compilation with macOS clang.

0 Likes

(gdolsson) #15

Fantastic, then this should theoretically also make the same error go away when compiling >c++11 code using gcc8.3 after applying the patch.

So after removing the binary version of gcc I tap and “install”/apply the patch, then I make a “brew install from source”. If this is a correct assumption then could I please trouble you for a command sequence to successfully replicate your fix?

0 Likes

(Akikazu Yoshikawa) #16

then this should theoretically also make the same error go away when compiling >c++11 code using gcc8.3 after applying the patch.

Sorry, I don’t know this will go away or not because I don’t know the difference between binary version and source version of gcc.

0 Likes

(gdolsson) #17

So after applying/installing the patch, how do I install the working version of gcc8?

0 Likes

(Bruno Senjean) #18

Hi. I got the exact same problem. Running the two commands of @akikazu

worked for me, it installed gcc-8.3 correctly. Note that I got an error at one point:

==> Installing gcc from androidports/patch
==> Downloading https://homebrew.bintray.com/bottles-patch/gcc-8.3.0.mojave.bottle.tar.gz
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource “gcc”
Download failed: https://homebrew.bintray.com/bottles-patch/gcc-8.3.0.mojave.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading …

0 Likes

(gdolsson) #19

This is what I would have expected to happen, meaning that you are not using a pre-compiled binary version of gcc but rather recompiling the patched version from source. This is not what happens for me:

Warning: androidports/patch/gcc 8.3.0 is already installed and up-to-date
To reinstall 8.3.0, run `brew reinstall gcc`

I then proceed to download without any issues and the binary version is installed:

==> Reinstalling gcc
==> Downloading https://homebrew.bintray.com/bottles/gcc-8.3.0.mojave.bottle.tar.gz

I did uninstall and clean my cache, proceeding to re-install gcc8 however I only get the binary version and it still presents the exact same error when trying to compile. This is why I was pushing for details regarding how to force a recompilation from source rather than just installing a binary version.

The issue I’m having is not that I cannot install gcc8.3 using homebrew, which has never been a problem. The issue is that I cannot compile the same code that I was able to compile before updating to Xcode 10.2 as I get the previously mentioned error.

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/sysctl.h:83,
                 from StringRoutines.cpp:14:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/ucred.h:94:2: error: '_Atomic' does not name a type
  _Atomic u_long          cr_ref;  /* reference count */
  ^~~~~~~
make[4]: *** [StringRoutines.o] Error 1
make[3]: *** [install] Error 2
make[2]: *** [build_cpptraj] Error 2
make[1]: *** [serial] Error 2
make: *** [install] Error 2

Best regards
// Gustaf

0 Likes

(Izaak Beekman) #20

Hi @gdolsson,

You need to use @akikazu’s tap, and then install from source using the commands he posted. I will test his patch, and open a PR to merge it into Homebrew and revision bump GCC so that it will get pulled in to the binary bottles that users install. If you don’t want to wait for an official fix, you can try out @akikazu’s tap and patch with:

brew tap androidports/patch
brew install -s androidports/patch/gcc

You may need to uninstall or unlink gcc first… BUT I would recommend you wait for the official fix to get merged in, which should happen soon.

@akikazu: Welcome and thanks for the patch!

0 Likes