sapling/build/fbcode_builder
Mohamed Bassem 4f19f3f2e0 Update the CheckAtomic CMake module to check for __atomic_fetch_add_4 instead of __atomic_is_lock_free
Summary:
When building with clang, the build fails with:

```
-- Looking for __atomic_is_lock_free in atomic
-- Looking for __atomic_is_lock_free in atomic - not found
CMake Error at cmake/CheckAtomic.cmake:90 (message):
  Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
  CMakeLists.txt:75 (include)
```

And the error is:

```
/usr/share/cmake-3.10/Modules/CheckFunctionExists.c:7:3: error: conflicting types for '__atomic_is_lock_free'
  CHECK_FUNCTION_EXISTS(void);
  ^
<command line>:1:31: note: expanded from here
#define CHECK_FUNCTION_EXISTS __atomic_is_lock_free
                              ^
/usr/share/cmake-3.10/Modules/CheckFunctionExists.c:7:3: note: '__atomic_is_lock_free' is a builtin with type 'int (unsigned long, const volatile void *)'
<command line>:1:31: note: expanded from here
#define CHECK_FUNCTION_EXISTS __atomic_is_lock_free
                              ^
/usr/share/cmake-3.10/Modules/CheckFunctionExists.c:17:25: error: too few arguments to function call, expected 2, have 0
  CHECK_FUNCTION_EXISTS();
  ~~~~~~~~~~~~~~~~~~~~~ ^
```

LLVM's CheckAtomic (https://fburl.com/bk14shjt) uses `__atomic_fetch_add_4` so I'm modifying the configs to use it as well to check for the existence of the library.

Reviewed By: yfeldblum

Differential Revision: D19497168

fbshipit-source-id: 64f77487efd16dba49055f6c4cb1cdd0fc4ae6da
2020-01-23 02:08:30 -08:00
..
CMake Update the CheckAtomic CMake module to check for __atomic_fetch_add_4 instead of __atomic_is_lock_free 2020-01-23 02:08:30 -08:00
getdeps opensource/fbcode_builder/getdeps.py: support cargo dependencies in cargo builds 2020-01-20 23:01:17 -08:00
manifests opensource/fbcode_builder/getdeps.py: support cargo dependencies in cargo builds 2020-01-20 23:01:17 -08:00
specs Fixes for travic CI build (#3) 2019-12-10 04:56:56 -08:00
.gitignore add fbcode_builder sources 2019-04-26 11:31:58 -07:00
docker_build_with_ccache.sh add fbcode_builder sources 2019-04-26 11:31:58 -07:00
docker_builder.py Fixes for travic CI build (#3) 2019-12-10 04:56:56 -08:00
docker_enable_ipv6.sh add fbcode_builder sources 2019-04-26 11:31:58 -07:00
fbcode_builder_config.py add fbcode_builder sources 2019-04-26 11:31:58 -07:00
fbcode_builder.py Fixes for travic CI build (#3) 2019-12-10 04:56:56 -08:00
getdeps.py opensource/fbcode_builder/getdeps.py: support cargo dependencies in cargo builds 2020-01-20 23:01:17 -08:00
LICENSE Relicense getdeps from BSD to MIT 2019-10-10 13:20:05 -07:00
make_docker_context.py update docker os_image to ubuntu18 and gcc7 2019-05-10 16:39:16 -07:00
parse_args.py add fbcode_builder sources 2019-04-26 11:31:58 -07:00
README.docker add fbcode_builder sources 2019-04-26 11:31:58 -07:00
README.md update README.md on ubuntu and gcc version 2019-05-27 13:33:44 -07:00
shell_builder.py Fixes for travic CI build (#3) 2019-12-10 04:56:56 -08:00
shell_quoting.py add fbcode_builder sources 2019-04-26 11:31:58 -07:00
travis_docker_build.sh add fbcode_builder sources 2019-04-26 11:31:58 -07:00
utils.py add fbcode_builder sources 2019-04-26 11:31:58 -07:00

Easy builds for Facebook projects

This is a Python 2.6+ library designed to simplify continuous-integration (and other builds) of Facebook projects.

For external Travis builds, the entry point is travis_docker_build.sh.

Using Docker to reproduce a CI build

If you are debugging or enhancing a CI build, you will want to do so from host or virtual machine that can run a reasonably modern version of Docker:

./make_docker_context.py --help  # See available options for OS & compiler
# Tiny wrapper that starts a Travis-like build with compile caching:
os_image=ubuntu:18.04 \
  gcc_version=7 \
  make_parallelism=2 \
  travis_cache_dir=~/travis_ccache \
    ./travis_docker_build.sh &> build_at_$(date +'%Y%m%d_%H%M%S').log

IMPORTANT: Read fbcode_builder/README.docker before diving in!

Setting travis_cache_dir turns on ccache, saving a fresh copy of ccache.tgz after every build. This will invalidate Docker's layer cache, foring it to rebuild starting right after OS package setup, but the builds will be fast because all the compiles will be cached. To iterate without invalidating the Docker layer cache, just cd /tmp/docker-context-* and interact with the Dockerfile normally. Note that the docker-context-* dirs preserve a copy of ccache.tgz as they first used it.

What to read next

The *.py files are fairly well-documented. You might want to peruse them in this order:

  • shell_quoting.py
  • fbcode_builder.py
  • docker_builder.py
  • make_docker_context.py

As far as runs on Travis go, the control flow is:

  • .travis.yml calls
  • travis_docker_build.sh calls
  • docker_build_with_ccache.sh

This library also has an (unpublished) component targeting Facebook's internal continuous-integration platform using the same build-step DSL.

Contributing

Please follow the ambient style (or PEP-8), and keep the code Python 2.6 compatible -- since fbcode_builder's only dependency is Docker, we want to allow building projects on even fairly ancient base systems. We also wish to be compatible with Python 3, and would appreciate it if you kept that in mind while making changes also.