コード例 #1
0
def get_rustc_argv(mode='debug', target=None):
    EXTERNS = {
        "porus":
        os.path.join(
            ROOTDIR, "target/{}{}/libporus.rlib".format(
                "" if target is None else target + "/", mode)),
        "porus_macros":
        os.path.join(ROOTDIR, "target/{}/libporus_macros.so".format(mode)),
    }
    DEPS = [
        '-L',
        'dependency=' + os.path.join(ROOTDIR, "target/{}/deps".format(mode))
    ]

    VERBOSE_FLAG = '-v' if VERBOSE else '-q'
    MODE = [] if mode == 'debug' else ['--' + mode]
    TARGET = [] if target is None else ['--target', target]

    ARGV = ['cargo', 'build', VERBOSE_FLAG, '--lib'] + MODE + TARGET
    if compile_file(ROOTDIR, ARGV, 'PORUS LIB', EXTERNS["porus"]) is None:
        return

    FLAGS = os.environ.get("RUSTFLAGS",
                           "-Z borrowck=mir -Z polonius").split(" ")
    DEBUG = ['-C', 'debuginfo=2'] if mode == 'debug' else []
    return ['rustc', '-Z', 'external-macro-backtrace'
            ] + DEBUG + FLAGS + DEPS, EXTERNS
コード例 #2
0
def generate_submission(source, llvm_target):
    argv, externs = get_rustc_argv('release', llvm_target)
    target = replace_ext(source, "s")

    argv = argv + extern(externs) + [
        "--crate-type", "cdylib", "--emit", "asm", "-C",
        "llvm-args=-disable-debug-info-print", "-C", "lto=fat", "-C",
        "opt-level=2", "-C", "panic=abort", "-o", target, "-"
    ]

    if has_to_recompile(source, target, externs):
        if compile_file(ROOTDIR, argv, target, read_source(source)) is None:
            return None

    return target
コード例 #3
0
def get_rustc_argv(mode='debug', target=None):
    EXTERNS = {
        "porus":
        os.path.join(
            BUILD_PATH,
            "{}{}/libporus.rlib".format("" if target is None else target + "/",
                                        mode)),
        "porus_macros":
        os.path.join(BUILD_PATH, "{}/libporus_macros.so".format(mode)),
    }
    DEPS = [
        '-L', 'dependency=' + os.path.join(BUILD_PATH, "{}/deps".format(mode))
    ]
    if mode != 'release' and not COVERAGE:
        DEPS = [
            '-C'
            'incremental=' +
            os.path.join(BUILD_PATH, "{}/incremental".format(mode))
        ] + DEPS

    VERBOSE_FLAG = '-v' if VERBOSE else '-q'
    MODE = [] if mode == 'debug' else ['--' + mode]
    TARGET = [] if target is None else ['--target', target]
    FEATURES = []
    if target is None:
        FEATURES.append("local-judge")
    if mode == 'release':
        FEATURES.append("online-judge")

    ARGV = ['cargo'] + (['cov'] if COVERAGE else []) + [
        'build', VERBOSE_FLAG, '--lib'
    ] + MODE + TARGET + ["--features", ",".join(FEATURES)]

    if compile_file(ROOTDIR, ARGV, EXTERNS["porus"]) is None:
        return

    FEATURES = sum([["--cfg", 'feature="{}"'.format(f)] for f in FEATURES], [])
    FLAGS = os.environ.get("RUSTFLAGS",
                           "-Z borrowck=mir -Z polonius").split(" ")
    DEBUG = ['-C', 'debuginfo=2'] if mode == 'debug' else []
    return [RUSTC, '-Z', 'external-macro-backtrace'
            ] + DEBUG + FLAGS + TARGET + FEATURES + DEPS, EXTERNS