Skip to content

Commit

Permalink
Compile with clang by default
Browse files Browse the repository at this point in the history
This should speed up template compilation times and improve
#275.

This also ensures that clang is used on all platforms. Before this PR,
our CI servers were building with gcc.
  • Loading branch information
CodingCanuck authored Jul 1, 2022
1 parent 1a31f7c commit fb5c51f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
19 changes: 9 additions & 10 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ build --enable_platform_specific_config
# Verbose failure logs when something goes wrong.
build --verbose_failures

# Build with clang (rather than the default of gcc) since clang compiles
# templates faster and produces better error messages.
build --repo_env=CC=clang

# Use Clang as a default compiler on Windows.
# TODO: use Clang as a default compiler on every platform.
# TODO(xander): Does repo_env above cover the windows case?
build:windows --compiler="clang-cl"

# Compiler options.
build:gcc --action_env=CC=gcc
build:clang --action_env=CC=clang
# Make it easy to use gcc.
build:gcc --repo_env=CC=gcc

# Build eventuals in C++17 mode.
build:linux --cxxopt=-std=c++17
build:linux --host_cxxopt=-std=c++17
build:macos --cxxopt=-std=c++17
build:macos --host_cxxopt=-std=c++17
build:windows --cxxopt=/std:c++17
build:windows --host_cxxopt=/std:c++17
build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17

# On Windows, `__cplusplus` is wrongly defined without this switch.
# See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
Expand Down
31 changes: 29 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ jobs:
if: ${{ matrix.bazel-command == 'dazel' }}
run: ${{ matrix.sudo-command }} pip3 install dazel

# Stop any running Dazel instances, so that any volume mounts for the
# caches removed above don't stick around. Volume mounts for nonexistent
# directories cause build failures.
#
# Note that after a clean reboot this may print an error saying that
# `docker stop` was given no arguments, as there were no containers running
# at the time: that's ok, so pipe errors to /dev/null.
- name: Stop Dazel instances
if: ${{ matrix.bazel-command == 'dazel' }}
run: |
docker ps --filter name="dazel/*" --filter status=running -aq \
| xargs docker stop 2> /dev/null \
|| true
# Clean up any artifacts from previous builds to ensure that we aren't
# mixing state across novel and old builds. This is especially important
# if new builds use different compiler settings than old builds.
- name: Remove Dazel cache
if: ${{ matrix.bazel-command == 'dazel' }}
run: |
sudo rm -rf ~/.cache/dazel
# Invoke 'dazel version' in order to build the Docker container
# as a separate step so we can track how long it takes and
# optimize as necessary.
Expand All @@ -108,6 +130,13 @@ jobs:
--google_credentials=${{ env.GOOGLE_APPLICATION_CREDENTIALS }}" \
>> $GITHUB_ENV
# Clean up any artifacts from previous builds to ensure that we aren't
# mixing state across novel and old builds. This is especially important
# if new builds use different compiler settings than old builds.
- name: Clean
run: |
bazelisk clean --expunge
- name: Build
run: |
${{ matrix.bazel-command }} \
Expand All @@ -116,7 +145,6 @@ jobs:
${{ matrix.bazel-config }} \
${{ env.BAZEL_REMOTE_CACHE }} \
--verbose_failures \
--spawn_strategy=local \
-c dbg \
--strip="never" \
...
Expand All @@ -130,7 +158,6 @@ jobs:
--experimental_ui_max_stdouterr_bytes=-1 \
${{ env.BAZEL_REMOTE_CACHE }} \
--verbose_failures \
--spawn_strategy=local \
-c dbg \
--strip="never" \
--test_output=errors \
Expand Down
5 changes: 5 additions & 0 deletions eventuals/just.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#include "eventuals/eventual.h"

// DO NOT SUBMIT !
#ifndef __clang__
#error "Should be compiled using clang!"
#endif

////////////////////////////////////////////////////////////////////////

namespace eventuals {
Expand Down

0 comments on commit fb5c51f

Please sign in to comment.