INNER CODE UNIT · Python

check_arch

JuliaLang/julia · cli/test_import_library.py:17

    def check_arch(self, arch, machine, use_lld=False):
        prefix = arch + '-w64-mingw32-'
        if not all(shutil.which(prefix + tool) for tool in ['gcc', 'dlltool', 'nm']):
            self.skipTest(prefix + ' tools unavailable')
        lld = os.environ.get('LLD', 'ld.lld')
        if use_lld and not shutil.which(lld):
            self.skipTest(lld + ' unavailable')
        with tempfile.TemporaryDirectory() as tmp:
            build = Path(tmp)
            (build / 'toy.c').write_text(
                '__declspec(dllexport) void jl_alloc_array_1d(void) {}\n'
                '__declspec(dllexport) void jl_codegen_only(void) {}\n'
                '__declspec(dllexport) int keep_data = 42;\n')
            if use_lld:
                subprocess.run([prefix + 'gcc', '-c', str(build / 'toy.c'),
                                '-o', str(build / 'toy.o')], check=True)
                subprocess.run([lld, '-m', 'i386pep' if arch == 'x86_64' else 'i386pe',
                                '-shared', '-e', 'jl_codegen_only' if arch == 'x86_64' else '_jl_codegen_only',

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…