Opened 2 years ago

Last modified 17 months ago

#64694 new request

gcc/libgcc: update older systems prior to 10.6 to a newer gcc version?

Reported by: barracuda156 Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: leopard tiger Cc: cooljeanius (Eric Gallager), cjones051073 (Chris Jones)
Port: libgcc, gcc10

Description

Now having gcc10 being able to build for ppc in Macports thanks to @catap efforts, a question is how to configure libgcc properly so that everything works.

When I tried to build gcc10 earlier on Leopard, I faced errors with C++ compiler: https://trac.macports.org/ticket/64577 I am getting the same errors now with gcc10: library not found for -lgcc_s.1.1.

Is it something with the way gcc10 is built or the way Macports is handling libgcc? gcc10-bootstrap has no problems.

Change History (14)

comment:1 Changed 2 years ago by kencu (Ken)

Keywords: tiger added; powerpc ppc gcc removed
Summary: libgcc: how to reconfigure for gcc10 on older systems?gcc/libgcc: update older systems prior to 10.6 to a newer gcc version?
Type: defectrequest

comment:2 Changed 2 years ago by kencu (Ken)

I updated SnowLeopard to a newer gcc/libgcc default last year once the gcc11 build was smooth on that system.

gcc / libgcc will likely be able to be updated to gcc11 on Tiger and Leopard as well once things settle down with the gcc10-bootstrap port that is required to build it.

It's not just one missing link library here or there -- it's a whole infrastructure that needs to be upgraded properly.

Someone (most likely Evan the way things are going lately) will then sit down with the entire system and work out all the many issues that will no doubt come up, and push the whole thing once it is all fixed.

comment:3 in reply to:  2 Changed 2 years ago by barracuda156

Replying to kencu:

I updated SnowLeopard to a newer gcc/libgcc default last year once the gcc11 build was smooth on that system.

gcc / libgcc will likely be able to be updated to gcc11 on Tiger and Leopard as well once things settle down with the gcc10-bootstrap port that is required to build it.

It's not just one missing link library here or there -- it's a whole infrastructure that needs to be upgraded properly.

Someone (most likely Evan the way things are going lately) will then sit down with the entire system and work out all the many issues that will no doubt come up, and push the whole thing once it is all fixed.

Aha, okay, thank you. So it is not a problem of gcc10 per se, am I right? (So rebuilding it won't help.)

  1. S. For others' reference, gcc10-bootstrap builds and works on 10.6 PPC without failure (like it also does on 10.5.8): https://github.com/macports/macports-ports/pull/13995#issuecomment-1045720767

comment:4 Changed 2 years ago by kencu (Ken)

BTW -- gcc10 and gcc10-bootstrap on 10.6 PPC will build but be broken just like all the gcc versions unless you went through that special patchset I came up with for gcc7 and tweak it up for gcc10.

comment:5 in reply to:  4 Changed 2 years ago by barracuda156

Replying to kencu:

BTW -- gcc10 and gcc10-bootstrap on 10.6 PPC will build but be broken just like all the gcc versions unless you went through that special patchset I came up with for gcc7 and tweak it up for gcc10.

Yes, I did that of course. You actually saw my patch for gcc10 in Iains thread, and yes, it’s 90% your patch from gcc7 adapted to gcc10.

The only difference is that Macports gcc10 now uses Iain’s patches involving same places of the code among others. So in order to avoid a conflict, existing patches have to be changed.

Last edited 2 years ago by barracuda156 (previous) (diff)

comment:6 in reply to:  4 Changed 2 years ago by barracuda156

Replying to kencu:

BTW -- gcc10 and gcc10-bootstrap on 10.6 PPC will build but be broken just like all the gcc versions unless you went through that special patchset I came up with for gcc7 and tweak it up for gcc10.

Do I get it correctly that moving to libgcc11 should be instead less painful, since it is set as default for 10.6 normally anyway?

36-72% port -v installed libgcc11
The following ports are currently installed:
  libgcc11 @11.2.0_3 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-09T07:19:42+0800'
36-72% port -v installed gcc11
The following ports are currently installed:
  gcc11 @11.2.0_3 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-09T01:38:58+0800'
36-72% port -v installed libgcc
The following ports are currently installed:
  libgcc @5.0_0 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-03-09T07:26:11+0800'

  1. S. After building libgcc11 I had to deactivate libgcc7, and trying activate it back results in:
36-72% sudo port activate libgcc7
Warning: configured user/group macports does not exist, will build as root
--->  Computing dependencies for libgcc7
--->  Activating libgcc7 @7.5.0_1
Error: Failed to activate libgcc7: Image error: /opt/local/include/gcc/c++/algorithm is being used by the active libgcc11 port.  Please deactivate this port first, or use 'port -f activate libgcc7' to force the activation.
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_libgcc7-7.5.0_1_5dd4ca996c44932720b515e198a68fea5a0470b6cb5a83ba7ca31d6877e2d1b1-16766/libgcc7/main.log for details.
Warning: Failed to execute portfile from registry for libgcc7 @7.5.0_1
--->  Activating libgcc7 @7.5.0_1
Error: port activate failed: Image error: /opt/local/include/gcc/c++/algorithm is being used by the active libgcc11 port.  Please deactivate this port first, or use 'port -f activate libgcc7' to force the activation.

Are they inherently incompatible or I should just change a setting somewhere? I have rebuilt libgcc port.

comment:7 Changed 2 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:8 Changed 22 months ago by cjones051073 (Chris Jones)

The way things are set up for gcc in macports is a little involved, primarily due to the fact we want there to be a single runtime that is hared by all gcc compilers. This leads to slightly more complex logic in a number of places, than just a single version set somewhere.

The first place to look is in the libgcc port, that is what proves the primary runtime. It is though just a shim port that sets a dep on a specific versioned libgccX based on the os versio. See

https://github.com/macports/macports-ports/blob/82071e70dd05d0afd94b2d02b9801ca894eebd32/lang/libgcc/Portfile#L31

Then, you need to look in the port files for the gcc version listed above, which are gcc12 for most system, and gcc7 for the really old ones.

So, if someone wanted to migrate the old oses from using gcc7 as its primary runtime, to something else, you would need to first update the libgcc7 port, removing the logic to decide if its a primary or secondary runtime provider, making it a secondary for all, and move that logic into the gcc version you want to become the new primary runtime. See eg.

https://github.com/macports/macports-ports/blob/82071e70dd05d0afd94b2d02b9801ca894eebd32/lang/gcc7/Portfile#L40

There is probably a few other little details I have forgotten about… i have to remind myself how to do the migration each time i add a new major version, and migrate libgcc to use it.

I am not going to do the above myself, i do not have the time but more importantly no means to test on OSX10.5 or older. But hopefully if someone else is interested the above would give them a starting point to make the changes ..

comment:9 Changed 22 months ago by cjones051073 (Chris Jones)

Cc: cjones051073 added

comment:10 in reply to:  8 Changed 22 months ago by barracuda156

Replying to cjones051073:

I am not going to do the above myself, i do not have the time but more importantly no means to test on OSX10.5 or older. But hopefully if someone else is interested the above would give them a starting point to make the changes

Thank you for guidelines!

It looks that gcc12 is building fine for PPC – I am building 12.1.0 now on 10.6.8 via Rosetta, libgcc12 built successfully, gcc12 in the process. If that succeeds, I am mostly sure 10.5.8 will work too (after all, Iain tests both ppc and ppc64 on Darwin). Cosmetic changes in the portfile will be needed: make a default variant supporting libcxx conditional (until it is tested on PPC and confirmed to work), remove a ban for older systems and gcc-4.2 (which leads to an error otherwise), specify gcc10-bootstrap as a dependency on PPC. (The latter gonna actually fail on Rosetta, but for most of users Leopard is the only concern.)

So apparently everything gonna work, as it is working with gcc11, for three PPC configurations: 10.5.8 (ppc + ppc64), 10A190 (ppc) and 10.6.8 (ppc via Rosetta).

What I am yet to do is to fix gcc7 port logic, so that the whole procedure does not leave gcc7 broken.

comment:11 Changed 22 months ago by kencu (Ken)

gcc10-bootstrap will be able to build the current libgcc on all systems where the system can’t build it.

It is not yet finished, and there’s a PR up for it. That is the reason this has not been done already.

Once it is finished, the upgrade is not difficult; copy the steps I took to upgrade 10.6 to the current libgcc last year. One hour, max.

gcc7 is not currently broken and I believe doesn’t need any fixing. It will be handled by the migration to libgcc12.

Part of the reason gcc10-bootstrap is not finished is many questions about 10.6-on-PPC etc. If we can just focus on one-step-at-a-time, progress might be forthcoming. catap I think threw in the towel at a certain point. Let him get it working on the easier systems first, then everything upgrades, then we can see about offbeat stuff like rosetta on SnowLeopard and 10.6-on-PPC.

IMHO.

comment:12 in reply to:  11 Changed 22 months ago by barracuda156

Replying to kencu:

gcc10-bootstrap will be able to build the current libgcc on all systems where the system can’t build it. It is not yet finished, and there’s a PR up for it. That is the reason this has not been done already. Once it is finished, the upgrade is not difficult; copy the steps I took to upgrade 10.6 to the current libgcc last year. One hour, max.

I will look at the port history to find those, thank you!

gcc7 is not currently broken and I believe doesn’t need any fixing. It will be handled by the migration to libgcc12.

I might have formulated it incorrectly. What I mean is that once I moved to gcc11 and libgcc provided by libgcc11 (on Leopard and SL), gcc7 stopped working correctly, since its libgcc7 is not there under libgcc port anymore. Fair enough, it may not be “broken”, but require re-building libgcc7 or something else. But some extra step is needed, apparently.

Part of the reason gcc10-bootstrap is not finished is many questions about 10.6-on-PPC etc. If we can just focus on one-step-at-a-time, progress might be forthcoming. catap I think threw in the towel at a certain point. Let him get it working on the easier systems first, then everything upgrades, then we can see about offbeat stuff like rosetta on SnowLeopard and 10.6-on-PPC.

I will discuss it with @catap, we are in touch. But in any case, Leopard is to be prioritized over any other PPC configurations, no questions about that.

comment:13 in reply to:  11 Changed 22 months ago by barracuda156

Replying to kencu:

One thing which I forgot to mention. There may be a problem on Leopard if ld64-127 is being used – at least I had a case of gcc11 build failing with it: https://forums.macrumors.com/threads/gcc11-on-10-5-8-10-6-ppc-and-10-6-8-rosetta-it-works.2330521/?post=31125610#post-31125610 (unfortunately, I do not remember which exactly system was that, but likely 10.5.8 ppc64).

Eventually, I began using ld64-97 on all systems, which so far works perfectly for ppc and ppc64 both. It can also be built against llvm5 (which may or may not give any benefit, but at least doesn’t hurt, apparently).

comment:14 Changed 17 months ago by barracuda156

PR to move 10.5 to using new libgcc: https://github.com/macports/macports-ports/pull/16843

Note: See TracTickets for help on using tickets.