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