diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2018-08-03 23:12:37 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2018-08-03 23:12:37 +0000 |
commit | a336291ffe7ae5927e040fd3fcffb3af30d7fff5 (patch) | |
tree | 31321c6d7ac06895f0791437140b031dfbef2867 /lib/Driver/ToolChains/Darwin.cpp | |
parent | 6c542b52ff1756169b286d50ed7c35628fe2e49a (diff) |
[Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.
Libc++ needs to know when aligned allocation is supported by clang, but is
otherwise unavailable at link time. Otherwise, libc++ will incorrectly end up
generating calls to `__builtin_operator_new`/`__builtin_operator_delete` with
alignment arguments.
This patch implements the following changes:
* The `__cpp_aligned_new` feature test macro to no longer be defined when
aligned allocation is otherwise enabled but unavailable.
* The Darwin driver no longer passes `-faligned-alloc-unavailable` when the
user manually specifies `-faligned-allocation` or `-fno-aligned-allocation`.
* Instead of a warning Clang now generates a hard error when an aligned
allocation or deallocation function is referenced but unavailable.
Patch by Eric Fiselier.
Reviewers: rsmith, vsapsai, erik.pilkington, ahatanak, dexonsmith
Reviewed By: rsmith
Subscribers: Quuxplusone, cfe-commits
Differential Revision: https://reviews.llvm.org/D45015
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r-- | lib/Driver/ToolChains/Darwin.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp index 9205dd52de..dc540688d2 100644 --- a/lib/Driver/ToolChains/Darwin.cpp +++ b/lib/Driver/ToolChains/Darwin.cpp @@ -2035,7 +2035,11 @@ bool Darwin::isAlignedAllocationUnavailable() const { void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const { - if (isAlignedAllocationUnavailable()) + // Pass "-faligned-alloc-unavailable" only when the user hasn't manually + // enabled or disabled aligned allocations. + if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation, + options::OPT_fno_aligned_allocation) && + isAlignedAllocationUnavailable()) CC1Args.push_back("-faligned-alloc-unavailable"); } |