Project

General

Profile

Preparing a Mac machine for Bilder » History » Revision 83

Revision 82 (John Cary, 11/03/2021 08:09 AM) → Revision 83/109 (David Alexander, 02/23/2022 02:34 PM)

# Preparing a Mac machine for Bilder # 

 *NOTE: as of Catalina, installing in /opt is no longer an option, so we have moved to /usr/local* 

 __If all you need is python and sphinx__ (e.g., for builds of documentation), then you need only 

 * XCode with command line tools 
 * Latex installed as noted below 

 and then you can add the arguments,    -W python, and your installed Python and CMake will be used if your path is correct. 


 ## Bilder on Darwin ## 

 Darwin comes with bash, so it is Bilder ready for the most part. 

 ### OS X Versions ### 

 Yosemite's XCode that supports C++ 11 by default. 

 El Capitan's clang compiler supports OpenMP. 

 ## Case insensitive file system ## 

 We have noted and filed bugs for CMake errors on OS X when using the case-sensitive file system. To fix we use the case-insensitive file system. There may be problems with various packages and the case-insensitive file system. 

 ## C and C++ compilers and Xcode command line tools ## 

 Install Xcode. To obtain version 11.3 (11.x 10.3 (10.x is required for LLVM@12), c++17), visit https://developer.apple.com/xcode/download, then at the bottom third of the page, click on the "Additional Tools" link . Sign in with your Apple ID. Also download   

 ~~~~~~ 
 sudo xcode-select --install 
 ~~~~~~ 

 With mojave, one must additionally open the Command Line Tools to match XCode app and install the version of Xcode that you are getting. The Xcode.app directory that is unpacked by opening the .xip file should be moved to the /Applications/ folder. The Command Line Tools is a DMG that has a PKG installer, so just run that. One must additionally command line tools or execute this command before using any command line tools: command: 

 ~~~~~~ 
 sudo xcodebuild -license installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / 
 ~~~~~~ 

 If you are upgrading from a previous installation you will want/need to run or use the following command graphical interface with 

 ~~~~~~ 
 sudo xcode-select -s /Applications/Xcode.app open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg 
 ~~~~~~ 

 One can check the version of Xcode from the command-line with Not doing this may give you an error like 

 ~~~~~ ~~~~~~ 
 xcodebuild -version In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/system_error:146: 
 /usr/bin/clang --version /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__errc:191:43: error: use of undeclared identifier 'EOWNERDEAD' 
     owner_dead                            = EOWNERDEAD, 
 ~~~~~~ 

 The clang should exact name of the pkg might be version 11.0.0 with Xcode 11.3.1. different in the future. This page https://apple.stackexchange.com/questions/337940/why-is-usr-include-missing-i-have-xcode-and-command-line-tools-installed-moja says it is better to use `xcrun --show-sdk-path` to find the default SDK path and then one can find the exact package name. 

 ## HomeBrew ## 

 One must select a non-OSX package manager for some additional packages. The candidates are HomeBrew, MacPorts, and Fink, with the HomeBrew being our recommendation at this time, as it is active, and it has the philosophy of not building extraneous stuff that is already present on OSX, which MacPorts tends to do, thus using up more disk space.    HomeBrew also installs packages in their own subdirs with links to other places in /usr/local/homebrew, thus making removal a matter removing a directory and then removing broken links in /usr/local/homebrew. 

 HomeBrew requires that one not have root privileges.    So we make the directory into which we can write: 

 ~~~~~~ 
 sudo -s 
 mkdir -p /usr/local/homebrew 
 chgrp -R admin /usr/local/homebrew 
 chmod -R 2775 /usr/local/homebrew 
 mkdir -p /usr/local/opt 
 chgrp -R admin /usr/local/opt 
 chmod -R 2775 /usr/local/opt 
 exit 
 ~~~~~~ 

 and then we work as nonroot: 

 ~~~~~~ 
 cd /usr/local 
 git clone https://github.com/Homebrew/brew.git homebrew 
 ~~~~~~ 

 ~~~~~~ 
 chmod -R a+rX /usr/local/homebrew 
 find /usr/local/homebrew -type l -exec chmod -h a+r '{}' \; 
 ~~~~~~ 

 These last two lines can be reused at anytime there is a permissions problem. 

 As root again execute these lines to pick up some paths in the defaults paths: 

 ~~~~~~ 
 sudo -s 
 echo "/usr/local/homebrew/bin" > /etc/paths.d/homebrew 
 echo "/usr/local/homebrew/share/man" > /etc/manpaths.d/homebrew 
 chmod a+r /etc/paths.d/homebrew /etc/manpaths.d/homebrew 
 exit 
 ~~~~~~ 

 Get various packages... 

 ~~~~~~ 
 brew install subversion gnupg libpng freetype gd ghostscript ninja wget imagemagick 
 ~~~~~~ 

 git large file support (for VisIt) 

 ~~~~~~ 
 brew install git-lfs 
 git lfs install --force --skip-smudge 
 ~~~~~~ 

 For Qt5: 

 ~~~~~~ 
 brew install bison flex gperf libcapn 
 ~~~~~~ 

 Fortran comes with the homebrew gcc compiler: 

 ~~~~~~ 
 brew install gcc 
 ~~~~~~ 

 As of Sep 2021, version 11.2 has been tried with success. 
 However, it does not work an Apple Silicon (M1), so you must instead get it from https://github.com/fxcoudert/gfortran-for-macOS/releases/tag/11-arm-alpha2. 

 OPTIONAL: 

 If you receive an error regarding ruby version: 

 ~~~~~~ 
 brew install ruby@2.3 
 ~~~~~~ 

 may help. 


 ## LaTeX ## 

 Those with sufficient hard drive space (3.4GB after install) may wish to download the full MacTeX package from <http://www.tug.org/mactex/downloading.html>. After installing, one can see the 'README ME FIRST.pdf' in /Applications/Tex. You will likely need to add /usr/texbin to your path: 

 ~~~~~~ 
 setenv PATH /usr/texbin:${PATH}    # For tcsh 
 export PATH=/usr/texbin:${PATH}    # For bash 
 ~~~~~~ 

 For those who like GUIs, the !TeXworks in /Applications/TeX/TeXworks should work fine. 

 For those with limited space, install BasicTeX from <https://tug.org/mactex/morepackages.html>. Add to your PATH: 

 ~~~~~~ 
     /usr/local/texlive/2017/bin/universal-darwin/ 
 ~~~~~~ 

 and then install the packages noted at 

 [[LaTeX packages needed by Bilder]] 

 You may need to use sudo. 

 ~~~~~~ 
 sudo tlmgr update --self 
 sudo tlmgr install <needed packages> 
 ~~~~~~ 

 and then used the autoupdate feature to get any additionally needed packages.    This minimal installation is 230 M instead of the usual 2GB. 


 ## Disable spindump ## 

 for faster compilations via 

 ~~~~~~ 
 sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.spindump.plist 
 ~~~~~~ 

 ## LLVM-Clang ## 

 LLVM-Clang (aka LlvmClang) is different from AppleClang.    It has support for target attributes and openmp, and provides a build chain for high-performance computing.    Check out the llvm-project of your chosen version. 

 We use homebrew to install this with 

 ~~~~~~ 
 brew install llvm@12 llvm 
 ~~~~~~ 

 As of Feb 2022, May 28, 2021, the default llvm version is 13 and that would be probably fine, however 12 is tested and is known to be ok. 12.0.0. 

 ALTERNATIVE 

 If brew does not work (e.g., it is not available for M1), then you can download a release from https://github.com/llvm/llvm-project/releases. 

 To configure and build: 

 ~~~~~~ 
 llvmver=12.0.0 # Correct as needed. 
 tar xf llvmorg-$llvmver.tar.gz 
 cd llvm-project-llvmorg-$llvmver 
 mkdir build 
 cd build 
 cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang;openmp;libcxx;libcxxabi" -DLLVM_ENABLE_RTTI:BOOL=ON -DLLVM_ENABLE_EH:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH="/usr/local/opt/llvm-$llvmver/install" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_NAME_DIR=/usr/local/opt/llvm-$llvmver/install/lib 
 make # Add appropriate -j argument for the machine to build faster 
           # with -j 8 on qamojavellvm the build and installation took a little under an hour 
 make install 
 ~~~~~~ 

 Bilder will look in /opt/llvmclang/bin for llvm binaries (as well as $LLVM_DIR/bin, and your installation dir/bin, in case you need to keep multiple versions for different builds), so we set a link to the installation directory in the chosen version of llvm: 

 ~~~~~~ 
 cd /usr/local/opt 
 sudo ln -s llvm-<Version>/install llvmclang 
 ~~~~~~ 

 ## Java ## 

 You will need to install java by invoking the executable in any way such as... 

 ~~~~~~ 
 java -version 
 ~~~~~~ 

 Follow the instructions in the dialog that takes you to the Oracle website and choose the latest version to download.    (As of March 2021 this is 16.) 

 Chose the macOS installer from 
 https://www.oracle.com/java/technologies/javase-jdk16-downloads.html 

 ## HostName ## 

 For bilder to properly send emails the fully qualified hostname must set on the machine. To check this try... 

 ~~~~~~ 
 hostname -f 
 ~~~~~~ 

 this should return machinename.domainname.com rather than just machinename.    If it does not, then set the hostname of the machine by typing the following commands. 

 ~~~~~~ 
 sudo scutil --set ComputerName "machinename" 
 sudo scutil --set LocalHostName "machinename" 
 sudo scutil --set HostName "machinename.domainname.com" 
 dscacheutil -flushcache 
 ~~~~~~ 

 Restart your Mac after this. 

 ## Power Saving Modes ## 

 For build machines that are not personal machines, disabling certain options will help in connectivity and responsiveness: 

 ~~~~~~ 
 Under Spotlight 
  - disabled the main HD. (multiple mdworkers taking up a lot of cpu.) 
 ~~~~~~ 

 ~~~~~~ 
 Under Energy Saver 
  - Computer sleep: Set to never 
  - Unchecked Put hard disks to sleep when possible 
  - Unchecked Wake for network access 
 ~~~~~~ 

 &nbsp; 
 &nbsp; 
 &nbsp; 
 &nbsp; 
 &nbsp; 
 &nbsp; 
 &nbsp; 
 &nbsp; 
 &nbsp; 
 &nbsp; 

 --- 

 --- 

 ## X11 ## 

 X11 should not be needed, but if it is needed: 

 Install [XQuartz X11](http://xquartz.macosforge.org/landing/). 

 Create a symbolic link so that the X11 headers can be found by the compiler: 

 ~~~~~~ 
 sudo ln -s /opt/X11/include/X11 /usr/local/include/X11 
 ~~~~~~ 

 # DEPRECATED INSTRUCTIONS # 


 ## Other gfortran options (besides HomeBrew) ## 

 ### Option 2: HPC ### 

 Install gfortran from [SourceForge HPC](http://hpc.sourceforge.net).    (Do not also install the other gcc compilers.) 

 As of March 29, 2015, the version is 4.9.0. 

 Install via 

 ~~~~~~ 
 $ tar xzf gfortran-4.9-bin.tar.gz -C / 
 ~~~~~~ 

 ### Option 3: GNU ### 

 Install gfortran using the installer from <http://gcc.gnu.org/wiki/GFortranBinaries>. 

 As of March 29, 2015, the version is 4.9.0. 

 The binaries will end up being installed in /usr/local/bin 


 ## Git ## 

 If any repository package requires Git protocol, then for Lion and earlier you may need Git from <http://git-scm.com/download/mac> and add /usr/local/git/bin to your path. 


 ### Macports ###  

 This provides wget, freetype, and other utilities. Get macports from <http://www.macports.org/install.php> and install. 

 Note: Before proceeding with the installation of various macports packages noted below on Lion machines with Xcode 4.3, one needs to run 

 ~~~~~~ 
 sudo xcode-select -switch /Applications/Xcode.app 
 ~~~~~~ 

 Otherwise, there will be an error installing zlib during the wget installation below. 

 After the macports installation, do 

 ~~~~~~ 
 sudo port install wget 
 sudo port install ImageMagick +no_x11 
 sudo port install f2c 
 ~~~~~~ 


 ### XCode ### 
 ### Lion ### 

 On Lion, the command line compilers are not installed automatically. After installing Xcode, navigate to the  
 Preferences->Download dialog  
 and install the Command Line Tools. The dialog is..  

 !screenShotCommandLineTools.png! 

 or from the command line do 

 ~~~~~~ 
 sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/ 
 xcodebuild 
       (hit agree) 
 ~~~~~~ 

 You may subsequently need to build your first package with sudo in order to accept the Xcode licenses. 

 ### Mountain Lion ###  

 Same as Mavericks? 

 ### Mavericks ### 

 ~~~~~~ 
 sudo xcode-select --install 
 ~~~~~~ 


 ## Java ## 

 (The below does not apply to yosemite.) 

 The cmake build may fail due to missing java headers linked to in /System/Library/Frameworks/JavaVM.framework/Headers. To fix: 

 ~~~~~~ 
 cd /System/Library/Frameworks/JavaVM.framework/Headers 
 sudo mv jni.h jni.h.missing 
 ~~~~~~