{"id":13436518,"url":"https://github.com/facebook/folly","last_synced_at":"2026-03-09T17:19:03.788Z","repository":{"id":3469513,"uuid":"4524181","full_name":"facebook/folly","owner":"facebook","description":"An open-source C++ library developed and used at Facebook.","archived":false,"fork":false,"pushed_at":"2025-05-03T02:22:08.000Z","size":47376,"stargazers_count":29326,"open_issues_count":377,"forks_count":5688,"subscribers_count":1014,"default_branch":"main","last_synced_at":"2025-05-05T14:08:52.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facebook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-06-01T20:49:04.000Z","updated_at":"2025-05-05T12:06:11.000Z","dependencies_parsed_at":"2023-10-15T04:46:23.611Z","dependency_job_id":"9ee0722a-fc51-4cdf-9719-24a36c7191bf","html_url":"https://github.com/facebook/folly","commit_stats":{"total_commits":13362,"total_committers":1596,"mean_commits":8.37218045112782,"dds":0.8790600209549468,"last_synced_commit":"11f0c9ef104bdea41eaf73fd9a07992a12bffe6f"},"previous_names":[],"tags_count":477,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebook%2Ffolly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebook%2Ffolly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebook%2Ffolly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebook%2Ffolly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facebook","download_url":"https://codeload.github.com/facebook/folly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253773908,"owners_count":21962194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:00:49.449Z","updated_at":"2026-03-09T17:19:03.772Z","avatar_url":"https://github.com/facebook.png","language":"C++","readme":"Folly: Facebook Open-source Library\n===================================\n\n\u003ca href=\"https://opensource.facebook.com/support-ukraine\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat\u0026labelColor=005BBB\" alt=\"Support Ukraine - Help Provide Humanitarian Aid to Ukraine.\" /\u003e\n\u003c/a\u003e\n\n# What is `folly`?\n\n\u003cimg src=\"static/logo.svg\" alt=\"Logo Folly\" width=\"15%\" align=\"right\" /\u003e\n\nFolly (an acronym loosely after Facebook Open Source Library) is a\nlibrary of C++20 components designed with practicality and efficiency\nin mind. **Folly contains a variety of core library components used extensively\nat Facebook**. In particular, it's often a dependency of Facebook's other\nopen source C++ efforts and place where those projects can share code.\n\nIt complements (as opposed to competing against) offerings\nsuch as Boost and of course `std`. In fact, we embark on defining our\nown component only when something we need is either not available, or\ndoes not meet the needed performance profile. We endeavor to remove\nthings from folly if or when `std` or Boost obsoletes them.\n\nPerformance concerns permeate much of Folly, sometimes leading to\ndesigns that are more idiosyncratic than they would otherwise be (see\ne.g. `PackedSyncPtr.h`, `SmallLocks.h`). Good performance at large\nscale is a unifying theme in all of Folly.\n\n## Check it out in the intro video\n[![Explain Like I’m 5: Folly](https://img.youtube.com/vi/Wr_IfOICYSs/0.jpg)](https://www.youtube.com/watch?v=Wr_IfOICYSs)\n\n# Logical Design\n\nFolly is a collection of relatively independent components, some as\nsimple as a few symbols. There is no restriction on internal\ndependencies, meaning that a given folly module may use any other\nfolly components.\n\nAll symbols are defined in the top-level namespace `folly`, except of\ncourse macros. Macro names are ALL_UPPERCASE and should be prefixed\nwith `FOLLY_`. Namespace `folly` defines other internal namespaces\nsuch as `internal` or `detail`. User code should not depend on symbols\nin those namespaces.\n\n# Physical Design\n\nAt the top level Folly uses the classic \"stuttering\" scheme\n`folly/folly` used by Boost and others. The first directory serves as\nan installation root of the library (with possible versioning a la\n`folly-1.0/`), and the second is to distinguish the library when\nincluding files, e.g. `#include \u003cfolly/FBString.h\u003e`.\n\nThe directory structure is flat (mimicking the namespace structure),\ni.e. we don't have an elaborate directory hierarchy (it is possible\nthis will change in future versions). The subdirectory `experimental`\ncontains files that are used inside folly and possibly at Facebook but\nnot considered stable enough for client use. Your code should not use\nfiles in `folly/experimental` lest it may break when you update Folly.\n\nThe `folly/folly/test` subdirectory includes the unittests for all\ncomponents, usually named `ComponentXyzTest.cpp` for each\n`ComponentXyz.*`. The `folly/folly/docs` directory contains\ndocumentation.\n\n# What's in it?\n\nBecause of folly's fairly flat structure, the best way to see what's in it\nis to look at the headers in [top level `folly/` directory](https://github.com/facebook/folly/tree/main/folly). You can also\ncheck the [`docs` folder](folly/docs) for documentation, starting with the\n[overview](folly/docs/Overview.md).\n\nFolly is published on GitHub at https://github.com/facebook/folly.\n\n# Build Notes\n\nBecause folly does not provide any ABI compatibility guarantees from commit to\ncommit, we generally recommend building folly as a static library.\n\nfolly supports gcc (5.1+), clang, or MSVC. It should run on Linux (x86-32,\nx86-64, and ARM), iOS, macOS, and Windows (x86-64). The CMake build is only\ntested on some of these platforms; at a minimum, we aim to support macOS and\nLinux (on the latest Ubuntu LTS release or newer.)\n\n## `getdeps.py`\n\nThis script is used by many of Meta's OSS tools.  It will download and build all of the necessary dependencies first, and will then invoke cmake etc to build folly.  This will help ensure that you build with relevant versions of all of the dependent libraries, taking into account what versions are installed locally on your system.\n\nIt's written in python so you'll need python3.6 or later on your PATH.  It works on Linux, macOS and Windows.\n\nThe settings for folly's cmake build are held in its getdeps manifest `build/fbcode_builder/manifests/folly`, which you can edit locally if desired.\n\n### Dependencies\n\nIf on Linux or MacOS (with homebrew installed) you can install system dependencies to save building them:\n\n    # Clone the repo\n    git clone https://github.com/facebook/folly\n    # Install dependencies\n    cd folly\n    sudo ./build/fbcode_builder/getdeps.py install-system-deps --recursive\n\nIf you'd like to see the packages before installing them:\n\n    ./build/fbcode_builder/getdeps.py install-system-deps --dry-run --recursive\n\nOn other platforms or if on Linux and without system dependencies `getdeps.py` will mostly download and build them for you during the build step.\n\nSome of the dependencies `getdeps.py` uses and installs are:\n\n  * a version of boost compiled with C++14 support.\n  * googletest is required to build and run folly's tests.\n\n### Build\n\nThis script will download and build all of the necessary dependencies first,\nand will then invoke cmake etc to build folly.  This will help ensure that you build with relevant versions of all of the dependent libraries, taking into account what versions are installed locally on your system.\n\n`getdeps.py` currently requires python 3.6+ to be on your path.\n\n`getdeps.py` will invoke cmake etc.\n\n    # Clone the repo\n    git clone https://github.com/facebook/folly\n    cd folly\n    # Build, using system dependencies if available\n    python3 ./build/fbcode_builder/getdeps.py --allow-system-packages build\n\nIt puts output in its scratch area:\n\n  * `installed/folly/lib/libfolly.a`: Library\n\nYou can also specify a `--scratch-path` argument to control\nthe location of the scratch directory used for the build. You can find the default scratch install location from logs or with `python3 ./build/fbcode_builder/getdeps.py show-inst-dir`.\n\nThere are also\n`--install-dir` and `--install-prefix` arguments to provide some more\nfine-grained control of the installation directories. However, given that\nfolly provides no compatibility guarantees between commits we generally\nrecommend building and installing the libraries to a temporary location, and\nthen pointing your project's build at this temporary location, rather than\ninstalling folly in the traditional system installation directories. e.g., if you are building with CMake you can use the `CMAKE_PREFIX_PATH` variable to allow CMake to find folly in this temporary installation directory when\nbuilding your project.\n\nIf you want to invoke `cmake` again to iterate, there is a helpful `run_cmake.py` script output in the scratch build directory.  You can find the scratch build directory from logs or with `python3 ./build/fbcode_builder/getdeps.py show-build-dir`.\n\n### Run tests\n\nBy default `getdeps.py` will build the tests for folly. To run them:\n\n    cd folly\n    python3 ./build/fbcode_builder/getdeps.py --allow-system-packages test\n\n### `build.sh`/`build.bat` wrapper\n\n`build.sh` can be used on Linux and MacOS, on Windows use\nthe `build.bat` script instead. Its a wrapper around `getdeps.py`.\n\n## Build with cmake directly\n\nIf you don't want to let getdeps invoke cmake for you then by default, building the tests is disabled as part of the CMake `all` target.\nTo build the tests, specify `-DBUILD_TESTS=ON` to CMake at configure time.\n\nNB if you want to invoke `cmake` again to iterate on a `getdeps.py` build, there is a helpful `run_cmake.py` script output in the scratch-path build directory. You can find the scratch build directory from logs or with `python3 ./build/fbcode_builder/getdeps.py show-build-dir`.\n\nRunning tests with ctests also works if you cd to the build dir, e.g.\n`(cd $(python3 ./build/fbcode_builder/getdeps.py show-build-dir) \u0026\u0026 ctest)`\n\n### Finding dependencies in non-default locations\n\nIf you have boost, gtest, or other dependencies installed in a non-default\nlocation, you can use the `CMAKE_INCLUDE_PATH` and `CMAKE_LIBRARY_PATH`\nvariables to make CMAKE look also look for header files and libraries in\nnon-standard locations.  For example, to also search the directories\n`/alt/include/path1` and `/alt/include/path2` for header files and the\ndirectories `/alt/lib/path1` and `/alt/lib/path2` for libraries, you can invoke\n`cmake` as follows:\n\n```\ncmake \\\n  -DCMAKE_INCLUDE_PATH=/alt/include/path1:/alt/include/path2 \\\n  -DCMAKE_LIBRARY_PATH=/alt/lib/path1:/alt/lib/path2 ...\n```\n\n## Ubuntu LTS, CentOS Stream, Fedora\n\nUse the `getdeps.py` approach above. We test in CI on Ubuntu LTS, and occasionally on other distros.\n\nIf you find the set of system packages is not quite right for your chosen distro, you can specify distro version specific overrides in the dependency manifests (e.g. https://github.com/facebook/folly/blob/main/build/fbcode_builder/manifests/boost ). You could probably make it work on most recent Ubuntu/Debian or Fedora/Redhat derived distributions.\n\nAt time of writing (Dec 2021) there is a build break on GCC 11.x based systems in lang_badge_test.  If you don't need badge functionality you can work around by commenting it out from CMakeLists.txt (unfortunately fbthrift does need it)\n\n## Windows (Vcpkg)\n\nNote that many tests are disabled for folly Windows builds, you can see them in the log from the cmake configure step, or by looking for WINDOWS_DISABLED in `CMakeLists.txt`\n\nThat said, `getdeps.py` builds work on Windows and are tested in CI.\n\nIf you prefer, you can try Vcpkg. folly is available in [Vcpkg](https://github.com/Microsoft/vcpkg#vcpkg) and releases may be built via `vcpkg install folly:x64-windows`.\n\nYou may also use `vcpkg install folly:x64-windows --head` to build against `main`.\n\n## macOS\n\n`getdeps.py` builds work on macOS and are tested in CI, however if you prefer, you can try one of the macOS package managers\n\n### Homebrew\n\nfolly is available as a Formula and releases may be built via `brew install folly`.\n\nYou may also use `folly/build/bootstrap-osx-homebrew.sh` to build against `main`:\n\n```\n  ./folly/build/bootstrap-osx-homebrew.sh\n```\n\nThis will create a build directory `_build` in the top-level.\n\n### MacPorts\n\nInstall the required packages from MacPorts:\n\n```\n  sudo port install \\\n    boost \\\n    cmake \\\n    gflags \\\n    git \\\n    google-glog \\\n    libevent \\\n    libtool \\\n    lz4 \\\n    lzma \\\n    openssl \\\n    snappy \\\n    xz \\\n    zlib\n```\n\nDownload and install double-conversion:\n\n```\n  git clone https://github.com/google/double-conversion.git\n  cd double-conversion\n  cmake -DBUILD_SHARED_LIBS=ON .\n  make\n  sudo make install\n```\n\nDownload and install folly with the parameters listed below:\n\n```\n  git clone https://github.com/facebook/folly.git\n  cd folly\n  mkdir _build\n  cd _build\n  cmake ..\n  make\n  sudo make install\n```\n","funding_links":[],"categories":["Frameworks","C++","HarmonyOS","Containers \u0026 Language Extentions \u0026 Linting","C++ Foundation Libraries","Real-World Projects","C/C++ 程序设计","Basic Utility","框架","Libraries \u0026 Frameworks:","Libraries","\u003ca name=\"cpp\"\u003e\u003c/a\u003eC++","Repos","Libraries and Frameworks","Projects"],"sub_categories":["Windows Manager","For C++/C","C++ Data Structures and Algorithms","Systems Programming / Kernel","网络服务_其他","Other","Kitchensink / Framework","Miscellaneous Libraries","Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebook%2Ffolly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacebook%2Ffolly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebook%2Ffolly/lists"}