1218885Sdim//===-- MCJIT.h - MC-Based Just-In-Time Execution Engine --------*- C++ -*-===//
2218885Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6218885Sdim//
7218885Sdim//===----------------------------------------------------------------------===//
8218885Sdim//
9218885Sdim// This file forces the MCJIT to link in on certain operating systems.
10218885Sdim// (Windows).
11218885Sdim//
12218885Sdim//===----------------------------------------------------------------------===//
13218885Sdim
14249423Sdim#ifndef LLVM_EXECUTIONENGINE_MCJIT_H
15249423Sdim#define LLVM_EXECUTIONENGINE_MCJIT_H
16218885Sdim
17218885Sdim#include "llvm/ExecutionEngine/ExecutionEngine.h"
18218885Sdim#include <cstdlib>
19218885Sdim
20218885Sdimextern "C" void LLVMLinkInMCJIT();
21218885Sdim
22218885Sdimnamespace {
23218885Sdim  struct ForceMCJITLinking {
24218885Sdim    ForceMCJITLinking() {
25239462Sdim      // We must reference MCJIT in such a way that compilers will not
26218885Sdim      // delete it all as dead code, even with whole program optimization,
27218885Sdim      // yet is effectively a NO-OP. As the compiler isn't smart enough
28218885Sdim      // to know that getenv() never returns -1, this will do the job.
29218885Sdim      if (std::getenv("bar") != (char*) -1)
30218885Sdim        return;
31218885Sdim
32218885Sdim      LLVMLinkInMCJIT();
33218885Sdim    }
34218885Sdim  } ForceMCJITLinking;
35218885Sdim}
36218885Sdim
37218885Sdim#endif
38