diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-01-07 01:05:02 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-01-07 01:05:02 +0000 |
commit | b466d01e464b21832c23eeed90112bc5c26c0236 (patch) | |
tree | f01b49b1ba42e7aff878a4406e9bc60515aed3fe | |
parent | a009b59fc2c550a229b9146aabda8e33fe3a7771 (diff) |
Add all options needed to support -fapple-kext. wip.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122987 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/LangOptions.h | 2 | ||||
-rw-r--r-- | include/clang/Driver/CC1Options.td | 2 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 20 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 7 | ||||
-rw-r--r-- | test/Driver/apple-kext-mkernel.c | 6 |
5 files changed, 33 insertions, 4 deletions
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index a868dbd9eb..f31c4ff6fb 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -45,6 +45,7 @@ public: unsigned ObjCNonFragileABI : 1; // Objective-C modern abi enabled unsigned ObjCNonFragileABI2 : 1; // Objective-C enhanced modern abi enabled unsigned ObjCDefaultSynthProperties : 1; // Objective-C auto-synthesized properties. + unsigned AppleKext : 1; // Allow apple kext features. unsigned PascalStrings : 1; // Allow Pascal strings unsigned WritableStrings : 1; // Allow writable strings @@ -156,6 +157,7 @@ public: GNUMode = GNUKeywords = ImplicitInt = Digraphs = 0; HexFloats = 0; GC = ObjC1 = ObjC2 = ObjCNonFragileABI = ObjCNonFragileABI2 = 0; + AppleKext = 0; ObjCDefaultSynthProperties = 0; NoConstantCFStrings = 0; InlineVisibilityHidden = 0; C99 = Microsoft = Borland = CPlusPlus = CPlusPlus0x = 0; diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 5ae7f32837..955ca72a2c 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -461,6 +461,8 @@ def fobjc_gc : Flag<"-fobjc-gc">, HelpText<"Enable Objective-C garbage collection">; def fobjc_gc_only : Flag<"-fobjc-gc-only">, HelpText<"Use GC exclusively for Objective-C related memory management">; +def fapple_kext : Flag<"-fapple-kext">, + HelpText<"Use apple's kext abi">; def fobjc_dispatch_method_EQ : Joined<"-fobjc-dispatch-method=">, HelpText<"Objective-C dispatch method to use">; def fobjc_default_synthesize_properties : Flag<"-fobjc-default-synthesize-properties">, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 9d9179b621..ee77f48c7c 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1284,6 +1284,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } + if (Args.getLastArg(options::OPT_fapple_kext)) + CmdArgs.push_back("-fapple-kext"); + Args.AddLastArg(CmdArgs, options::OPT_fno_show_column); Args.AddLastArg(CmdArgs, options::OPT_fobjc_sender_dependent_dispatch); Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_print_source_range_info); @@ -1321,8 +1324,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Forward -f options with positive and negative forms; we translate // these by hand. + if (Args.hasArg(options::OPT_mkernel)) { + if (!Args.hasArg(options::OPT_fapple_kext)) + CmdArgs.push_back("-fapple-kext"); + if (!Args.hasArg(options::OPT_fbuiltin)) + CmdArgs.push_back("-fno-builtin"); + } // -fbuiltin is default. - if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin)) + else if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin)) CmdArgs.push_back("-fno-builtin"); if (!Args.hasFlag(options::OPT_fassume_sane_operator_new, @@ -1519,9 +1528,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_mno_pascal_strings, false)) CmdArgs.push_back("-fpascal-strings"); - + + if (Args.hasArg(options::OPT_mkernel) || + Args.hasArg(options::OPT_fapple_kext)) { + if (!Args.hasArg(options::OPT_fcommon)) + CmdArgs.push_back("-fno-common"); + } // -fcommon is default, only pass non-default. - if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common)) + else if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common)) CmdArgs.push_back("-fno-common"); // -fsigned-bitfields is default, and clang doesn't yet support diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 48121a1770..aa44abf19e 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -639,6 +639,9 @@ static void LangOptsToArgs(const LangOptions &Opts, Res.push_back("-fobjc-gc-only"); } } + if (Opts.AppleKext) + Res.push_back("-fapple-kext"); + if (Opts.getVisibilityMode() != DefaultVisibility) { Res.push_back("-fvisibility"); if (Opts.getVisibilityMode() == HiddenVisibility) { @@ -1351,7 +1354,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.setGCMode(LangOptions::GCOnly); else if (Args.hasArg(OPT_fobjc_gc)) Opts.setGCMode(LangOptions::HybridGC); - + + if (Args.hasArg(OPT_fapple_kext)) + Opts.AppleKext = 1; if (Args.hasArg(OPT_print_ivar_layout)) Opts.ObjCGCBitmapPrint = 1; if (Args.hasArg(OPT_fno_constant_cfstrings)) diff --git a/test/Driver/apple-kext-mkernel.c b/test/Driver/apple-kext-mkernel.c new file mode 100644 index 0000000000..712dfc8d0e --- /dev/null +++ b/test/Driver/apple-kext-mkernel.c @@ -0,0 +1,6 @@ +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -mkernel -### -fsyntax-only %s 2> %t +// RUN grep "-disable-red-zone" %t +// RUN grep "-fapple-kext" %t +// RUN grep "-fno-builtin" %t +// RUN grep "-fno-rtti" %t +// RUN grep "-fno-common" %t |