Use System/DynamicLibrary instead of Support/DynamicLinker to implement.
[oota-llvm.git] / lib / Support / PluginLoader.cpp
1 //===-- PluginLoader.cpp - Implement -load command line option ------------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the -load <plugin> command line option handler.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #define DONT_GET_PLUGIN_LOADER_OPTION
15 #include "llvm/Support/PluginLoader.h"
16 #include "llvm/System/DynamicLibrary.h"
17 #include <iostream>
18
19 using namespace llvm;
20
21 void PluginLoader::operator=(const std::string &Filename) {
22   std::string ErrorMessage;
23   try {
24     sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str());
25   } catch (const std::string& errmsg) {
26     if (errmsg.empty()) {
27       ErrorMessage = "Unknown";
28     } else {
29       ErrorMessage = errmsg;
30     }
31   }
32   if (!ErrorMessage.empty())
33     std::cerr << "Error opening '" << Filename << "': " << ErrorMessage
34               << "\n  -load request ignored.\n";        
35 }