[llvm-commits] [llvm] r74417 - in /llvm/trunk: Makefile.rules include/llvm/CompilerDriver/Main.inc lib/CompilerDriver/BuiltinOptions.cpp lib/CompilerDriver/Makefile lib/CompilerDriver/Tool.cpp

Howard Su howard0su at gmail.com
Sun Jun 28 20:34:02 PDT 2009


Great. I can now wait to try. How can I compile a pass as a DLL? Can you
include a sample CMakefile?

On Mon, Jun 29, 2009 at 11:09 AM, Mikhail Glushenkov <foldr at codedgers.com>wrote:

> Author: foldr
> Date: Sun Jun 28 22:09:15 2009
> New Revision: 74417
>
> URL: http://llvm.org/viewvc/llvm-project?rev=74417&view=rev
> Log:
> Make dynamic LLVMC plugins work on Windows (finally!).
>
> Implemented by making lib/CompilerDriver a shared library that holds all
> the
> global static data (CommandLine options, plugin registry) that we
> unfortunately
> have to live with.
>
> Added:
>    llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp
> Modified:
>    llvm/trunk/Makefile.rules
>    llvm/trunk/include/llvm/CompilerDriver/Main.inc
>    llvm/trunk/lib/CompilerDriver/Makefile
>    llvm/trunk/lib/CompilerDriver/Tool.cpp
>
> Modified: llvm/trunk/Makefile.rules
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=74417&r1=74416&r2=74417&view=diff
>
>
> ==============================================================================
> --- llvm/trunk/Makefile.rules (original)
> +++ llvm/trunk/Makefile.rules Sun Jun 28 22:09:15 2009
> @@ -200,6 +200,7 @@
>  LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
>  CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
>  REQUIRES_EH := 1
> +LD.Flags += -lCompilerDriver
>
>  # Build a dynamic library if the user runs `make` directly from the plugin
>  # directory.
> @@ -217,9 +218,8 @@
>  ifdef LLVMC_BASED_DRIVER
>
>  TOOLNAME = $(LLVMC_BASED_DRIVER)
> -LLVMLIBS = CompilerDriver.a
> -LINK_COMPONENTS = support system
>  REQUIRES_EH := 1
> +LD.Flags += -lCompilerDriver
>
>  # Preprocessor magic that generates references to static variables in
> built-in
>  # plugins.
>
> Modified: llvm/trunk/include/llvm/CompilerDriver/Main.inc
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Main.inc?rev=74417&r1=74416&r2=74417&view=diff
>
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CompilerDriver/Main.inc (original)
> +++ llvm/trunk/include/llvm/CompilerDriver/Main.inc Sun Jun 28 22:09:15
> 2009
> @@ -24,8 +24,6 @@
>  #include "llvm/CompilerDriver/Plugin.h"
>
>  #include "llvm/System/Path.h"
> -#include "llvm/Support/CommandLine.h"
> -#include "llvm/Support/PluginLoader.h"
>
>  #include <iostream>
>  #include <stdexcept>
> @@ -35,42 +33,6 @@
>  namespace sys = llvm::sys;
>  using namespace llvmc;
>
> -// Built-in command-line options.
> -// External linkage here is intentional.
> -
> -cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input
> file>"),
> -                                     cl::ZeroOrMore);
> -cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
> -                                    cl::value_desc("file"), cl::Prefix);
> -cl::list<std::string> Languages("x",
> -          cl::desc("Specify the language of the following input files"),
> -          cl::ZeroOrMore);
> -cl::opt<bool> DryRun("dry-run",
> -                     cl::desc("Only pretend to run commands"));
> -cl::opt<bool> VerboseMode("v",
> -                          cl::desc("Enable verbose mode"));
> -
> -cl::opt<bool> CheckGraph("check-graph",
> -                         cl::desc("Check the compilation graph for
> errors"),
> -                         cl::Hidden);
> -cl::opt<bool> WriteGraph("write-graph",
> -                         cl::desc("Write compilation-graph.dot file"),
> -                         cl::Hidden);
> -cl::opt<bool> ViewGraph("view-graph",
> -                         cl::desc("Show compilation graph in GhostView"),
> -                         cl::Hidden);
> -
> -cl::opt<SaveTempsEnum::Values> SaveTemps
> -("save-temps", cl::desc("Keep temporary files"),
> - cl::init(SaveTempsEnum::Unset),
> - cl::values(clEnumValN(SaveTempsEnum::Obj, "obj",
> -                       "Save files in the directory specified with -o"),
> -            clEnumValN(SaveTempsEnum::Cwd, "cwd",
> -                       "Use current working directory"),
> -            clEnumValN(SaveTempsEnum::Obj, "", "Same as 'cwd'"),
> -            clEnumValEnd),
> - cl::ValueOptional);
> -
>  namespace {
>
>   sys::Path getTempDir() {
>
> Added: llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp?rev=74417&view=auto
>
>
> ==============================================================================
> --- llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp (added)
> +++ llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp Sun Jun 28 22:09:15
> 2009
> @@ -0,0 +1,52 @@
> +//===--- BuiltinOptions.cpp - 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.
> +//
>
> +//===----------------------------------------------------------------------===//
> +//
> +//  Definitions of all global command-line option variables.
> +//
>
> +//===----------------------------------------------------------------------===//
> +
> +#include "llvm/CompilerDriver/BuiltinOptions.h"
> +#include "llvm/Support/PluginLoader.h"
> +
> +namespace cl = llvm::cl;
> +
> +// External linkage here is intentional.
> +
> +cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input
> file>"),
> +                                     cl::ZeroOrMore);
> +cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
> +                                    cl::value_desc("file"), cl::Prefix);
> +cl::list<std::string> Languages("x",
> +          cl::desc("Specify the language of the following input files"),
> +          cl::ZeroOrMore);
> +cl::opt<bool> DryRun("dry-run",
> +                     cl::desc("Only pretend to run commands"));
> +cl::opt<bool> VerboseMode("v",
> +                          cl::desc("Enable verbose mode"));
> +
> +cl::opt<bool> CheckGraph("check-graph",
> +                         cl::desc("Check the compilation graph for
> errors"),
> +                         cl::Hidden);
> +cl::opt<bool> WriteGraph("write-graph",
> +                         cl::desc("Write compilation-graph.dot file"),
> +                         cl::Hidden);
> +cl::opt<bool> ViewGraph("view-graph",
> +                         cl::desc("Show compilation graph in GhostView"),
> +                         cl::Hidden);
> +
> +cl::opt<SaveTempsEnum::Values> SaveTemps
> +("save-temps", cl::desc("Keep temporary files"),
> + cl::init(SaveTempsEnum::Unset),
> + cl::values(clEnumValN(SaveTempsEnum::Obj, "obj",
> +                       "Save files in the directory specified with -o"),
> +            clEnumValN(SaveTempsEnum::Cwd, "cwd",
> +                       "Use current working directory"),
> +            clEnumValN(SaveTempsEnum::Obj, "", "Same as 'cwd'"),
> +            clEnumValEnd),
> + cl::ValueOptional);
>
> Modified: llvm/trunk/lib/CompilerDriver/Makefile
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Makefile?rev=74417&r1=74416&r2=74417&view=diff
>
>
> ==============================================================================
> --- llvm/trunk/lib/CompilerDriver/Makefile (original)
> +++ llvm/trunk/lib/CompilerDriver/Makefile Sun Jun 28 22:09:15 2009
> @@ -12,8 +12,22 @@
>  # We don't want this library to appear in `llvm-config --libs` output, so
> its
>  # name doesn't start with "LLVM".
>
> -LIBRARYNAME = CompilerDriver
> -LINK_COMPONENTS = support system
> +LIBRARYNAME = libCompilerDriver
> +LLVMLIBS = LLVMSupport.a LLVMSystem.a
> +LOADABLE_MODULE := 1
>  REQUIRES_EH := 1
>
>  include $(LEVEL)/Makefile.common
> +
> +FullLibName = $(LIBRARYNAME)$(SHLIBEXT)
> +
> +# Copy the library to the bin dir so that llvmc can find it.
> +all-local::
> +       $(Echo) Copying $(BuildMode) Shared Library $(FullLibName) \
> +       to $(ToolDir)
> +       -$(Verb) $(CP) $(LibDir)/$(FullLibName) $(ToolDir)/
> +
> +clean-local::
> +       $(Echo) Removing $(BuildMode) Shared Library $(FullLibName) \
> +       from $(ToolDir)
> +       -$(Verb) $(RM) -f $(ToolDir)/$(FullLibName)
>
> Modified: llvm/trunk/lib/CompilerDriver/Tool.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Tool.cpp?rev=74417&r1=74416&r2=74417&view=diff
>
>
> ==============================================================================
> --- llvm/trunk/lib/CompilerDriver/Tool.cpp (original)
> +++ llvm/trunk/lib/CompilerDriver/Tool.cpp Sun Jun 28 22:09:15 2009
> @@ -14,11 +14,17 @@
>  #include "llvm/CompilerDriver/BuiltinOptions.h"
>  #include "llvm/CompilerDriver/Tool.h"
>
> +#include "llvm/ADT/StringExtras.h"
>  #include "llvm/System/Path.h"
>
>  using namespace llvm;
>  using namespace llvmc;
>
> +// SplitString is used by derived Tool classes.
> +typedef void (*SplitStringFunPtr)(const std::string&,
> +                                  std::vector<std::string>&, const char*);
> +SplitStringFunPtr ForceLinkageSplitString = &llvm::SplitString;
> +
>  namespace {
>   sys::Path MakeTempFile(const sys::Path& TempDir, const std::string&
> BaseName,
>                          const std::string& Suffix) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
-Howard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090629/85037ea8/attachment.html>


More information about the llvm-commits mailing list