forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add link-time detection of LLVM_ABI_BREAKING_CHECKS mismatch (microso…
…ft#5380) The macro LLVM_ENABLE_ABI_BREAKING_CHECKS is moved to a new header abi-breaking.h, from llvm-config.h. Only headers that are using the macro are including this new header. LLVM will define a symbol, either EnableABIBreakingChecks or DisableABIBreakingChecks depending on the configuration setting for LLVM_ABI_BREAKING_CHECKS. The abi-breaking.h header will add weak references to these symbols in every clients that includes this header. This should ensure that a mismatch triggers a link failure (or a load time failure for DSO). On MSVC, the pragma "detect_mismatch" is used instead. Differential Revision: https://reviews.llvm.org/D26876 llvm-svn: 288082 Co-authored-by: Mehdi Amini <[email protected]>
- Loading branch information
Showing
8 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/ | ||
/* */ | ||
/* The LLVM Compiler Infrastructure */ | ||
/* */ | ||
/* This file is distributed under the University of Illinois Open Source */ | ||
/* License. See LICENSE.TXT for details. */ | ||
/* */ | ||
/*===----------------------------------------------------------------------===*/ | ||
|
||
/* This file controls the C++ ABI break introduced in LLVM public header. */ | ||
|
||
#ifndef LLVM_ABI_BREAKING_CHECKS_H | ||
#define LLVM_ABI_BREAKING_CHECKS_H | ||
|
||
/* Define to enable checks that alter the LLVM C++ ABI */ | ||
#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS | ||
|
||
// ABI_BREAKING_CHECKS protection: provides link-time failure when clients build | ||
// mismatch with LLVM | ||
#if defined(_MSC_VER) | ||
// Use pragma with MSVC | ||
#define LLVM_XSTR(s) LLVM_STR(s) | ||
#define LLVM_STR(s) #s | ||
#pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS)) | ||
#undef LLVM_XSTR | ||
#undef LLVM_STR | ||
#elif defined(__cplusplus) | ||
namespace llvm { | ||
#if LLVM_ENABLE_ABI_BREAKING_CHECKS | ||
extern int EnableABIBreakingChecks; | ||
__attribute__((weak, visibility ("hidden"))) int *VerifyEnableABIBreakingChecks = &EnableABIBreakingChecks; | ||
#else | ||
extern int DisableABIBreakingChecks; | ||
__attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks; | ||
#endif | ||
} | ||
#endif // _MSC_VER | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters