Supply an explicit default dtor impl
[folly.git] / README.md
1 Folly: Facebook Open-source Library
2 -----------------------------------
3
4 ### What is `folly`?
5
6 Folly (acronymed loosely after Facebook Open Source Library) is a
7 library of C++11 components designed with practicality and efficiency
8 in mind. **Folly contains a variety of core library components used extensively
9 at Facebook**. In particular, it's often a dependency of Facebook's other
10 open source C++ efforts and place where those projects can share code.
11
12 It complements (as opposed to competing against) offerings
13 such as Boost and of course `std`. In fact, we embark on defining our
14 own component only when something we need is either not available, or
15 does not meet the needed performance profile. We endeavor to remove
16 things from folly if or when `std` or Boost obsoletes them.
17
18 Performance concerns permeate much of Folly, sometimes leading to
19 designs that are more idiosyncratic than they would otherwise be (see
20 e.g. `PackedSyncPtr.h`, `SmallLocks.h`). Good performance at large
21 scale is a unifying theme in all of Folly.
22
23 ### Logical Design
24
25 Folly is a collection of relatively independent components, some as
26 simple as a few symbols. There is no restriction on internal
27 dependencies, meaning that a given folly module may use any other
28 folly components.
29
30 All symbols are defined in the top-level namespace `folly`, except of
31 course macros. Macro names are ALL_UPPERCASE and should be prefixed
32 with `FOLLY_`. Namespace `folly` defines other internal namespaces
33 such as `internal` or `detail`. User code should not depend on symbols
34 in those namespaces.
35
36 Folly has an `experimental` directory as well. This designation connotes
37 primarily that we feel the API may change heavily over time. This code,
38 typically, is still in heavy use and is well tested.
39
40 ### Physical Design
41
42 At the top level Folly uses the classic "stuttering" scheme
43 `folly/folly` used by Boost and others. The first directory serves as
44 an installation root of the library (with possible versioning a la
45 `folly-1.0/`), and the second is to distinguish the library when
46 including files, e.g. `#include <folly/FBString.h>`.
47
48 The directory structure is flat (mimicking the namespace structure),
49 i.e. we don't have an elaborate directory hierarchy (it is possible
50 this will change in future versions). The subdirectory `experimental`
51 contains files that are used inside folly and possibly at Facebook but
52 not considered stable enough for client use. Your code should not use
53 files in `folly/experimental` lest it may break when you update Folly.
54
55 The `folly/folly/test` subdirectory includes the unittests for all
56 components, usually named `ComponentXyzTest.cpp` for each
57 `ComponentXyz.*`. The `folly/folly/docs` directory contains
58 documentation.
59
60 ### What's in it?
61
62 Because of folly's fairly flat structure, the best way to see what's in it
63 is to look at the headers in [top level `folly/` directory](https://github.com/facebook/folly/tree/master/folly). You can also
64 check the [`docs` folder](folly/docs) for documentation, starting with the
65 [overview](folly/docs/Overview.md).
66
67 Folly is published on Github at https://github.com/facebook/folly
68
69 ### Build Notes
70
71 #### Dependencies
72
73 folly requires gcc 4.9+ and a version of boost compiled with C++14 support.
74
75 Please download googletest from
76 https://github.com/google/googletest/archive/release-1.8.0.tar.gz and unpack it into the
77 folly/test subdirectory as `gtest`:
78
79     (cd folly/test && \
80      rm -rf gtest && \
81      wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
82      tar zxf release-1.8.0.tar.gz && \
83      rm -f release-1.8.0.tar.gz && \
84      mv googletest-release-1.8.0 gtest)
85
86 #### Linking non-default boost libraries
87
88 If you have boost installed in a non-default location, you need to be sure that
89 the linker and configure scripts know where to find boost.  This means making
90 sure that the `LIBRARY_PATH` environment variable contains `<BOOST_ROOT>/lib`,
91 as well as including the path explicitly when running
92 `./configure`:
93
94 ```
95 export LIBRARY_PATH=$BOOST_ROOT/lib:$LIBRARY_PATH
96 ./configure --with-boost=$BOOST_ROOT/lib
97 ```
98
99 #### Ubuntu 12.04
100
101 This release is old, requiring many upgrades. However, since Travis CI runs
102 on 12.04, `folly/build/deps_ubuntu_12.04.sh` is provided, and upgrades all
103 the required packages.
104
105 #### Ubuntu 13.10
106
107 The following packages are required (feel free to cut and paste the apt-get
108 command below):
109
110 ```
111 sudo apt-get install \
112     g++ \
113     automake \
114     autoconf \
115     autoconf-archive \
116     libtool \
117     libboost-all-dev \
118     libevent-dev \
119     libdouble-conversion-dev \
120     libgoogle-glog-dev \
121     libgflags-dev \
122     liblz4-dev \
123     liblzma-dev \
124     libsnappy-dev \
125     make \
126     zlib1g-dev \
127     binutils-dev \
128     libjemalloc-dev \
129     libssl-dev \
130     pkg-config
131 ```
132
133 If advanced debugging functionality is required
134
135 ```
136 sudo apt-get install \
137     libunwind8-dev \
138     libelf-dev \
139     libdwarf-dev
140 ```
141
142 #### Ubuntu 14.04 LTS
143
144 The packages listed above for Ubuntu 13.10 are required, as well as:
145
146 ```
147 sudo apt-get install \
148     libiberty-dev
149 ```
150
151 The above packages are sufficient for Ubuntu 13.10 and Ubuntu 14.04.
152
153 In the folly directory, run:
154 ```
155   autoreconf -ivf
156   ./configure
157   make
158   make check
159   sudo make install
160 ```
161
162 #### Ubuntu 16.04 LTS
163 The packages listed above for 13.10 and 14.04 are sufficient for installation,
164 and the build commands remain the same.
165
166 #### OS X (Homebrew)
167
168 folly is available as a Formula and releases may be built via `brew install folly`.
169
170 You may also use `folly/build/bootstrap-osx-homebrew.sh` to build against `master`:
171
172 ```
173   cd folly
174   ./build/bootstrap-osx-homebrew.sh
175 ```
176
177 #### OS X (MacPorts)
178
179 Install the required packages from MacPorts:
180
181 ```
182   sudo port install \
183     autoconf \
184     automake \
185     boost \
186     gflags \
187     git \
188     google-glog \
189     libevent \
190     libtool \
191     lz4 \
192     lzma \
193     scons \
194     snappy \
195     zlib
196 ```
197
198 Download and install double-conversion:
199
200 ```
201   git clone https://github.com/google/double-conversion.git
202   cd double-conversion
203   cmake -DBUILD_SHARED_LIBS=ON .
204   make
205   sudo make install
206 ```
207
208 Download and install folly with the parameters listed below:
209
210 ```
211   git clone https://github.com/facebook/folly.git
212   cd folly/folly
213   autoreconf -ivf
214   ./configure CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib"
215   make
216   sudo make install
217 ```
218
219 #### Other Linux distributions
220
221 - double-conversion (https://github.com/google/double-conversion)
222
223   Download and build double-conversion.
224   You may need to tell configure where to find it.
225
226   [double-conversion/] `ln -s src double-conversion`
227
228   [folly/] `./configure LDFLAGS=-L$DOUBLE_CONVERSION_HOME/ CPPFLAGS=-I$DOUBLE_CONVERSION_HOME/`
229
230   [folly/] `LD_LIBRARY_PATH=$DOUBLE_CONVERSION_HOME/ make`
231
232 - additional platform specific dependencies:
233
234   Fedora 21 64-bit
235     - gcc
236     - gcc-c++
237     - autoconf
238     - autoconf-archive
239     - automake
240     - boost-devel
241     - libtool
242     - lz4-devel
243     - lzma-devel
244     - snappy-devel
245     - zlib-devel
246     - glog-devel
247     - gflags-devel
248     - scons
249     - double-conversion-devel
250     - openssl-devel
251     - libevent-devel
252
253   Optional
254     - libdwarf-dev
255     - libelf-dev
256     - libunwind8-dev