Skip to content

Commit

Permalink
Bug 1403346 - Implement clang-plugin cxxflags in moz.build. r=glandium
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 9zSryJcTRGl
  • Loading branch information
chmanchester committed Oct 25, 2017
1 parent f09fbe0 commit d43c1ef
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
6 changes: 1 addition & 5 deletions build/clang-plugin/Makefile.in
Expand Up @@ -9,13 +9,9 @@ include $(topsrcdir)/config/config.mk

# In the current moz.build world, we need to override essentially every
# variable to limit ourselves to what we need to build the clang plugin.
ifeq ($(HOST_OS_ARCH),WINNT)
OS_CXXFLAGS := $(LLVM_CXXFLAGS) -GR- -EHsc
else
OS_CXXFLAGS := $(LLVM_CXXFLAGS) -fno-rtti -fno-exceptions
ifneq ($(HOST_OS_ARCH),WINNT)
DSO_LDOPTS := -shared
endif
OS_COMPILE_CXXFLAGS :=
OS_LDFLAGS := $(LLVM_LDFLAGS) $(CLANG_LDFLAGS)

ifeq ($(HOST_OS_ARCH)_$(OS_ARCH),Linux_Darwin)
Expand Down
16 changes: 16 additions & 0 deletions build/clang-plugin/moz.build
Expand Up @@ -59,3 +59,19 @@ if CONFIG['HOST_OS_ARCH'] == 'Darwin':
DIRS += [
'tests',
]


# In the current moz.build world, we need to override essentially every
# variable to limit ourselves to what we need to build the clang plugin.
if CONFIG['HOST_OS_ARCH'] == 'WINNT':
extra_cxxflags = ['-GR-', '-EHsc']
else:
extra_cxxflags = ['-fno-rtti', '-fno-exceptions']

if CONFIG['LLVM_CXXFLAGS']:
COMPILE_FLAGS['OS_CXXFLAGS'] = CONFIG['LLVM_CXXFLAGS'] + extra_cxxflags

COMPILE_FLAGS['CLANG_PLUGIN'] = []
COMPILE_FLAGS['OPTIMIZE'] = []
COMPILE_FLAGS['DEBUG'] = []
COMPILE_FLAGS['OS_COMPILE_CXXFLAGS'] = []
5 changes: 0 additions & 5 deletions build/clang-plugin/tests/Makefile.in
Expand Up @@ -2,11 +2,6 @@
# 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/.

# Build without any warning flags, and with clang verify flag for a
# syntax-only build (no codegen), without a limit on the number of errors.
OS_CFLAGS := $(filter-out -W%,$(OS_CFLAGS)) -fsyntax-only -Xclang -verify -ferror-limit=0 -std=c11 -Wno-invalid-noreturn
OS_CXXFLAGS := $(filter-out -W%,$(OS_CXXFLAGS)) -fsyntax-only -Xclang -verify -ferror-limit=0 -Wno-invalid-noreturn

include $(topsrcdir)/config/rules.mk

target:: $(OBJS)
Expand Down
12 changes: 12 additions & 0 deletions build/clang-plugin/tests/moz.build
Expand Up @@ -47,3 +47,15 @@ SOURCES += [

DisableStlWrapping()
NoVisibilityFlags()

# Build without any warning flags, and with clang verify flag for a
# syntax-only build (no codegen), without a limit on the number of errors.
COMPILE_FLAGS['OS_CXXFLAGS'] = (
[f for f in COMPILE_FLAGS.get('OS_CXXFLAGS', []) if not f.startswith('-W')] +
['-fsyntax-only', '-Xclang', '-verify', '-ferror-limit=0', '-Wno-invalid-noreturn']
)
COMPILE_FLAGS['OS_CFLAGS'] = (
[f for f in COMPILE_FLAGS.get('OS_CFLAGS', []) if not f.startswith('-W')] +
['-fsyntax-only', '-Xclang', '-verify', '-ferror-limit=0', '-std=c11',
'-Wno-invalid-noreturn']
)
3 changes: 0 additions & 3 deletions config/static-checking-config.mk
Expand Up @@ -13,7 +13,4 @@ ifeq ($(OS_ARCH),WINNT)
CC := $(subst clang-cl.exe,clang.exe --driver-mode=cl,$(CC:.EXE=.exe))
CXX := $(subst clang-cl.exe,clang.exe --driver-mode=cl,$(CXX:.EXE=.exe))
endif

OS_CXXFLAGS += $(CLANG_PLUGIN_FLAGS)
OS_CFLAGS += $(CLANG_PLUGIN_FLAGS)
endif
4 changes: 3 additions & 1 deletion python/mozbuild/mozbuild/frontend/context.py
Expand Up @@ -338,6 +338,8 @@ def __init__(self, context):
('DEBUG', (context.config.substs['MOZ_DEBUG_FLAGS'].split() if
'MOZ_DEBUG_FLAGS' in context.config.substs else []),
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('CLANG_PLUGIN', context.config.substs.get('CLANG_PLUGIN_FLAGS'),
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('OPTIMIZE', self._optimize_flags(),
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('FRAMEPTR', context.config.substs.get('MOZ_FRAMEPTR_FLAGS'),
Expand Down Expand Up @@ -393,7 +395,7 @@ def __setitem__(self, key, value):
if key in self and self[key] is None:
raise ValueError('`%s` may not be set in COMPILE_FLAGS from moz.build, this '
'value is resolved from the emitter.' % key)
if not (isinstance(value, list) and all(isinstance(v, unicode) for v in value)):
if not (isinstance(value, list) and all(isinstance(v, basestring) for v in value)):
raise ValueError('A list of strings must be provided as a value for a '
'compile flags category.')
dict.__setitem__(self, key, value)
Expand Down

0 comments on commit d43c1ef

Please sign in to comment.