117680Spst//===-- Interpreter.h - Abstract Execution Engine Interface -----*- C++ -*-===//
239297Sfenner//
317680Spst//                     The LLVM Compiler Infrastructure
417680Spst//
517680Spst// This file is distributed under the University of Illinois Open Source
617680Spst// License. See LICENSE.TXT for details.
717680Spst//
817680Spst//===----------------------------------------------------------------------===//
917680Spst//
1017680Spst// This file forces the interpreter to link in on certain operating systems.
1117680Spst// (Windows).
1217680Spst//
1317680Spst//===----------------------------------------------------------------------===//
1417680Spst
1517680Spst#ifndef LLVM_EXECUTIONENGINE_INTERPRETER_H
1617680Spst#define LLVM_EXECUTIONENGINE_INTERPRETER_H
1717680Spst
1817680Spst#include "llvm/ExecutionEngine/ExecutionEngine.h"
1917680Spst#include <cstdlib>
2017680Spst
21190207Srpauloextern "C" void LLVMLinkInInterpreter();
2217680Spst
2317680Spstnamespace {
2417680Spst  struct ForceInterpreterLinking {
2517680Spst    ForceInterpreterLinking() {
2617680Spst      // We must reference the interpreter in such a way that compilers will not
2717680Spst      // delete it all as dead code, even with whole program optimization,
2817680Spst      // yet is effectively a NO-OP. As the compiler isn't smart enough
2917680Spst      // to know that getenv() never returns -1, this will do the job.
3017680Spst      if (std::getenv("bar") != (char*) -1)
31        return;
32
33      LLVMLinkInInterpreter();
34    }
35  } ForceInterpreterLinking;
36}
37
38#endif
39