1
0

INSTALL 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. Quick Installation Guide for musl libc
  2. ======================================
  3. There are many different ways to install musl depending on your usage
  4. case. This document covers only the build and installation of musl by
  5. itself, which is useful for upgrading an existing musl-based system or
  6. compiler toolchain, or for using the provided musl-gcc wrapper with an
  7. existing non-musl-based compiler.
  8. Building complete native or cross-compiler toolchains is outside the
  9. scope of this INSTALL file. More information can be found on the musl
  10. website and community wiki.
  11. Build Prerequisites
  12. -------------------
  13. The only build-time prerequisites for musl are GNU Make and a
  14. freestanding C99 compiler toolchain targeting the desired instruction
  15. set architecture and ABI, with support for gcc-style inline assembly,
  16. weak aliases, and stand-alone assembly source files.
  17. The system used to build musl does not need to be Linux-based, nor do
  18. the Linux kernel headers need to be available.
  19. If support for dynamic linking is desired, some further requirements
  20. are placed on the compiler and linker. In particular, the linker must
  21. support the -Bsymbolic-functions option.
  22. At present, GCC 4.6 or later is the recommended compiler for building
  23. musl. Any earlier version of GCC with full C99 support should also
  24. work, but may be subject to minor floating point conformance issues on
  25. i386 targets. Sufficiently recent versions of PCC and LLVM/clang are
  26. also believed to work, but have not been tested as heavily; prior to
  27. Fall 2012, both had known bugs that affected musl. Firm/cparser is
  28. also believed to work but lacks support for producing shared
  29. libraries.
  30. Supported Targets
  31. -----------------
  32. musl can be built for the following CPU instruction set architecture
  33. and ABI combinations:
  34. * i386
  35. * Minimum CPU model is actually 80486 unless kernel emulation of
  36. the `cmpxchg` instruction is added
  37. * x86_64
  38. * ARM
  39. * EABI, standard or hard-float VFP variant
  40. * Little-endian default; big-endian variants also supported
  41. * Compiler toolchains only support armv4t and later
  42. * MIPS
  43. * ABI is o32
  44. * Big-endian default; little-endian variants also supported
  45. * Default ABI variant uses FPU registers; alternate soft-float ABI
  46. that does not use FPU registers or instructions is available
  47. * MIPS2 or later, or kernel emulation of ll/sc (standard in Linux)
  48. is required
  49. * PowerPC
  50. * Only 32-bit is supported
  51. * Compiler toolchain must provide 64-bit long double, not IBM
  52. double-double or IEEE quad
  53. * For dynamic linking, compiler toolchain must be configured for
  54. "secure PLT" variant
  55. * Microblaze
  56. * Big-endian default; little-endian variants also supported
  57. * Soft-float
  58. * Requires support for lwx/swx instructions
  59. The following additional targets are available for build, but may not
  60. work correctly and may not yet have ABI stability:
  61. * SuperH (SH)
  62. * Little-endian by default; big-engian variant also supported
  63. * Full FPU ABI or soft-float ABI is supported, but the
  64. single-precision-only FPU ABI is not supported (musl always
  65. requires IEEE single and double to be supported)
  66. * x32 (x86_64 ILP32 ABI)
  67. Build and Installation Procedure
  68. --------------------------------
  69. To build and install musl:
  70. 1. Run the provided configure script from the top-level source
  71. directory, passing on its command line any desired options.
  72. 2. Run "make" to compile.
  73. 3. Run "make install" with appropriate privileges to write to the
  74. target locations.
  75. The configure script attempts to determine automatically the correct
  76. target architecture based on the compiler being used. For some
  77. compilers, this may not be possible. If detection fails or selects the
  78. wrong architecture, you can provide an explicit selection on the
  79. configure command line.
  80. By default, configure installs to a prefix of "/usr/local/musl". This
  81. differs from the behavior of most configure scripts, and is chosen
  82. specifically to avoid clashing with libraries already present on the
  83. system. DO NOT set the prefix to "/usr", "/usr/local", or "/" unless
  84. you're upgrading libc on an existing musl-based system. Doing so will
  85. break your existing system when you run "make install" and it may be
  86. difficult to recover.
  87. Notes on Dynamic Linking
  88. ------------------------
  89. If dynamic linking is enabled, one file needs to be installed outside
  90. of the installation prefix: /lib/ld-musl-$ARCH.so.1. This is the
  91. dynamic linker. Its pathname is hard-coded into all dynamic-linked
  92. programs, so for the sake of being able to share binaries between
  93. systems, a consistent location should be used everywhere. Note that
  94. the same applies to glibc and its dynamic linker, which is named
  95. /lib/ld-linux.so.2 on i386 systems.
  96. If for some reason it is impossible to install the dynamic linker in
  97. its standard location (for example, if you are installing without root
  98. privileges), the --syslibdir option to configure can be used to
  99. provide a different location
  100. At runtime, the dynamic linker needs to know the paths to search for
  101. shared libraries. You should create a text file named
  102. /etc/ld-musl-$ARCH.path (where $ARCH matches the architecture name
  103. used in the dynamic linker) containing a list of directories where you
  104. want the dynamic linker to search for shared libraries, separated by
  105. colons or newlines. If the dynamic linker has been installed in a
  106. non-default location, the path file also needs to reside at that
  107. location (../etc relative to the chosen syslibdir).
  108. If you do not intend to use dynamic linking, you may disable it by
  109. passing --disable-shared to configure; this also cuts the build time
  110. in half.
  111. Checking for Successful Installation
  112. ------------------------------------
  113. After installing, you should be able to use musl via the musl-gcc
  114. wrapper. For example:
  115. cat > hello.c <<EOF
  116. #include <stdio.h>
  117. int main()
  118. {
  119. printf("hello, world!\n");
  120. return 0;
  121. }
  122. EOF
  123. /usr/local/musl/bin/musl-gcc hello.c
  124. ./a.out
  125. To configure autoconf-based program to compile and link against musl,
  126. set the CC variable to musl-gcc when running configure, as in:
  127. CC=musl-gcc ./configure ...
  128. You will probably also want to use --prefix when building libraries to
  129. ensure that they are installed under the musl prefix and not in the
  130. main host system library directories.