1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-01 16:33:37 +01:00
llvm-mirror/include/llvm/CompilerDriver/ForceLinkage.h
Mikhail Glushenkov f7b3bf53e2 Make llvmc work again.
Chris recently broke llvmc with his Makefile changes (r75379). That patch made
the global change .o -> .a, which caused built-in llvmc plugins to stop working
since plugin initialization in llvmc is based on static variables not referenced
from the main executable. This patch implements auto-generated forced references
to the plugin libraries.

llvm-svn: 74000
2009-06-23 20:46:48 +00:00

83 lines
2.0 KiB
C++

//===--- ForceLinkage.h - The LLVM Compiler Driver --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open
// Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// A bit of preprocessor magic to force references to static libraries. Needed
// because plugin initialization is done via static variables.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H
#define LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H
#include "llvm/CompilerDriver/ForceLinkageMacros.h"
namespace llvmc {
// Declare all ForceLinkage$(PluginName) functions.
#ifdef LLVMC_BUILTIN_PLUGIN_1
LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_1);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_2
LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_2);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_3
LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_3);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_4
LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_4);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_5
LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_5);
#endif
namespace force_linkage {
struct LinkageForcer {
LinkageForcer() {
// Call all ForceLinkage$(PluginName) functions.
#ifdef LLVMC_BUILTIN_PLUGIN_1
LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_1);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_2
LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_2);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_3
LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_3);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_4
LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_4);
#endif
#ifdef LLVMC_BUILTIN_PLUGIN_5
LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_5);
#endif
}
};
} // End namespace force_linkage.
// The only externally used bit.
void ForceLinkage() {
force_linkage::LinkageForcer dummy;
}
} // End namespace llvmc.
#endif // LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H