Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28593 Discussions

Mac Xcode 15.0: unknown options: -commons

Dave_Allured
New Contributor I
2,635 Views

This is just a heads-up.  Apple just released Xcode 15.0 and related Command Line Tools on 2023 September 18.  This is related to the upcoming Sonoma OS release next week.

It looks like support was dropped in the Apple linker for -commons, a fortran-related linker option that may be needed for some Intel fortran compiles.  Here is a typical error message on Mac:

ld: unknown options: -commons 
clang: error: linker command failed with exit code 1

I have not tested or experienced this error with Intel fortran.  However, I find an old note in HDF5 source code (2017), suggesting that Intel fortran uses this linker and needs -commons in some cases.

4 Replies
sims__james
Beginner
2,006 Views

I just installed the new oneapi Math Kernel Library for macOS version 2023.2.1 

and now I am getting this error message. Any thoughts on how to fix?

0 Kudos
Dave_Allured
New Contributor I
1,944 Views

If your program does not use COMMON or EQUIVALENCE, then I think you can safely remove -commons from your compile command.

 

There is a rumor that the upcoming release of Xcode 15.1 will include linker fixes.  Please treat this as rumor only.  This may or may not solve your problem.

0 Kudos
JeffHammond
Beginner
892 Views

This problem does not affect just COMMON (or EQUIVALENT).  Modern Fortran features with bind(C) are equivalent in the linker.


For example, this line...

integer(c_int), bind(C, name="MPIR_F08_MPI_IN_PLACE"), target :: MPI_IN_PLACE

...compiles to this with ifort, ifx and gfortran on Linux and with gfortran on MacOS (I no longer have an Intel Mac to verify the Intel compilers there):

$ ifx -c extern.F90 && nm extern.o | grep MPI
0000000000000004 C MPIR_F08_MPI_IN_PLACE

The "C" attribute is treated as COMMON even though modern language features are used.

 

This is the relevant text of the Fortran standard:

 

19.5.1.5 Linkage association

Linkage association occurs between a module variable that has the BIND attribute and the C variable with which it interoperates, or between a Fortran common block and the C variable with which it interoperates (18.9). Such association remains in effect throughout the execution of the program.

0 Kudos
Steve_Lionel
Honored Contributor III
870 Views

Clearly, Intel is not going to make any changes for this on Mac, since it no longer offers a Mac compiler. Apple does so like to break things in its updates.

Reply