From: Chris Lattner Date: Fri, 13 Mar 2009 22:38:49 +0000 (+0000) Subject: wire up a new -fno-builtin option, make it control things like simplifylibcalls, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7644f0726c310ec4224085eaea5f9aff8b957d90;p=clang wire up a new -fno-builtin option, make it control things like simplifylibcalls, etc and make freestanding imply it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66972 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/clang.cpp b/Driver/clang.cpp index b33f3443e5..6d9aaa7f75 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -230,6 +230,11 @@ Freestanding("ffreestanding", llvm::cl::desc("Assert that the compilation takes place in a " "freestanding environment")); +static llvm::cl::opt +NoBuiltin("fno-builtin", + llvm::cl::desc("Disable implicit builtin knowledge of functions")); + + static llvm::cl::opt MathErrno("fmath-errno", llvm::cl::desc("Require math functions to respect errno"), @@ -650,8 +655,11 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, if (EnableBlocks.getPosition()) Options.Blocks = EnableBlocks; + if (NoBuiltin) + Options.NoBuiltin = 1; if (Freestanding) - Options.Freestanding = 1; + Options.Freestanding = Options.NoBuiltin = 1; + if (EnableHeinousExtensions) Options.HeinousExtensions = 1; @@ -1195,7 +1203,7 @@ static void InitializeCompileOptions(CompileOptions &Opts) { // FIXME: There are llvm-gcc options to control these selectively. Opts.InlineFunctions = (Opts.OptimizationLevel > 1); Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize); - Opts.SimplifyLibCalls = !Freestanding; + Opts.SimplifyLibCalls = !NoBuiltin; #ifdef NDEBUG Opts.VerifyModule = 0; diff --git a/include/clang/AST/Builtins.h b/include/clang/AST/Builtins.h index ad71375eba..2eabd88927 100644 --- a/include/clang/AST/Builtins.h +++ b/include/clang/AST/Builtins.h @@ -56,7 +56,7 @@ public: /// appropriate builtin ID # and mark any non-portable builtin identifiers as /// such. void InitializeBuiltins(IdentifierTable &Table, const TargetInfo &Target, - bool Freestanding = false); + bool NoBuiltins = false); /// Builtin::GetName - Return the identifier name for the specified builtin, /// e.g. "__builtin_abs". diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index f0a583c3d3..ee04439cad 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -48,6 +48,7 @@ public: unsigned NeXTRuntime : 1; // Use NeXT runtime. unsigned Freestanding : 1; // Freestanding implementation + unsigned NoBuiltin : 1; // Do not use builtin functions (-fno-builtin) unsigned ThreadsafeStatics : 1; // Whether static initializers are protected // by locks. @@ -75,7 +76,7 @@ public: GC = ObjC1 = ObjC2 = ObjCNonFragileABI = 0; C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0; CXXOperatorNames = PascalStrings = Boolean = WritableStrings = 0; - Exceptions = NeXTRuntime = Freestanding = 0; + Exceptions = NeXTRuntime = Freestanding = NoBuiltin = 0; LaxVectorConversions = 1; HeinousExtensions = 0; diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a51f432880..80e17746bb 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -39,7 +39,7 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM, { if (size_reserve > 0) Types.reserve(size_reserve); InitBuiltinTypes(); - BuiltinInfo.InitializeBuiltins(idents, Target, LangOpts.Freestanding); + BuiltinInfo.InitializeBuiltins(idents, Target, LangOpts.NoBuiltin); TUDecl = TranslationUnitDecl::Create(*this); } diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index 46b0346ca4..4655cf392d 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -38,12 +38,11 @@ const Builtin::Info &Builtin::Context::GetRecord(unsigned ID) const { /// such. void Builtin::Context::InitializeBuiltins(IdentifierTable &Table, const TargetInfo &Target, - bool Freestanding) { + bool NoBuiltins) { // Step #1: mark all target-independent builtins with their ID's. for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i) if (!BuiltinInfo[i].Suppressed && - (!Freestanding || - !strchr(BuiltinInfo[i].Attributes, 'f'))) + (!NoBuiltins || !strchr(BuiltinInfo[i].Attributes, 'f'))) Table.get(BuiltinInfo[i].Name).setBuiltinID(i); // Step #2: Get target builtins. @@ -52,7 +51,7 @@ void Builtin::Context::InitializeBuiltins(IdentifierTable &Table, // Step #3: Register target-specific builtins. for (unsigned i = 0, e = NumTSRecords; i != e; ++i) if (!TSRecords[i].Suppressed && - (!Freestanding || + (!NoBuiltins || (TSRecords[i].Attributes && !strchr(TSRecords[i].Attributes, 'f')))) Table.get(TSRecords[i].Name).setBuiltinID(i+Builtin::FirstTSBuiltin);