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
#!/bin/bash case "$4" in "") echo $INTEL_OSXSDK_VER;; *) echo $INTEL_OSXSDK_PATH;; esac
Now save the script above as ~/bin/xcodebuild and give it execute permission.
Finally, make your ~/bin path come BEFORE other system paths
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.