Unable to build 'lld' on Mac OS 10.9

Hi All,

I am trying to build the ‘lld’ linker on Mac OS 10.9, but during the build, I am getting the errors. Following are the steps that I have followed:

  1. I have downloaded the ‘llvm-stable’ source code from the following location:

https://github.com/llvm-mirror/llvm/tree/stable

  1. Machine details(on which llvm source code is being built) are as follows:

$ sw_vers

ProductName: Mac OS X

ProductVersion: 10.9.5

BuildVersion: 13F1911

$ clang -v

Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)

Target: x86_64-apple-darwin13.4.0

Thread model: posix

$ xcode-select -v

xcode-select version 2333.

  1. Following command is successful:

$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=lld -DCMAKE_INSTALL_PREFIX=/testlocation/llvm_siri …/llvm-stable

CMake Deprecation Warning at CMakeLists.txt:14 (cmake_policy):

The OLD behavior for policy CMP0051 will be removed from a future version

of CMake.

The cmake-policies(7) manual explains that the OLD behaviors of all

policies are deprecated and that a policy should be set to OLD only under

specific short-term circumstances. Projects should be ported to the NEW

behavior and not rely on setting a policy to OLD.

– The C compiler identification is AppleClang 6.0.0.6000057

– The CXX compiler identification is AppleClang 6.0.0.6000057

– The ASM compiler identification is AppleClang

– Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc – works

– Detecting C compiler ABI info

– Detecting C compiler ABI info - done

– Detecting C compile features

– Detecting C compile features - done

– Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++

– Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ – works

– Detecting CXX compiler ABI info

– Detecting CXX compiler ABI info - done

– Detecting CXX compile features

– Detecting CXX compile features - done

– Found libtool - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool

– Looking for dlfcn.h

– Looking for dlfcn.h - found

– Looking for errno.h

– Looking for errno.h - found

– Looking for fcntl.h

– Looking for fcntl.h - found

– Looking for link.h

– Looking for link.h - not found

– Looking for malloc.h

– Looking for malloc.h - not found

– Looking for malloc/malloc.h

– Looking for malloc/malloc.h - found

– Looking for pthread.h

– Looking for pthread.h - found

– Looking for signal.h

– Looking for signal.h - found

– Looking for sys/ioctl.h

– Looking for sys/ioctl.h - found

– Looking for sys/mman.h

– Looking for sys/mman.h - found

– Looking for sys/param.h

– Looking for sys/param.h - found

– Looking for sys/resource.h

– Looking for sys/resource.h - found

– Looking for sys/stat.h

– Looking for sys/stat.h - found

– Looking for sys/time.h

– Looking for sys/time.h - found

– Looking for sys/types.h

– Looking for sys/types.h - found

– Looking for termios.h

– Looking for termios.h - found

– Looking for unistd.h

– Looking for unistd.h - found

– Looking for valgrind/valgrind.h

– Looking for valgrind/valgrind.h - not found

– Looking for zlib.h

– Looking for zlib.h - found

– Looking for fenv.h

– Looking for fenv.h - found

– Looking for FE_ALL_EXCEPT

– Looking for FE_ALL_EXCEPT - found

– Looking for FE_INEXACT

– Looking for FE_INEXACT - found

– Looking for mach/mach.h

– Looking for mach/mach.h - found

– Looking for histedit.h

– Looking for histedit.h - found

– Looking for CrashReporterClient.h

– Looking for CrashReporterClient.h - not found

– Performing Test HAVE_CRASHREPORTER_INFO

– Performing Test HAVE_CRASHREPORTER_INFO - Success

– Looking for pthread_create in pthread

– Looking for pthread_create in pthread - found

– Looking for pthread_getspecific in pthread

– Looking for pthread_getspecific in pthread - found

– Looking for pthread_rwlock_init in pthread

– Looking for pthread_rwlock_init in pthread - found

– Looking for pthread_mutex_lock in pthread

– Looking for pthread_mutex_lock in pthread - found

– Looking for dlopen in dl

– Looking for dlopen in dl - found

– Looking for clock_gettime in rt

– Looking for clock_gettime in rt - not found

– Looking for pfm_initialize in pfm

– Looking for pfm_initialize in pfm - not found

– Looking for pthread.h

– Looking for pthread.h - found

– Looking for pthread_create

– Looking for pthread_create - found

– Found Threads: TRUE

– Looking for compress2 in z

– Looking for compress2 in z - found

– Looking for el_init in edit

– Looking for el_init in edit - found

– Looking for setupterm in tinfo

– Looking for setupterm in tinfo - not found

– Looking for setupterm in terminfo

– Looking for setupterm in terminfo - not found

– Looking for setupterm in curses

– Looking for setupterm in curses - found

– Found LibXml2: /usr/lib/libxml2.dylib (found version “2.9.0”)

– Looking for xar_open in xar

– Looking for xar_open in xar - found

– Looking for arc4random

– Looking for arc4random - found

– Looking for backtrace

– Looking for backtrace - found

– backtrace facility detected in default set of libraries

– Found Backtrace: /usr/include

– Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW

– Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed

– Looking for _Unwind_Backtrace

– Looking for _Unwind_Backtrace - found

– Looking for getpagesize

– Looking for getpagesize - found

– Looking for sysconf

– Looking for sysconf - found

– Looking for getrusage

– Looking for getrusage - found

– Looking for setrlimit

– Looking for setrlimit - found

– Looking for isatty

– Looking for isatty - found

– Looking for futimens

– Looking for futimens - not found

– Looking for futimes

– Looking for futimes - found

– Looking for posix_fallocate

– Looking for posix_fallocate - not found

– Looking for lseek64

– Looking for lseek64 - not found

– Looking for mallctl

– Looking for mallctl - not found

– Looking for mallinfo

– Looking for mallinfo - not found

– Looking for malloc_zone_statistics

– Looking for malloc_zone_statistics - found

– Looking for getrlimit

– Looking for getrlimit - found

– Looking for posix_spawn

– Looking for posix_spawn - found

– Looking for pread

– Looking for pread - found

– Looking for realpath

– Looking for realpath - found

– Looking for sbrk

– Looking for sbrk - found

– Looking for strerror

– Looking for strerror - found

– Looking for strerror_r

– Looking for strerror_r - found

– Looking for strerror_s

– Looking for strerror_s - not found

– Looking for setenv

– Looking for setenv - found

– Looking for dlopen

– Looking for dlopen - found

– Looking for dladdr

– Looking for dladdr - found

– Looking for GLIBC

– Looking for GLIBC - not found

– Looking for sched_getaffinity

– Looking for sched_getaffinity - not found

– Looking for CPU_COUNT

– Looking for CPU_COUNT - not found

– Looking for pthread_getname_np

– Looking for pthread_getname_np - found

– Looking for pthread_setname_np

– Looking for pthread_setname_np - found

– Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB

– Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Success

– Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB

– Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Success

– Performing Test LLVM_HAS_ATOMICS

– Performing Test LLVM_HAS_ATOMICS - Success

– Performing Test SUPPORTS_VARIADIC_MACROS_FLAG

– Performing Test SUPPORTS_VARIADIC_MACROS_FLAG - Success

– Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG

– Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG - Success

– Native target architecture is X86

– Threads enabled.

– Doxygen disabled.

– Go bindings disabled.

– Found ld64 - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld

– Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)

– Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)

– OCaml bindings disabled.

– Could NOT find Python module pygments

– Could NOT find Python module pygments.lexers.c_cpp

– Could NOT find Python module yaml

– LLVM host triple: x86_64-apple-darwin13.4.0

– LLVM default target triple: x86_64-apple-darwin13.4.0

– Performing Test C_SUPPORTS_FPIC

– Performing Test C_SUPPORTS_FPIC - Success

– Performing Test CXX_SUPPORTS_FPIC

– Performing Test CXX_SUPPORTS_FPIC - Success

– Building with -fPIC

– Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG

– Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success

– Performing Test C_SUPPORTS_WERROR_DATE_TIME

– Performing Test C_SUPPORTS_WERROR_DATE_TIME - Failed

– Performing Test CXX_SUPPORTS_WERROR_DATE_TIME

– Performing Test CXX_SUPPORTS_WERROR_DATE_TIME - Failed

– Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW

– Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed

– Performing Test CXX_SUPPORTS_CXX11

– Performing Test CXX_SUPPORTS_CXX11 - Success

– Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG

– Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG - Success

– Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG

– Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success

– Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG

– Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Success

– Performing Test CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR

– Performing Test CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR - Failed

– Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG

– Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Success

– Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG

– Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Success

– Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP

– Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Success

– Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG

– Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG - Success

– Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG

– Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG - Success

– Found PythonInterp: /usr/bin/python2.7 (found version “2.7.5”)

– Constructing LLVMBuild project information

– Targeting AArch64

– Targeting AMDGPU

– Targeting ARM

– Targeting BPF

– Targeting Hexagon

– Targeting Lanai

– Targeting Mips

– Targeting MSP430

– Targeting NVPTX

– Targeting PowerPC

– Targeting Sparc

– Targeting SystemZ

– Targeting X86

– Targeting XCore

– LLD version: 7.0.0

– Configuring done

– Generating done

– Build files have been written to: /testlocation/llvm_lld/build

  1. But on running ‘make install’, following error is observed:

$ make install

Scanning dependencies of target LLVMDemangle

[ 0%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o

[ 0%] Linking CXX static library …/libLLVMDemangle.a

[ 0%] Built target LLVMDemangle

Scanning dependencies of target LLVMSupport

[ 0%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/AMDGPUMetadata.cpp.o

In file included from /testlocation/llvm_lld/llvm-stable/lib/Support/AMDGPUMetadata.cpp:18:

In file included from /testlocation/llvm_lld/llvm-stable/include/llvm/Support/YAMLTraits.h:23:

In file included from /testlocation/llvm_lld/llvm-stable/include/llvm/Support/SourceMgr.h:25:

In file included from /testlocation/llvm_lld/llvm-stable/include/llvm/Support/MemoryBuffer.h:23:

In file included from /testlocation/llvm_lld/llvm-stable/include/llvm/Support/FileSystem.h:33:

In file included from /testlocation/llvm_lld/llvm-stable/include/llvm/Support/Chrono.h:14:

/testlocation/llvm_lld/llvm-stable/include/llvm/Support/FormatProviders.h:267:25: error: no viable conversion from

‘const char [2]’ to ‘llvm::StringLiteral’

.Case(“Y”, B ? “YES” : “NO”)

^~~

/testlocation/llvm_lld/llvm-stable/include/llvm/ADT/StringRef.h:857:9: note: candidate constructor

(the implicit copy constructor) not viable: no known conversion from ‘const char [2]’ to ‘const llvm::StringLiteral &’ for 1st

argument

class StringLiteral : public StringRef {

^

/testlocation/llvm_lld/llvm-stable/include/llvm/ADT/StringRef.h:857:9: note: candidate constructor

(the implicit move constructor) not viable: no known conversion from ‘const char [2]’ to ‘llvm::StringLiteral &&’ for 1st

argument

class StringLiteral : public StringRef {

^

/testlocation/llvm_lld/llvm-stable/include/llvm/ADT/StringRef.h:864:15: note: candidate disabled: invalid string literal

constexpr StringLiteral(const char (&Str)[N])

^

/testlocation/llvm_lld/llvm-stable/include/llvm/ADT/StringSwitch.h:70:36: note: passing argument to parameter ‘S’ here

StringSwitch &Case(StringLiteral S, T Value) {

^

1 error generated.

make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/AMDGPUMetadata.cpp.o] Error 1

make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2

make: *** [all] Error 2

Please let me know how to resolve this error.

Regards,
Vinay

I’m not sure what the stable sources listed there are. I would probably start from the directions here: https://llvm.org/docs/GettingStarted.html and on lld.llvm.org as a way to get started.

-eric