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

Slow compilation on macOS*


Problem:  Intel compilers on macOS Catalina, Big Sur is slow compared to Linux or Windows.


The slowness is due to ifort/icc/icpc drivers calling 'xcodebuild' twice, once to determine the SDK version, the second to find the SDK path.  the exact calls are:

xcodebuild -sdk macosx -version | grep SDKVersion

xcodebuild -sdk macosx -version Path


time those on Catalina and Big Sur.  Not speedy are they? If you have older macOS versions you will find these commands are very very much fasters.  We have a bug report into Apple on this since last year.   Interestingly if you have macOS from like 3 to 4 versions ago these commands fly in a fraction of a second.  OK nothing we can do about that that we haven't already done (bug report).  
But I have a hack workaround

First step, define 2 env vars for the results of those 2 calls:

INTEL_OSXSDK_VER=`xcodebuild -sdk macosx -version | grep SDKVersion`
INTEL_OSXSDK_PATH=`xcodebuild -sdk macosx -version Path`


Next, we write our own 'override' version of 'xcodebuild' as a script file with execute permissions

case "$4" in
      echo $INTEL_OSXSDK_VER;;
      echo $INTEL_OSXSDK_PATH;;

Now save the script above as ~/bin/xcodebuild and give it execute permission.

Finally, make your ~/bin path come BEFORE other system paths


export PATH=/Users/myUserName/bin:${PATH}

 and there you have it.  'ifort' and 'icc' drivers will now fly like the wind.  For me, I put the 3 'export' statements in my ~/.bashrc and made sure my ~/.bash_profile sources ~/.bashrc


This is a workaround until xcodebuild is fixed to run fast again (if ever).  We're looking at perhaps having the Intel compiler drivers look for those 2 INTEL_OSSDK_* variables and if they exist, use those instead of calling xcodebuild. 

3 Replies

Is this still a problem under Monterey? Thanks!

0 Kudos

I am NOT seeing slow compilation on Monterey.  But I only have the Xcode command line tools, not a full Xcode installation.  I tested with

ifort -V

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.8.0 Build 20221120_000000

Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.


It's possible we changed the ifort driver to speed things up.  a year or so back there was an internal group looking at the driver on macOS and we came up with a solution using the command line utilities instead of Xcode.  Possible we put that in the 2021.8 compiler.

0 Kudos

in Monterey, Xcode 14.2, this command

time xcodebuild -sdk macosx -version Path


still take a long time the first time I run it.  then it is quite fast, .7sec.  So I think Apple did something with xcodebuild with XC 14 to improve speed.  Perhaps they cache the Path result??  


In any event, I am seeing much faster compilation on macOS Monterey and XC 14

0 Kudos