Bug 1062219 - Don't build build/clang-plugin as an external directory. r=jcranmer

This commit is contained in:
Mike Hommey 2014-09-04 17:44:01 +09:00
parent c5c27fe755
commit 51f6cc88c1
15 changed files with 154 additions and 183 deletions

View File

@ -315,27 +315,4 @@ config/export:
endif
# Interdependencies for parallel export.
js/xpconnect/src/export: dom/bindings/export xpcom/xpidl/export
accessible/xpcom/export: xpcom/xpidl/export
ifdef ENABLE_CLANG_PLUGIN
js/src/export config/host: build/clang-plugin/export
endif
# Interdependencies that moz.build world don't know about yet for compilation.
# Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk3)
toolkit/library/target: widget/gtk/mozgtk/gtk3/target
endif
ifdef MOZ_LDAP_XPCOM
ldap/target: config/external/nss/target mozglue/build/target
toolkit/library/target: ldap/target
endif
ifndef MOZ_FOLD_LIBS
ifndef MOZ_NATIVE_SQLITE
config/external/nss/target: db/sqlite3/src/target
endif
endif
ifeq ($(MOZ_REPLACE_MALLOC_LINKAGE),dummy library)
mozglue/build/target: memory/replace/dummy/target
endif
# There used to be build interdependencies here. They are now in config/recurse.mk

1
aclocal.m4 vendored
View File

@ -34,6 +34,7 @@ builtin(include, build/autoconf/python-virtualenv.m4)dnl
builtin(include, build/autoconf/winsdk.m4)dnl
builtin(include, build/autoconf/icu.m4)dnl
builtin(include, build/autoconf/ffi.m4)dnl
builtin(include, build/autoconf/clang-plugin.m4)dnl
MOZ_PROG_CHECKMSYS()

View File

@ -0,0 +1,56 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_CONFIG_CLANG_PLUGIN], [
MOZ_ARG_ENABLE_BOOL(clang-plugin,
[ --enable-clang-plugin Enable building with the mozilla clang plugin ],
ENABLE_CLANG_PLUGIN=1,
ENABLE_CLANG_PLUGIN= )
if test -n "$ENABLE_CLANG_PLUGIN"; then
if test -z "$CLANG_CC"; then
AC_MSG_ERROR([Can't use clang plugin without clang.])
fi
AC_MSG_CHECKING([for llvm-config])
if test -z "$LLVMCONFIG"; then
LLVMCONFIG=`which llvm-config`
fi
if test -z "$LLVMCONFIG"; then
LLVMCONFIG=`$CXX -print-prog-name=llvm-config`
fi
if test ! -x "$LLVMCONFIG"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Cannot find an llvm-config binary for building a clang plugin])
fi
AC_MSG_RESULT([$LLVMCONFIG])
if test -z "$LLVMCONFIG"; then
AC_MSG_ERROR([Cannot find an llvm-config binary for building a clang plugin])
fi
LLVM_CXXFLAGS=`$LLVMCONFIG --cxxflags`
LLVM_LDFLAGS=`$LLVMCONFIG --ldflags --libs core mc analysis asmparser mcparser bitreader | xargs`
if test "${OS_ARCH}" = "Darwin"; then
CLANG_LDFLAGS="-lclangFrontend -lclangDriver -lclangSerialization"
CLANG_LDFLAGS="$CLANG_LDFLAGS -lclangParse -lclangSema -lclangAnalysis"
CLANG_LDFLAGS="$CLANG_LDFLAGS -lclangEdit -lclangAST -lclangLex"
CLANG_LDFLAGS="$CLANG_LDFLAGS -lclangBasic -lclangASTMatchers"
else
CLANG_LDFLAGS="-lclangASTMatchers"
fi
AC_DEFINE(MOZ_CLANG_PLUGIN)
fi
AC_SUBST(LLVM_CXXFLAGS)
AC_SUBST(LLVM_LDFLAGS)
AC_SUBST(CLANG_LDFLAGS)
AC_SUBST(ENABLE_CLANG_PLUGIN)
])

View File

@ -2,58 +2,16 @@
# 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/.
CXX := @CXX@
CXXFLAGS := @CXXFLAGS@
LDFLAGS := @LDFLAGS@
VPATH := @srcdir@
DSO_LDOPTS := @DSO_LDOPTS@
DLL_SUFFIX := @DLL_SUFFIX@
# LLVM_CXXFLAGS comes with its own optimization flags.
MOZ_OPTIMIZE =
# Helper for end
NULL :=
MOZ_GLUE_LDFLAGS =
CPPSRCS := \
clang-plugin.cpp \
$(NULL)
include $(topsrcdir)/config/config.mk
TESTSRCS := \
TestCustomHeap.cpp \
TestMustOverride.cpp \
TestNonHeapClass.cpp \
TestStackClass.cpp \
$(NULL)
OBJS := $(patsubst %.cpp,%.o,$(CPPSRCS))
TESTS := $(patsubst %.cpp,test-%,$(TESTSRCS))
PLUGIN := libclang-plugin.$(DLL_SUFFIX)
all: $(PLUGIN) $(TESTS)
$(OBJS): %.o: %.cpp Makefile
$(CXX) -o $@ -c $(CXXFLAGS) $<
$(PLUGIN): $(OBJS)
rm -f $@
$(CXX) $(DSO_LDOPTS) -o $@ $(CXXFLAGS) $(OBJS) $(LDFLAGS)
TESTFLAGS := -fsyntax-only -Xclang -verify \
-Xclang -load -Xclang $(CURDIR)/$(PLUGIN) \
-Xclang -add-plugin -Xclang moz-check
$(TESTS): test-%: tests/%.cpp $(PLUGIN)
$(CXX) $(TESTFLAGS) $<
compile libs export tools: all
distclean clean:
rm -f $(OBJS) $(TESTS) $(PLUGIN)
check:
libs: binaries
binaries: all
@touch $@
.PHONY: compile libs export tools distclean clean check
# 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.
OS_CXXFLAGS := $(LLVM_CXXFLAGS) -fno-rtti -fno-exceptions
OS_COMPILE_CXXFLAGS :=
OS_LDFLAGS := $(LLVM_LDFLAGS) $(CLANG_LDFLAGS)
DSO_LDOPTS := -shared

View File

@ -1,67 +0,0 @@
#!/bin/sh
PLATFORM=`uname`
# Default srcdir to this directory
srcdir=$(dirname $0)
for option; do
case "$option" in
-*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$option" in
--srcdir=*) srcdir="$optarg";;
esac
done
if test -z "$CXX"; then
CXX=`which clang++`
fi
echo -n "checking for llvm-config... "
if test -z "$LLVMCONFIG"; then
LLVMCONFIG=`which llvm-config`
fi
if test -z "$LLVMCONFIG"; then
LLVMCONFIG=`dirname $CXX`/llvm-config
fi
if test ! -x "$LLVMCONFIG"; then
echo "configure: error: Cannot find an llvm-config binary for building a clang plugin" 1>&2
exit 1
fi
echo "$LLVMCONFIG"
LLVMLIBS="core mc analysis asmparser mcparser bitreader"
LLVMCXXFLAGS=`$LLVMCONFIG --cxxflags`
LLVMLDFLAGS=`$LLVMCONFIG --ldflags`
LLVMLDFLAGS="$LLVMLDFLAGS `$LLVMCONFIG --libs $LLVMLIBS`"
if [ $PLATFORM == Darwin ]; then
DSO_LDOPTS="-dynamiclib -shared"
CLANGLDFLAGS="-lclangFrontend -lclangDriver -lclangSerialization \
-lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST \
-lclangLex -lclangBasic -lclangASTMatchers"
DLL_SUFFIX="dylib"
else
DSO_LDOPTS="-shared"
CLANGLDFLAGS=-lclangASTMatchers
DLL_SUFFIX="so"
fi
CXXFLAGS="$CXXFLAGS $LLVMCXXFLAGS -fno-rtti -fno-exceptions"
LDFLAGS="$LDFLAGS $LLVMLDFLAGS $CLANGLDFLAGS"
cat $srcdir/Makefile.in | sed \
-e "s%@CXX@%$CXX%" \
-e "s%@CXXFLAGS@%$CXXFLAGS%" \
-e "s%@LDFLAGS@%$LDFLAGS%" \
-e "s%@srcdir@%$srcdir%" \
-e "s%@DSO_LDOPTS@%$DSO_LDOPTS%" \
-e "s%@DLL_SUFFIX@%$DLL_SUFFIX%" \
> Makefile

View File

@ -0,0 +1,18 @@
# -*- 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/.
SharedLibrary('clang-plugin')
SOURCES += [
'clang-plugin.cpp',
]
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True
DIRS += [
'tests',
]

View File

@ -0,0 +1,14 @@
# 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/.
# Build without any warning flags, and with clang verify flag for a
# syntax-only build (no codegen).
OS_CXXFLAGS := $(filter-out -W%,$(OS_CXXFLAGS)) -fsyntax-only -Xclang -verify
include $(topsrcdir)/config/rules.mk
target:: $(OBJS)
# We don't actually build anything.
.PHONY: $(OBJS)

View File

@ -0,0 +1,15 @@
# -*- 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/.
SOURCES += [
'TestCustomHeap.cpp',
'TestMustOverride.cpp',
'TestNonHeapClass.cpp',
'TestStackClass.cpp',
]
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True

View File

@ -3,6 +3,7 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
NO_EXPAND_LIBS = 1
ENABLE_CLANG_PLUGIN :=
include $(topsrcdir)/config/rules.mk

View File

@ -75,16 +75,14 @@ endif
# TIERS (like for js/src).
CURRENT_DIRS := $($(CURRENT_TIER)_dirs)
# The compile tier has different rules from other tiers.
ifeq ($(CURRENT_TIER),compile)
# Need a list of compile targets because we can't use pattern rules:
# https://savannah.gnu.org/bugs/index.php?42833
.PHONY: $(compile_targets)
$(compile_targets):
$(call SUBMAKE,$(@F),$(@D))
else
# The compile tier has different rules from other tiers.
ifneq ($(CURRENT_TIER),compile)
# Recursion rule for all directories traversed for all subtiers in the
# current tier.
@ -108,11 +106,6 @@ $(addsuffix /$(CURRENT_TIER),$(filter-out config,$(CURRENT_DIRS))): config/$(CUR
# nsinstall.py there.
ifneq (,$(filter config/host, $(compile_targets)))
$(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): config/host
# Ensure rules for config/host and its possible dependencies.
.PHONY: $(filter %/host, $(compile_targets))
$(filter %/host, $(compile_targets)):
$(call SUBMAKE,host,$(@D))
endif
endif
@ -163,3 +156,32 @@ endif # ifeq (.,$(DEPTH))
recurse:
@$(RECURSED_COMMAND)
$(LOOP_OVER_DIRS)
ifeq (.,$(DEPTH))
# Interdependencies for parallel export.
js/xpconnect/src/export: dom/bindings/export xpcom/xpidl/export
accessible/xpcom/export: xpcom/xpidl/export
ifdef ENABLE_CLANG_PLUGIN
$(filter-out build/clang-plugin/%,$(compile_targets)): build/clang-plugin/target build/clang-plugin/tests/target
build/clang-plugin/tests/target: build/clang-plugin/target
endif
# Interdependencies that moz.build world don't know about yet for compilation.
# Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk3)
toolkit/library/target: widget/gtk/mozgtk/gtk3/target
endif
ifdef MOZ_LDAP_XPCOM
ldap/target: config/external/nss/target mozglue/build/target
toolkit/library/target: ldap/target
endif
ifndef MOZ_FOLD_LIBS
ifndef MOZ_NATIVE_SQLITE
config/external/nss/target: db/sqlite3/src/target
endif
endif
ifeq ($(MOZ_REPLACE_MALLOC_LINKAGE),dummy library)
mozglue/build/target: memory/replace/dummy/target
endif
endif

View File

@ -7250,18 +7250,7 @@ dnl ========================================================
dnl = Enable using the clang plugin to build
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(clang-plugin,
[ --enable-clang-plugin Enable building with the mozilla clang plugin ],
ENABLE_CLANG_PLUGIN=1,
ENABLE_CLANG_PLUGIN= )
if test -n "$ENABLE_CLANG_PLUGIN"; then
if test -z "$CLANG_CC"; then
AC_MSG_ERROR([Can't use clang plugin without clang.])
fi
AC_DEFINE(MOZ_CLANG_PLUGIN)
fi
AC_SUBST(ENABLE_CLANG_PLUGIN)
MOZ_CONFIG_CLANG_PLUGIN
dnl ========================================================
dnl = Enable stripping of libs & executables
@ -9112,11 +9101,6 @@ HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
RC=
if test -n "$ENABLE_CLANG_PLUGIN"; then
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
AC_OUTPUT_SUBDIRS(build/clang-plugin)
fi
# Run the SpiderMonkey 'configure' script.
dist=$MOZ_BUILD_ROOT/dist
ac_configure_args="$_SUBDIR_CONFIG_ARGS"

1
js/src/aclocal.m4 vendored
View File

@ -33,6 +33,7 @@ builtin(include, ../../build/autoconf/python-virtualenv.m4)dnl
builtin(include, ../../build/autoconf/winsdk.m4)dnl
builtin(include, ../../build/autoconf/icu.m4)dnl
builtin(include, ../../build/autoconf/ffi.m4)dnl
builtin(include, ../../build/autoconf/clang-plugin.m4)dnl
define([__MOZ_AC_INIT_PREPARE], defn([AC_INIT_PREPARE]))
define([AC_INIT_PREPARE],

View File

@ -3389,18 +3389,7 @@ dnl ========================================================
dnl = Enable using the clang plugin to build
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(clang-plugin,
[ --enable-clang-plugin Enable building with the mozilla clang plugin ],
ENABLE_CLANG_PLUGIN=1,
ENABLE_CLANG_PLUGIN= )
if test -n "$ENABLE_CLANG_PLUGIN"; then
if test -z "$CLANG_CC"; then
AC_MSG_ERROR([Can't use clang plugin without clang.])
fi
AC_DEFINE(MOZ_CLANG_PLUGIN)
fi
AC_SUBST(ENABLE_CLANG_PLUGIN)
MOZ_CONFIG_CLANG_PLUGIN
dnl ========================================================
dnl = Enable static checking using sixgill

View File

@ -10,7 +10,7 @@ CONFIGURE_SUBST_FILES += [
]
if CONFIG['ENABLE_CLANG_PLUGIN']:
add_tier_dir('base', 'build/clang-plugin', external=True)
add_tier_dir('base', 'build/clang-plugin')
add_tier_dir('base', ['config', 'python'])
if not CONFIG['JS_STANDALONE']:

View File

@ -1182,7 +1182,9 @@ class RecursiveMakeBackend(CommonBackend):
# we build depends on it.
if obj.KIND == 'target' and not isinstance(obj, StaticLibrary) and \
build_target != 'mozglue/build/target' and \
not obj.config.substs.get('JS_STANDALONE'):
not obj.config.substs.get('JS_STANDALONE') and \
(not isinstance(obj, SharedLibrary) or
obj.basename != 'clang-plugin'):
self._compile_graph[build_target].add('mozglue/build/target')
if obj.config.substs.get('MOZ_MEMORY'):
self._compile_graph[build_target].add('memory/build/target')