miosix-kernel icon indicating copy to clipboard operation
miosix-kernel copied to clipboard

不能在apple M1上成功编译gcc-start

Open losehu opened this issue 1 year ago • 1 comments

According to https://miosix.org/wiki/index.php? title=Building_GCC_from_sources' tips

My step:

  1. xcode-select --install

  2. cc-v

  3. Git clone https://miosix.org/git-public/miosix-kernel.git

  4. cd miosix-kernel

  5. Git fetch origin

  6. git checkout -b testing origin/testing

  7. sh download.sh

  8. sh install-script.sh -j12

Finally, I got:: Error compiling gcc-start

This is my log/e.txt. I would appreciate it if you could help me.

e.txt

Image

losehu avatar Mar 08 '25 09:03 losehu

I had a quick look at the issue, but I don't have access to a mac so I could not try to reproduce it and test solutions. From the log file (thanks! that was helpful) the first error is

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:496:3: error: '__abi_tag__' attribute only applies to structs, variables, functions, and namespaces

Looking online I found https://trac.macports.org/ticket/71137 linking to a useful bug report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111632

It looks like an incompatibility between the source code of GCC and the latest clang/libc++.

Comment 1 in the bug report contains a patch https://gcc.gnu.org/bugzilla/attachment.cgi?id=56010&action=diff that seems not too hard to backport to gcc 9.2.0.

If you feel like trying yourself, you can try backporting it and we could add it together with our patches in the kernel unstable branch (which is where we are working right now).

Alternatively you could use the pre-compiled release of the Miosix compiler https://miosix.org/wiki/index.php?title=Miosix_Toolchain

We also have a pre-compiled release for the apple M1, I suppose compiled before apple updated clang to the version incompatible with GCC's source code.

Finally, we are working on upgrading to a later GCC as we want to support C++20 with Miosix, so in a few months the problem will be gone anyway.

fedetft avatar Mar 09 '25 08:03 fedetft