Pull in r170135 from upstream clang trunk:

Dont use/link ARCMT, StaticAnalyzer and Rewriter to clang when the user
  specifies not to. Dont build ASTMatchers with Rewriter disabled and
  StaticAnalyzer when it's disabled.

  Without all those three, the clang binary shrinks (x86_64) from ~36MB
  to ~32MB (unstripped).

To disable these clang components, and get a smaller clang binary built
and installed, set WITHOUT_CLANG_FULL in src.conf(5).  During the
initial stages of buildworld, those extra components are already
disabled automatically, to save some build time.

MFC after:	1 week
This commit is contained in:
Dimitry Andric 2013-02-02 22:28:29 +00:00
parent 757224cbdb
commit df5d2454a3
70 changed files with 218 additions and 18 deletions

View File

@ -60,6 +60,8 @@ def warn_fe_cc_log_diagnostics_failure : Warning<
"unable to open CC_LOG_DIAGNOSTICS file: %0 (using stderr)">;
def err_fe_no_pch_in_dir : Error<
"no suitable precompiled header file found in directory '%0'">;
def err_fe_action_not_available : Error<
"action %0 not compiled in">;
def warn_fe_serialized_diag_failure : Warning<
"unable to open file %0 for serializing diagnostics (%1)">,

View File

@ -31,6 +31,7 @@ using namespace clang;
static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
using namespace clang::frontend;
StringRef Action("unknown");
switch (CI.getFrontendOpts().ProgramAction) {
case ASTDeclList: return new ASTDeclListAction();
@ -42,12 +43,20 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
case DumpTokens: return new DumpTokensAction();
case EmitAssembly: return new EmitAssemblyAction();
case EmitBC: return new EmitBCAction();
#ifdef CLANG_ENABLE_REWRITER
case EmitHTML: return new HTMLPrintAction();
#else
case EmitHTML: Action = "EmitHTML"; break;
#endif
case EmitLLVM: return new EmitLLVMAction();
case EmitLLVMOnly: return new EmitLLVMOnlyAction();
case EmitCodeGenOnly: return new EmitCodeGenOnlyAction();
case EmitObj: return new EmitObjAction();
#ifdef CLANG_ENABLE_REWRITER
case FixIt: return new FixItAction();
#else
case FixIt: Action = "FixIt"; break;
#endif
case GenerateModule: return new GenerateModuleAction;
case GeneratePCH: return new GeneratePCHAction;
case GeneratePTH: return new GeneratePTHAction();
@ -74,19 +83,46 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
case PrintDeclContext: return new DeclContextPrintAction();
case PrintPreamble: return new PrintPreambleAction();
case PrintPreprocessedInput: {
if (CI.getPreprocessorOutputOpts().RewriteIncludes)
if (CI.getPreprocessorOutputOpts().RewriteIncludes) {
#ifdef CLANG_ENABLE_REWRITER
return new RewriteIncludesAction();
#else
Action = "RewriteIncludesAction";
break;
#endif
}
return new PrintPreprocessedAction();
}
#ifdef CLANG_ENABLE_REWRITER
case RewriteMacros: return new RewriteMacrosAction();
case RewriteObjC: return new RewriteObjCAction();
case RewriteTest: return new RewriteTestAction();
case RunAnalysis: return new ento::AnalysisAction();
#else
case RewriteMacros: Action = "RewriteMacros"; break;
case RewriteObjC: Action = "RewriteObjC"; break;
case RewriteTest: Action = "RewriteTest"; break;
#endif
#ifdef CLANG_ENABLE_ARCMT
case MigrateSource: return new arcmt::MigrateSourceAction();
#else
case MigrateSource: Action = "MigrateSource"; break;
#endif
#ifdef CLANG_ENABLE_STATIC_ANALYZER
case RunAnalysis: return new ento::AnalysisAction();
#else
case RunAnalysis: Action = "RunAnalysis"; break;
#endif
case RunPreprocessorOnly: return new PreprocessOnlyAction();
}
#if !defined(CLANG_ENABLE_ARCMT) || !defined(CLANG_ENABLE_STATIC_ANALYZER) \
|| !defined(CLANG_ENABLE_REWRITER)
CI.getDiagnostics().Report(diag::err_fe_action_not_available) << Action;
return 0;
#else
llvm_unreachable("Invalid program action!");
#endif
}
static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
@ -97,10 +133,13 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
const FrontendOptions &FEOpts = CI.getFrontendOpts();
#ifdef CLANG_ENABLE_REWRITER
if (FEOpts.FixAndRecompile) {
Act = new FixItRecompile(Act);
}
#endif
#ifdef CLANG_ENABLE_ARCMT
// Potentially wrap the base FE action in an ARC Migrate Tool action.
switch (FEOpts.ARCMTAction) {
case FrontendOptions::ARCMT_None:
@ -124,6 +163,7 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
FEOpts.ObjCMTAction & ~FrontendOptions::ObjCMT_Literals,
FEOpts.ObjCMTAction & ~FrontendOptions::ObjCMT_Subscripting);
}
#endif
// If there are any AST files to merge, create a frontend action
// adaptor to perform the merge.
@ -176,12 +216,14 @@ bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) {
llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args);
}
#ifdef CLANG_ENABLE_STATIC_ANALYZER
// Honor -analyzer-checker-help.
// This should happen AFTER plugins have been loaded!
if (Clang->getAnalyzerOpts()->ShowCheckerHelp) {
ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins);
return 0;
}
#endif
// If there were errors in processing arguments, don't do anything else.
bool Success = false;

View File

@ -3,8 +3,20 @@
.include <bsd.own.mk>
.if !make(install)
.if !defined(EARLY_BUILD) && defined(MK_CLANG_FULL) && ${MK_CLANG_FULL} != "no"
_libclangstaticanalyzer= \
libclangstaticanalyzercheckers \
libclangstaticanalyzercore \
libclangstaticanalyzerfrontend
_libclangarcmigrate= \
libclangarcmigrate
_libclangrewriter= \
libclangrewritecore \
libclangrewritefrontend
.endif # !EARLY_BUILD && MK_CLANG_FULL
SUBDIR= libclanganalysis \
libclangarcmigrate \
${_libclangarcmigrate} \
libclangast \
libclangbasic \
libclangcodegen \
@ -14,13 +26,10 @@ SUBDIR= libclanganalysis \
libclangfrontendtool \
libclanglex \
libclangparse \
libclangrewritecore \
libclangrewritefrontend \
${_libclangrewriter} \
libclangsema \
libclangserialization \
libclangstaticanalyzercheckers \
libclangstaticanalyzercore \
libclangstaticanalyzerfrontend \
${_libclangstaticanalyzer} \
\
libllvmanalysis \
libllvmarchive \
@ -78,8 +87,8 @@ SUBDIR+=libllvmdebuginfo \
libllvmmcdisassembler \
libllvmmcjit \
libllvmruntimedyld
.endif
.endif
.endif # MK_CLANG_EXTRAS
.endif # !make(install)
SUBDIR+= include

View File

@ -8,6 +8,12 @@ CFLAGS+= -I${LLVM_SRCS}/include -I${CLANG_SRCS}/include \
-DLLVM_ON_UNIX -DLLVM_ON_FREEBSD \
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS #-DNDEBUG
.if !defined(EARLY_BUILD) && defined(MK_CLANG_FULL) && ${MK_CLANG_FULL} != "no"
CFLAGS+= -DCLANG_ENABLE_ARCMT \
-DCLANG_ENABLE_REWRITER \
-DCLANG_ENABLE_STATIC_ANALYZER
.endif # !EARLY_BUILD && MK_CLANG_FULL
# LLVM is not strict aliasing safe as of 12/31/2011
CFLAGS+= -fno-strict-aliasing

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clanganalysis
SRCDIR= tools/clang/lib/Analysis

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangarcmigrate
SRCDIR= tools/clang/lib/ARCMigrate

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangast
SRCDIR= tools/clang/lib/AST

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangbasic
SRCDIR= tools/clang/lib/Basic

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangcodegen
SRCDIR= tools/clang/lib/CodeGen

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangdriver
SRCDIR= tools/clang/lib/Driver

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangedit
SRCDIR= tools/clang/lib/Edit

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangfrontend
SRCDIR= tools/clang/lib/Frontend

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangfrontendtool
SRCDIR= tools/clang/lib/FrontendTool

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clanglex
SRCDIR= tools/clang/lib/Lex

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangparse
SRCDIR= tools/clang/lib/Parse

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangrewritecore
SRCDIR= tools/clang/lib/Rewrite/Core

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangrewritefrontend
SRCDIR= tools/clang/lib/Rewrite/Frontend

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangsema
SRCDIR= tools/clang/lib/Sema

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangserialization
SRCDIR= tools/clang/lib/Serialization

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangstaticanalyzercheckers
SRCDIR= tools/clang/lib/StaticAnalyzer/Checkers

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangstaticanalyzercore
SRCDIR= tools/clang/lib/StaticAnalyzer/Core

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= clangstaticanalyzerfrontend
SRCDIR= tools/clang/lib/StaticAnalyzer/Frontend

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmarchive
SRCDIR= lib/Archive

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmarmasmparser
SRCDIR= lib/Target/ARM/AsmParser

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmarmcodegen
SRCDIR= lib/Target/ARM

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmarmdesc
SRCDIR= lib/Target/ARM/MCTargetDesc

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmarmdisassembler
SRCDIR= lib/Target/ARM/Disassembler

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmarminfo
SRCDIR= lib/Target/ARM/TargetInfo

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmarminstprinter
SRCDIR= lib/Target/ARM/InstPrinter

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmasmparser
SRCDIR= lib/AsmParser

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmasmprinter
SRCDIR= lib/CodeGen/AsmPrinter

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmbitreader
SRCDIR= lib/Bitcode/Reader

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmbitwriter
SRCDIR= lib/Bitcode/Writer

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmcodegen
SRCDIR= lib/CodeGen

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmcore
SRCDIR= lib/VMCore

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmdebuginfo
SRCDIR= lib/DebugInfo

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmexecutionengine
SRCDIR= lib/ExecutionEngine

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvminstcombine
SRCDIR= lib/Transforms/InstCombine

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvminstrumentation
SRCDIR= lib/Transforms/Instrumentation

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvminterpreter
SRCDIR= lib/ExecutionEngine/Interpreter

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmjit
SRCDIR= lib/ExecutionEngine/JIT

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmlinker
SRCDIR= lib/Linker

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmcdisassembler
SRCDIR= lib/MC/MCDisassembler

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmcparser
SRCDIR= lib/MC/MCParser

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmipsasmparser
SRCDIR= lib/Target/Mips/AsmParser

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmipscodegen
SRCDIR= lib/Target/Mips

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmipsdesc
SRCDIR= lib/Target/Mips/MCTargetDesc

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmipsdisassembler
SRCDIR= lib/Target/Mips/Disassembler

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmipsinfo
SRCDIR= lib/Target/Mips/TargetInfo

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmmipsinstprinter
SRCDIR= lib/Target/Mips/InstPrinter

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmobject
SRCDIR= lib/Object

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmpowerpccodegen
SRCDIR= lib/Target/PowerPC

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmpowerpcdesc
SRCDIR= lib/Target/PowerPC/MCTargetDesc

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmpowerpcinfo
SRCDIR= lib/Target/PowerPC/TargetInfo

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmpowerpcinstprinter
SRCDIR= lib/Target/PowerPC/InstPrinter

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmruntimedyld
SRCDIR= lib/ExecutionEngine/RuntimeDyld

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmselectiondag
SRCDIR= lib/CodeGen/SelectionDAG

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmtablegen
SRCDIR= lib/TableGen

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmtarget
SRCDIR= lib/Target

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmvectorize
SRCDIR= lib/Transforms/Vectorize

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmx86asmparser
SRCDIR= lib/Target/X86/AsmParser

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmx86codegen
SRCDIR= lib/Target/X86

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmx86desc
SRCDIR= lib/Target/X86/MCTargetDesc

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmx86info
SRCDIR= lib/Target/X86/TargetInfo

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmx86instprinter
SRCDIR= lib/Target/X86/InstPrinter

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= llvmx86utils
SRCDIR= lib/Target/X86/Utils

View File

@ -391,9 +391,9 @@ __T=${MACHINE_ARCH}
.endif
# Clang is only for x86 and powerpc right now, by default.
.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
__DEFAULT_YES_OPTIONS+=CLANG
__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL
.else
__DEFAULT_NO_OPTIONS+=CLANG
__DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL
.endif
# Clang the default system compiler only on x86.
.if ${__T} == "amd64" || ${__T} == "i386"
@ -524,6 +524,7 @@ MK_GDB:= no
.if ${MK_CLANG} == "no"
MK_CLANG_EXTRAS:= no
MK_CLANG_FULL:= no
MK_CLANG_IS_CC:= no
.endif

View File

@ -0,0 +1,3 @@
.\" $FreeBSD$
Set to avoid building the ARCMigrate, Rewriter and StaticAnalyzer components of
the Clang C/C++ compiler.

View File

@ -0,0 +1,3 @@
.\" $FreeBSD$
Set to build the ARCMigrate, Rewriter and StaticAnalyzer components of the
Clang C/C++ compiler.

View File

@ -35,6 +35,19 @@ TGHDRS= CC1AsOptions \
DiagnosticLexKinds \
DiagnosticSemaKinds \
Options
.if !defined(EARLY_BUILD) && defined(MK_CLANG_FULL) && ${MK_CLANG_FULL} != "no"
_clangstaticanalyzer= \
clangstaticanalyzerfrontend \
clangstaticanalyzercheckers \
clangstaticanalyzercore
_clangarcmigrate= \
clangarcmigrate
_clangrewriter= \
clangrewritefrontend \
clangrewritecore
.endif # !EARLY_BUILD && MK_CLANG_FULL
LIBDEPS=clangfrontendtool \
clangfrontend \
clangdriver \
@ -42,13 +55,10 @@ LIBDEPS=clangfrontendtool \
clangcodegen \
clangparse \
clangsema \
clangstaticanalyzerfrontend \
clangstaticanalyzercheckers \
clangstaticanalyzercore \
${_clangstaticanalyzer} \
clanganalysis \
clangarcmigrate \
clangrewritefrontend \
clangrewritecore \
${_clangarcmigrate} \
${_clangrewriter} \
clangedit \
clangast \
clanglex \