Issues with compiler flags in gfortran

Ken Cunningham ken.cunningham.webuse at gmail.com
Tue Jan 22 06:08:01 UTC 2019


On 2019-01-21, at 9:22 PM, Joshua Root wrote:

> On 2019-1-22 01:47 , Nicolas Pavillon wrote:
>> I then tried with another gfortran compiler outside of macports, and it
>> could compile without any issue if I remove macports’ prefix from the
>> path, which seems to indicate that the issue is coming from the
>> assembler in macports.
> 
> So this means that gfortran is using whatever assembler it happens to
> find first in $PATH? That seems undesirable. Is there not a way to
> configure it to always use a particular assembler?
> 
> - Josh


MacPorts cctools assembler is /opt/local/bin/as, which is the same as Xcode's assembler. 

if you extract the cctools source and look in the as/driver.c file, you will see that it has two behaviours.

On older systems, by default it runs the ancient gnu as 1.38, which can't do much. 

On newer systems, or if certain flags are set, it runs the "clang" that is **next to it**. 

If you invoke clang directly, you get the assembler associated with that clang.

You have to be careful what you select.  See below.

$ which as
/opt/local/bin/as

$ as -v
Apple Inc version cctools-921, GNU assembler version 1.38

$ sudo port select clang
Available versions for clang:
	mp-clang-3.4
	mp-clang-3.7
	mp-clang-3.8
	mp-clang-3.9 (active)
	mp-clang-4.0
	mp-clang-5.0
	mp-clang-7.0
	none

$ AS_INTEGRATED_ASSEMBLER=1 as -v
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-3.9/bin

$ sudo port select clang mp-clang-7.0
Selecting 'mp-clang-7.0' for 'clang' succeeded. 'mp-clang-7.0' is now active.

$ sudo port select clang
Available versions for clang:
	mp-clang-3.4
	mp-clang-3.7
	mp-clang-3.8
	mp-clang-3.9
	mp-clang-4.0
	mp-clang-5.0
	mp-clang-7.0 (active)
	none

$ AS_INTEGRATED_ASSEMBLER=1 as -v
clang version 7.0.1 (tags/RELEASE_701/final)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-7.0/bin

$ sudo port select clang none
Selecting 'none' for 'clang' succeeded. 'none' is now active.

$ AS_INTEGRATED_ASSEMBLER=1 as -v
as: assembler (/opt/local/bin/clang) not installed

The xcode variant of as replaces "as" with a script that calls xcrun to send the command to Xcode's installed as, which then sends it to Xcode's clang (which is installed beside Xcode's "as", so it gets called)..

$ xcrun -find as
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as

$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as -v
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1as -triple x86_64-apple-macosx10.14.0 -filetype obj -main-file-name - -target-cpu penryn -fdebug-compilation-dir /Users/cunningh -dwarf-debug-producer Apple LLVM version 10.0.0 (clang-1000.11.45.5) -dwarf-version=4 -mrelocation-model pic -o a.out -



Ken





More information about the macports-dev mailing list