anchor.diff:    '' + lib.optionalString (useLLVM) ''
       ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
       ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
  +    ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o
  +    ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o
       ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
       ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
  +  ''
  +  # See https://reviews.llvm.org/D37278 for why android exception
  +  + lib.optionalString (stdenv.hostPlatform.isx86_32 && !stdenv.hostPlatform.isAndroid) ''
  +    for f in $out/lib/*/*builtins-i?86*; do
  +      ln -s "$f" $(echo "$f" | sed -e 's/builtins-i.86/builtins-i386/')
  +    done
     '';
   
     meta = llvm_meta // {
  
positive.code:   ] ++ lib.optionals (bareMetal) [
      "-DCOMPILER_RT_OS_DIR=baremetal"
    ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
      # The compiler-rt build infrastructure sniffs supported platforms on Darwin
      # and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
      # when it tries to use libc++ and libc++api for i386.
      "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
      "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}"
    ];
  
negative.code:   postPatch = lib.optionalString (!stdenv.isDarwin) ''
      substituteInPlace cmake/builtin-config-ix.cmake \
        --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
      substituteInPlace cmake/config-ix.cmake \
        --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
    '' + lib.optionalString stdenv.isDarwin ''
      substituteInPlace cmake/config-ix.cmake \
        --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
  