Opened 2 hours ago

#71356 new defect

New linker in Command Line Tools 16 not working with fortran BLOCK DATA

Reported by: luillo76 Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: gcc

Description

Hello,

We've encountered a critical issue with the new linker of CLT16 (version 16.1.0.0.1.1729049160) that prevents proper initialization of BLOCK DATA in Fortran code. This affects software built with the Macports-provided GNU gcc13 compiler.

BLOCK DATA are used to initialize global variables, and its failure to initialize those variables leads to a program crash.

The current workaround is using the -ld_classic linker option. However, this option is deprecated and will be removed in a future release, as described in the Xcode release note https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes#Linking.

I've attached a minimal example that reproduces the problem using GNU gcc13 with the following instructions:

gfortran -c bd.f
gfortran -c main.f

ar rv libtest.a bd.o main.o

gfortran -ld_classic -o good.x -L. libtest.a
gfortran -o bad.x -L. libtest.a

Running the two programs, one can see that the BLOCK DATA are not initialised without the option ld_classic,

$ > ./good.x 
   3.7273802569289098        2.8083922366048202     
$ > ./bad.x 
   0.0000000000000000        0.0000000000000000

I'm not sure if this is directly related to Macports, but I suspect it might be connected to how Macports builds GCC. Has anyone else encountered this issue? Are there any known workarounds within the Macports environment?

Thanks.

Attachments (3)

bd.f (143 bytes) - added by luillo76 2 hours ago.
main.f (85 bytes) - added by luillo76 2 hours ago.
part.inc (96 bytes) - added by luillo76 2 hours ago.

Download all attachments as: .zip

Change History (3)

Changed 2 hours ago by luillo76

Attachment: bd.f added

Changed 2 hours ago by luillo76

Attachment: main.f added

Changed 2 hours ago by luillo76

Attachment: part.inc added
Note: See TracTickets for help on using tickets.