Skip to content

Commit

Permalink
Merge pull request #2210 from hawkeye116477/classic_build
Browse files Browse the repository at this point in the history
[Classic] Compile with a C++14-compatible mode and cleanup a little
  • Loading branch information
MrAlex94 authored Aug 20, 2021
2 parents 0906204 + 152251a commit e8e6c9d
Show file tree
Hide file tree
Showing 83 changed files with 411 additions and 945 deletions.
5 changes: 0 additions & 5 deletions Android.mk

This file was deleted.

11 changes: 0 additions & 11 deletions accessible/jsat/PointerAdapter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ var PointerRelay = { // jshint ignore:line
'touchend': true };
break;

case 'gonk':
this._eventsOfInterest = {
'touchstart': true,
'touchmove': true,
'touchend': true,
'mousedown': false,
'mousemove': false,
'mouseup': false,
'click': false };
break;

default:
// Desktop.
this._eventsOfInterest = {
Expand Down
1 change: 0 additions & 1 deletion build/gyp.mozbuild
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ gyp_vars.update({
'arm_neon': 0,
'arm_neon_optional': 1,

'moz_widget_toolkit_gonk': 0,
'moz_webrtc_omx': 0,
'moz_webrtc_mediacodec': 0,

Expand Down
150 changes: 113 additions & 37 deletions build/moz.configure/compile-checks.configure
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,25 @@ def check_headers(*headers, **kwargs):
return checks


@dependable
def warnings_cflags():
return []

@dependable
def warnings_cxxflags():
return []


# Tests whether GCC or clang support the given warning flag, and if it is,
# add it to the list of warning flags for the build.
# - `warning` is the warning flag (e.g. -Wfoo)
# Determine whether to add a given flag to the given lists of flags for C or
# C++ compilation.
# - `flag` is the flag to test
# - `cflags` is a @depends function for the list of C compiler flags to add to
# - `cxxflags` is a @depends function for the list of C++ compiler flags to
# add to
# - `test_flags` is a list of flags to pass to the compiler instead of merely
# passing `flag`. This is especially useful for checking warning flags. If
# this list is empty, `flag` will be passed on its own.
# - `compiler` (optional) is the compiler to test against (c_compiler or
# cxx_compiler, from toolchain.configure). When omitted, both compilers
# are tested.
# are tested; the list of flags added to is dependent on the compiler tested.
# - `when` (optional) is a @depends function or option name conditioning
# when the warning flag is wanted.
# - `check`, when not set, skips checking whether the flag is supported and
# adds it to the list of warning flags unconditionally. This is only meant
# for add_gcc_warning().
# adds it to the list of flags unconditionally.
@template
def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
def check_and_add_flags(flag, cflags, cxxflags, test_flags,
compiler=None, when=None, check=True):
if compiler is not None:
compilers = (compiler,)
else:
Expand All @@ -106,26 +103,20 @@ def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
if when is None:
when = always

results = []

if test_flags:
flags = test_flags
else:
flags = [flag]

for c in compilers:
assert c in (c_compiler, cxx_compiler)
lang, warnings_flags = {
c_compiler: ('C', warnings_cflags),
cxx_compiler: ('C++', warnings_cxxflags),
lang, list_of_flags = {
c_compiler: ('C', cflags),
cxx_compiler: ('C++', cxxflags),
}[c]

# GCC and clang will fail if given an unknown warning option like
# -Wfoobar. But later versions won't fail if given an unknown negated
# warning option like -Wno-foobar. So when we are checking for support
# of a negated warning option, we actually test the positive form, but
# add the negated form to the flags variable.
if (warning.startswith('-Wno-') and
not warning.startswith('-Wno-error=')):
flags = ['-Werror', '-W' + warning[5:]]
elif warning.startswith('-Werror='):
flags = [warning]
else:
flags = ['-Werror', warning]

@depends(c, when)
def result(c, when):
if when and c.type in ('clang', 'gcc'):
Expand All @@ -134,13 +125,56 @@ def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
if check:
result = c.try_compile(
flags=flags, when=result,
check_msg='whether the %s compiler supports %s' % (lang,
warning))
check_msg='whether the %s compiler supports %s' % (lang, flag))

@depends(result, warnings_flags)
def maybe_add_flag(result, warnings_flags):
@depends(result, list_of_flags)
def maybe_add_flag(result, list_of_flags):
if result:
warnings_flags.append(warning)
list_of_flags.append(flag)

results.append(result)

return tuple(results)


@dependable
def warnings_cflags():
return []


@dependable
def warnings_cxxflags():
return []


# Tests whether GCC or clang support the given warning flag, and if it is,
# add it to the list of warning flags for the build.
# - `warning` is the warning flag (e.g. -Wfoo)
# - `compiler` (optional) is the compiler to test against (c_compiler or
# cxx_compiler, from toolchain.configure). When omitted, both compilers
# are tested.
# - `when` (optional) is a @depends function or option name conditioning
# when the warning flag is wanted.
# - `check`, when not set, skips checking whether the flag is supported and
# adds it to the list of warning flags unconditionally. This is only meant
# for add_gcc_warning().
@template
def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
# GCC and clang will fail if given an unknown warning option like
# -Wfoobar. But later versions won't fail if given an unknown negated
# warning option like -Wno-foobar. So when we are checking for support
# of a negated warning option, we actually test the positive form, but
# add the negated form to the flags variable.
if warning.startswith('-Wno-') and not warning.startswith('-Wno-error='):
flags = ['-Werror', '-W' + warning[5:]]
elif warning.startswith('-Werror='):
flags = [warning]
else:
flags = ['-Werror', warning]

return check_and_add_flags(warning, warnings_cflags, warnings_cxxflags,
flags, compiler=compiler, when=when, check=check)


# Add the given warning to the list of warning flags for the build.
# - `warning` is the warning flag (e.g. -Wfoo)
Expand All @@ -152,3 +186,45 @@ def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
@template
def add_gcc_warning(warning, compiler=None, when=None):
check_and_add_gcc_warning(warning, compiler, when, check=False)


# Like the warning checks above, but for general compilation flags.
@dependable
def compilation_cflags():
return []


@dependable
def compilation_cxxflags():
return []


# Tests whether GCC or clang support the given compilation flag; if the flag
# is supported, add it to the list of compilation flags for the build.
# - `flag` is the flag to test
# - `compiler` (optional) is the compiler to test against (c_compiler or
# cxx_compiler, from toolchain.configure). When omitted, both compilers
# are tested.
# - `when` (optional) is a @depends function or option name conditioning
# when the warning flag is wanted.
# - `check`, when not set, skips checking whether the flag is supported and
# adds it to the list of flags unconditionally. This is only meant for
# add_gcc_flag().
@template
def check_and_add_gcc_flag(flag, compiler=None, when=None, check=True):
flags = ['-Werror', flag]

return check_and_add_flags(flag, compilation_cflags, compilation_cxxflags,
flags, compiler=compiler, when=when, check=check)


# Add the given flag to the list of flags for the build.
# - `flag` is the flag (e.g. -fno-sized-deallocation)
# - `compiler` (optional) is the compiler to add the flag for (c_compiler or
# cxx_compiler, from toolchain.configure). When omitted, the flag is added
# for both compilers.
# - `when` (optional) is a @depends function or option name conditioning
# when the flag is wanted.
@template
def add_gcc_flag(warning, compiler=None, when=None):
check_and_add_gcc_flag(warning, compiler, when, check=False)
13 changes: 13 additions & 0 deletions build/moz.configure/flags.configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# We support C++14, but we don't want to enable the sized deallocation
# facilities in C++14 yet.
check_and_add_gcc_flag('-fno-sized-deallocation', compiler=cxx_compiler)

# Please keep these last in this file.
add_old_configure_assignment('_COMPILATION_CFLAGS', compilation_cflags)
add_old_configure_assignment('_COMPILATION_CXXFLAGS', compilation_cxxflags)
27 changes: 4 additions & 23 deletions build/moz.configure/memory.configure
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def jemalloc(value, target, build_project, c_compiler):
if target.kernel == 'Linux':
return True

if value and target.kernel not in ('WINNT', 'Linux', 'Darwin', 'kFreeBSD',
'FreeBSD', 'NetBSD'):
die('--enable-jemalloc is not supported on %s', target.kernel)


set_config('MOZ_MEMORY', jemalloc)
set_define('MOZ_MEMORY', jemalloc)
Expand All @@ -47,29 +51,6 @@ def jemalloc_for_old_configure(jemalloc):
add_old_configure_arg(jemalloc_for_old_configure)


@depends(jemalloc, target)
def jemalloc_os_define(jemalloc, target):
if jemalloc:
if target.kernel == 'WINNT':
return 'MOZ_MEMORY_WINDOWS'
if target.kernel == 'Linux':
return 'MOZ_MEMORY_LINUX'
if target.kernel == 'Darwin':
return 'MOZ_MEMORY_DARWIN'
if target.kernel in ('kFreeBSD', 'FreeBSD', 'NetBSD'):
return 'MOZ_MEMORY_BSD'
die('--enable-jemalloc is not supported on %s', target.kernel)

set_define(jemalloc_os_define, '1')

@depends(jemalloc, target)
def jemalloc_os_define_android(jemalloc, target):
if jemalloc and target.os == 'Android':
return 'MOZ_MEMORY_ANDROID'

set_define(jemalloc_os_define_android, '1')


option('--enable-replace-malloc',
help='Enable ability to dynamically replace the malloc implementation')

Expand Down
44 changes: 29 additions & 15 deletions build/moz.configure/toolchain.configure
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,24 @@ def check_compiler(compiler, language, target):
if info.type in ('clang-cl', 'clang', 'gcc'):
append_flag('-std=gnu99')

# Note: MSVC, while supporting C++11, still reports 199711L for __cplusplus.
# Note: MSVC, while supporting C++14, still reports 199711L for __cplusplus.
# Note: this is a strict version check because we used to always add
# -std=gnu++11.
# -std=gnu++14.
draft_cxx14_version = 201300
cxx14_version = 201402
if info.language == 'C++':
if info.type in ('clang', 'gcc') and info.language_version != 201103:
append_flag('-std=gnu++11')
if info.type == 'clang' and info.language_version != cxx14_version:
append_flag('-std=gnu++14')
# MSVC 2015 headers include C++14 features, but don't guard them
# with appropriate checks.
if info.type == 'clang-cl' and info.language_version != 201402:
elif info.type == 'clang-cl' and info.language_version != cxx14_version:
append_flag('-std=c++14')
# GCC 4.9 indicates that it implements draft C++14 features
# instead of the full language.
elif info.type == 'gcc' and \
info.language_version not in (draft_cxx14_version,
cxx14_version):
append_flag('-std=gnu++14')

# We force clang-cl to emulate Visual C++ 2017 version 15.4
if info.type == 'clang-cl' and info.version != '19.11.25547':
Expand Down Expand Up @@ -803,11 +811,17 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
host_or_target)

# Check that the additional flags we got are enough to not require any
# more flags.
if info.flags:
flags += info.flags
info = check_compiler(wrapper + [compiler] + flags, language,
host_or_target)
# more flags. If we get an exception, just ignore it; it's liable to be
# invalid command-line flags, which means the compiler we're checking
# doesn't support those command-line flags and will fail one or more of
# the checks below.
try:
if info.flags:
flags += info.flags
info = check_compiler(wrapper + [compiler] + flags, language,
host_or_target)
except FatalCheckError:
pass

if not info.target_cpu or info.target_cpu != host_or_target.cpu:
raise FatalCheckError(
Expand All @@ -833,10 +847,6 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
info.target_endianness or 'unknown', host_or_target_str,
host_or_target.endianness))

if info.flags:
raise FatalCheckError(
'Unknown compiler or compiler not supported.')

# Compiler version checks
# ===================================================
# Check the compiler version here instead of in `compiler_version` so
Expand All @@ -848,7 +858,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
% info.version)

# If you want to bump the version check here search for
# __cpp_static_assert above, and see the associated comment.
# cxx_alignof above, and see the associated comment.
if info.type == 'clang' and not info.version:
raise FatalCheckError(
'Only clang/llvm 3.6 or newer is supported.')
Expand All @@ -863,6 +873,10 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
'See https://developer.mozilla.org/en/'
'Windows_Build_Prerequisites' % info.version)

if info.flags:
raise FatalCheckError(
'Unknown compiler or compiler not supported.')

return namespace(
wrapper=wrapper,
compiler=compiler,
Expand Down
Loading

0 comments on commit e8e6c9d

Please sign in to comment.