Skip to content

Commit

Permalink
Another attempt to reduce flaky builds on GitHub.
Browse files Browse the repository at this point in the history
  • Loading branch information
phst committed Dec 22, 2021
1 parent a6e8c49 commit 53112ef
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
5 changes: 5 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def _bazel(command: str, targets: Iterable[str], *,
args.extend(targets)
env = dict(os.environ)
attempts = 1
if kernel == 'Darwin':
# We don’t need XCode, and using the Unix toolchain tends to be less
# flaky. See
# https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586.
env['BAZEL_USE_CPP_ONLY_TOOLCHAIN'] = '1'
if env.get('CI') == 'true':
# Hacks so that Bazel finds the right binaries on GitHub. See
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables.
Expand Down
23 changes: 23 additions & 0 deletions emacs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("//elisp:util.bzl", "cc_defaults")

alias(
name = "emacs",
Expand Down Expand Up @@ -204,3 +205,25 @@ constraint_value(
"@gnu_emacs_27.2//:__pkg__",
],
)

cc_defaults(
name = "defaults",
copts = [],
linkopts = select({
"//constraints:macos": [
# Override the toolchain’s “-undefined dynamic” option so that the
# configure script doesn’t incorrectly detect absent functions as
# present.
"-undefined",
"error",
],
"//conditions:default": [],
}),
visibility = [
"@gnu_emacs_26.1//:__pkg__",
"@gnu_emacs_26.2//:__pkg__",
"@gnu_emacs_26.3//:__pkg__",
"@gnu_emacs_27.1//:__pkg__",
"@gnu_emacs_27.2//:__pkg__",
],
)
11 changes: 8 additions & 3 deletions emacs/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ recommended.""",
default = "//elisp:wrapper_defaults",
providers = [CcDefaultInfo],
),
"_emacs_defaults": attr.label(
default = ":defaults",
providers = [CcDefaultInfo],
),
},
doc = """Builds Emacs from a source repository.
The resulting executable can be used to run the compiled Emacs.""",
Expand All @@ -135,10 +139,11 @@ def _install(ctx, cc_toolchain, source):
Returns:
a File representing the Emacs installation directory
"""
defaults = ctx.attr._emacs_defaults[CcDefaultInfo]
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
requested_features = defaults.features + ctx.features,
# Never instrument Emacs itself for coverage collection. It doesn’t
# hurt, but leads to needless reinstall actions when switching between
# “bazel test” and “bazel coverage”.
Expand All @@ -157,14 +162,14 @@ def _install(ctx, cc_toolchain, source):
feature_configuration = feature_configuration,
action_name = C_COMPILE_ACTION_NAME,
variables = vars,
) + fragment.copts + fragment.conlyopts + [
) + fragment.copts + fragment.conlyopts + defaults.copts + [
"-DNO_SHLWAPI_ISOS", # Work around https://bugs.gnu.org/48303
]
ldflags = cc_common.get_memory_inefficient_command_line(
feature_configuration = feature_configuration,
action_name = CPP_LINK_EXECUTABLE_ACTION_NAME,
variables = vars,
) + fragment.linkopts
) + fragment.linkopts + defaults.linkopts

# The build process needs to find some common binaries like “make” or the
# GNU coreutils.
Expand Down

0 comments on commit 53112ef

Please sign in to comment.