IQ.Pilot Release Commit @ 40589c1
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import ctypes, subprocess
|
||||
import ctypes, subprocess, signal
|
||||
from tinygrad.device import Compiler
|
||||
from tinygrad.helpers import getenv, capstone_flatdump, DEBUG, unwrap
|
||||
from tinygrad.runtime.support.elf import jit_loader
|
||||
from tinygrad.runtime.autogen import llvm
|
||||
|
||||
def _block_sigusr2():
|
||||
try: signal.pthread_sigmask(signal.SIG_BLOCK, {signal.SIGUSR2})
|
||||
except (ValueError, OSError): pass
|
||||
|
||||
class ClangCompiler(Compiler):
|
||||
def __init__(self, arch:list[str], cachekey="compile_clang_jit"):
|
||||
assert len(arch) >= 2, f"invalid arch string: {','.join(arch)!r}, expected '<arch>,<cpu>,[<feats>]' (eg. 'x86_64,znver2')"
|
||||
@@ -21,7 +25,8 @@ class ClangCompiler(Compiler):
|
||||
"""Compile C source to ELF object file (before linking)."""
|
||||
# -fno-math-errno is required for __builtin_sqrt to become an instruction instead of a function call
|
||||
return subprocess.check_output([getenv("CC", 'clang'), '-c', '-x', 'c', '-O2', '-fPIC', '-ffreestanding', '-fno-math-errno', '-nostdlib',
|
||||
'-fno-ident', f'--target={self.arch}-none-unknown-elf', *self.args, '-', '-o', '-'], input=src.encode('utf-8'))
|
||||
'-fno-ident', f'--target={self.arch}-none-unknown-elf', *self.args, '-', '-o', '-'], input=src.encode('utf-8'),
|
||||
preexec_fn=_block_sigusr2)
|
||||
|
||||
def compile(self, src:str) -> bytes: return jit_loader(self.compile_to_obj(src))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user