Known Issue: macOS* Slow Compilation Time

ID 标签 689821
已更新 12/8/2020
版本 Latest
公共

author-image

作者

The following issue affects macOS* C++ and Fortran compilers in the Intel® Parallel Studio and Intel® oneAPI. 

Slow license checkout may lead to slow compilation. If this is your case, please, refer to Intel® Fortran Compiler for macOS* 19.1 Release Notes for Intel® Parallel Studio XE 2020, Known Limitations for more information.

Since renaming xcodebuild* may affect the clang* or gcc* and xcodebuild* you may have on the system, this workaround does not work for you if:
•    you use Xcode* for other projects on the same system 
•    you use Xcode*  build and an Xcode* project file to build a project from the command line

Issue Description 

There is an issue with ifort and icc drivers leading to slow compilation. Both drivers make two calls to xcodebuild* to determine:

  • version of the macOS* platform SDK: /usr/bin/xcodebuild -sdk macosx -version
  • location of the macOS* platform SDK: xcodebuild -sdk macosx -version Path

Run this a few times to account for initial caching and check time: time xcodebuild -sdk macosx -version

Solution

The temporary workaround is to override the /usr/bin/xcodebuild with a user script named xcodebuild that comes earlier in the PATH. Thus, the compiler driver  (ifort or icc) will call this script for those values rather than the original xcodebuild. This temporary workaround will get compilation 10x faster:

# with original xcodebuild
$ time ifort -O0 -o hello hello.f90
 
real 0m3.483s
user 0m0.601s
sys 0m0.852s
 
# with custom xcodebuild
$ time ifort -O0 -o hello hello.f90
 
real 0m0.391s
user 0m0.120s
sys 0m0.254s

 

Follow the following steps to apply the temporary workaround and note that steps 3 and 4 depend on the shell you currently use so you need to do only one of them: 

1. Create a separate bin directory that is not searched by default. For example, the local user's folders or /usr/local/ifort/bin for multi-user systems.

2. Put the following script named xcodebuild in /usr/local/ifort/bin and make it executable calling chmod +x xcodebuild

#!/bin/bash
case "$4" in
"")
echo $INTEL_OSXSDK_VER;;
*)
echo $INTEL_OSXSDK_PATH;;
esac

The script echoes out one of the values in two new ENV vars: INTEL_OSXSDK_VER and INTEL_OSXSDK_PATH so when it's called by xcodebuild -sdk macosx -version the 4th arg is null so echo $INTEL_OSXSDK_VER. Similarly, xcodebuild -sdk macosx -version Path we echo $INTEL_OSXSDK_PATH

 

3. For Bash:

  • To apply for the specific user, set those putting in ~/.bashrc which is sourced from the user’s ~/.bash_profile:
$ cat ~/.bash_profile 
source ~/.bashrc

$ cat ~/.bashrc
export INTEL_OSXSDK_VER=’xcodebuild -sdk macosx -version | grep SDKVersion’
export INTEL_OSXSDK_PATH=’xcodebuild -sdk macosx -version Path’

 

  • To apply the system-wide configuration, use /etc/profile or /etc/bashrc
  • Add your custom bin to PATH to make it available during compilation: export PATH=/usr/local/ifort/bin:${PATH}

   

4.    For ZSH:

  • To apply for the specific user,  set those putting in ~/.zshenv:
$ cat ~/.zshenv
export INTEL_OSXSDK_VER=`xcodebuild -sdk macosx -version | grep SDKVersion`
export INTEL_OSXSDK_PATH=`xcodebuild -sdk macosx -version Path`

 

  • To apply the system-wide configuration, use /etc/zshenv
  • Add your custom bin to PATH to make it available during compilation: export PATH=/usr/local/ifort/bin:$PATH

 

5. Replace /usr/local/ifort/bin by the path to your custom bin created in step 1 if needed.  


As a result, the ifort and icc drivers will find your new xcodebuild FIRST before the one in /usr/bin/xcodebuild. Each new user terminal or login shell, in essence, caches the 1-time call to the /usr/bin/xcodebuild and stores in those 2 ENV vars.

The current situation is considered a defect that will be fixed in a future compiler release.
 

"