예제 #1
0
    def __init__(self, name, sources, libraries=None, optimization_level=3,
                 cflags=None, language='c'):
        self.name = __name__ + '.' + name
        self.sources = sources
        self.cflags = cflags
        self.libraries = libraries or ()
        self.optimization_level = optimization_level
        self.language = language
        self.module = self._create_module_from_source_files(sources)
        for l in self.libraries:
            lc.load_library_permanently(find_library(l))
        self.module.verify()
        eb = ee.EngineBuilder.new(self.module).opt(optimization_level)
        self._ee = eb.create()
        self._ufunc_cache = {}

        initializer = self._extract_initializer()
        if initializer:
            self._ee.run_function(initializer, [])
예제 #2
0
 def add_shared_library(self, filename):
     "Load the shared library 'filename'"
     return llvm_c.load_library_permanently(filename)
예제 #3
0
import sys
import os.path
import subprocess
from cStringIO import StringIO
from shutil import copyfileobj
from ctypes.util import find_library

import llvm.core as lc
import llvm.ee as ee

from .builder import make_ufunc, UFUNC_PREFIX

lc.load_library_permanently(find_library('stdc++'))

class CModule(object):
    BITCODE_EXT = '.bc'
    ATEXIT_NAME = '__cxa_atexit'
    INITIALIZER_NAME = '__cxx_global_var_init'

    _stdout = None
    _stderr = None

    _destructor = None


    def __init__(self, name, sources, libraries=None, optimization_level=3,
                 cflags=None, language='c'):
        self.name = __name__ + '.' + name
        self.sources = sources
        self.cflags = cflags
        self.libraries = libraries or ()