[PATCH] D11459: [Driver] Fix handling of -fbuiltin/-fcommon when combined with -mkernel
John Brawn
john.brawn at arm.com
Thu Jul 23 06:48:55 PDT 2015
john.brawn created this revision.
john.brawn added reviewers: ddunbar, mcrosier.
john.brawn added a subscriber: cfe-commits.
john.brawn set the repository for this revision to rL LLVM.
-mkernel enables -fno-builtin and -fno-common by default, but allows -fbuiltin and -fcommon to override that. However "-fbuiltin -fno-builtin" is treated the same as "-fbuiltin" which is wrong, so fix that. Also fixes similar behaviour when -fno-common is default.
Repository:
rL LLVM
http://reviews.llvm.org/D11459
Files:
lib/Driver/Tools.cpp
test/Driver/apple-kext-mkernel.c
Index: test/Driver/apple-kext-mkernel.c
===================================================================
--- test/Driver/apple-kext-mkernel.c
+++ test/Driver/apple-kext-mkernel.c
@@ -1,15 +1,13 @@
-// RUN: %clang -target x86_64-apple-darwin10 \
-// RUN: -mkernel -### -fsyntax-only %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-X86 < %t %s
+// RUN: %clang -target x86_64-apple-darwin10 -mkernel -### -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-X86 %s
+// RUN: %clang -target x86_64-apple-darwin10 -mkernel -### -fsyntax-only -fbuiltin -fno-builtin -fcommon -fno-common %s 2>&1 | FileCheck --check-prefix=CHECK-X86 %s
// CHECK-X86: "-disable-red-zone"
// CHECK-X86: "-fno-builtin"
// CHECK-X86: "-fno-rtti"
// CHECK-X86: "-fno-common"
-// RUN: %clang -target x86_64-apple-darwin10 \
-// RUN: -arch armv7 -mkernel -mstrict-align -### -fsyntax-only %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ARM < %t %s
+// RUN: %clang -target x86_64-apple-darwin10 -arch armv7 -mkernel -mstrict-align -### -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-ARM %s
+// RUN: %clang -target x86_64-apple-darwin10 -arch armv7 -mkernel -mstrict-align -### -fsyntax-only -fbuiltin -fno-builtin -fcommon -fno-common %s 2>&1 | FileCheck --check-prefix=CHECK-ARM %s
// CHECK-ARM: "-target-feature" "+long-calls"
// CHECK-ARM: "-backend-option" "-arm-strict-align"
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4013,7 +4013,8 @@
options::OPT_fno_lax_vector_conversions))
CmdArgs.push_back("-fno-lax-vector-conversions");
- if (Args.getLastArg(options::OPT_fapple_kext))
+ if (Args.getLastArg(options::OPT_fapple_kext) ||
+ (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
CmdArgs.push_back("-fapple-kext");
Args.AddLastArg(CmdArgs, options::OPT_fobjc_sender_dependent_dispatch);
@@ -4147,15 +4148,9 @@
A->render(Args, CmdArgs);
}
- if (Args.hasArg(options::OPT_mkernel)) {
- if (!Args.hasArg(options::OPT_fapple_kext) && types::isCXX(InputType))
- CmdArgs.push_back("-fapple-kext");
- if (!Args.hasArg(options::OPT_fbuiltin))
- CmdArgs.push_back("-fno-builtin");
- Args.ClaimAllArgs(options::OPT_fno_builtin);
- }
- // -fbuiltin is default.
- else if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin))
+ // -fbuiltin is default unless -mkernel is used
+ if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin,
+ !Args.hasArg(options::OPT_mkernel)))
CmdArgs.push_back("-fno-builtin");
if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
@@ -4556,14 +4551,11 @@
}
}
- if (KernelOrKext || isNoCommonDefault(getToolChain().getTriple())) {
- if (!Args.hasArg(options::OPT_fcommon))
- CmdArgs.push_back("-fno-common");
- Args.ClaimAllArgs(options::OPT_fno_common);
- }
-
- // -fcommon is default, only pass non-default.
- else if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common))
+ // -fcommon is the default unless compiling kernel code or the target says so
+ bool NoCommonDefault =
+ KernelOrKext || isNoCommonDefault(getToolChain().getTriple());
+ if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common,
+ !NoCommonDefault))
CmdArgs.push_back("-fno-common");
// -fsigned-bitfields is default, and clang doesn't yet support
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11459.30478.patch
Type: text/x-patch
Size: 3481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150723/e3edf9d7/attachment.bin>
More information about the cfe-commits
mailing list