runtime: move the definition of report_bad_alloc_err

Use the reserved spelling for the weak attribute.  Move the definition into an
implementation file to avoid multiple definitions of the function from being
emitted.  PE/COFF does not support weak symbols, however, the runtime will never
link against LLVMSupport, so provide a single, strong definition of the
function.  Mark it as hidden visibility so that we do not expose it outside of
the runtime.
This commit is contained in:
Saleem Abdulrasool
2018-09-04 11:51:39 -07:00
parent 6f3b6182bc
commit 736fbabf92
3 changed files with 24 additions and 10 deletions

View File

@@ -0,0 +1,23 @@
//===--- LLVMSupport.cpp - Swift Language ABI Metadata Support ------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// ADT uses report_bad_alloc_error to report an error when it can't allocate
// elements for a data structure. The swift runtime uses ADT without linking
// against libSupport, so here we provide a stub to make sure we don't fail
// to link.
#if defined(swiftCore_EXPORTS)
namespace llvm {
void __attribute__((__weak__, __visibility__("hidden")))
report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {}
} // end namespace llvm
#endif