[PATCH] D11459: [Driver] Fix handling of -fbuiltin/-fcommon when combined with -mkernel
Justin Bogner via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 7 22:48:11 PDT 2015
(resending with the list address fixed)
John Brawn <john.brawn at arm.com> writes:
> 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
Please also test the -mkernel -fbuiltin -fcommon case, but otherwise LGTM.
>
> // 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
>
More information about the cfe-commits
mailing list