diff --git a/doc/manual.xml b/doc/manual.xml index 75bd21557fd1..eb0a24789d44 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -18,6 +18,7 @@ + diff --git a/doc/platform-notes.xml b/doc/platform-notes.xml new file mode 100644 index 000000000000..f4f6ec600294 --- /dev/null +++ b/doc/platform-notes.xml @@ -0,0 +1,83 @@ + + +Platform Notes + +
+ +Darwin (macOS) +Some common issues when packaging software for darwin: + + + + + + The darwin stdenv uses clang instead of gcc. + When referring to the compiler $CC or cc + will work in both cases. Some builds hardcode gcc/g++ in their + build scripts, that can usually be fixed with using something + like makeFlags = [ "CC=cc" ]; or by patching + the build scripts. + + + + stdenv.mkDerivation { + name = "libfoo-1.2.3"; + # ... + buildPhase = '' + $CC -o hello hello.c + ''; + } + + + + + + On darwin libraries are linked using absolute paths, libraries + are resolved by their install_name at link + time. Sometimes packages won't set this correctly causing the + library lookups to fail at runtime. This can be fixed by adding + extra linker flags or by running install_name_tool -id + during the fixupPhase. + + + + stdenv.mkDerivation { + name = "libfoo-1.2.3"; + # ... + makeFlags = stdenv.lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libfoo.dylib"; + } + + + + + + Some packages assume xcode is available and use xcrun + to resolve build tools like clang, etc. + This causes errors like xcode-select: error: no developer tools were found at '/Applications/Xcode.app' + while the build doesn't actually depend on xcode. + + + + stdenv.mkDerivation { + name = "libfoo-1.2.3"; + # ... + prePatch = '' + substituteInPlace Makefile \ + --replace '/usr/bin/xcrun clang' clang + ''; + } + + + + The package xcbuild can be used to build projects + that really depend on Xcode, however projects that build some kind of + graphical interface won't work without using Xcode in an impure way. + + + + +
+ +