From e0c2b5e700aef751efa31625c19e507a3b5d82ae Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:28:09 -0500 Subject: [PATCH] Add the movfuscator (#5193) Resolves #985 Builder: https://github.com/compiler-explorer/misc-builder/pull/65 Infra: https://github.com/compiler-explorer/infra/pull/1041 --- etc/config/c.amazon.properties | 17 +++++++++++- lib/base-compiler.ts | 2 +- lib/compilers/_all.ts | 1 + lib/compilers/movfuscator.ts | 47 ++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 lib/compilers/movfuscator.ts diff --git a/etc/config/c.amazon.properties b/etc/config/c.amazon.properties index 203956c39..a4665b1dd 100644 --- a/etc/config/c.amazon.properties +++ b/etc/config/c.amazon.properties @@ -1,4 +1,4 @@ -compilers=&cgcc86:&cclang:&armcclang32:&armcclang64:&cmosclang-trunk:&rvcclang:&wasmcclang:&ppci:&cicc:&cicx:&ccl:&ccross:&cgcc-classic:&cc65:&sdcc:&ctendra:&tinycc:&zigcc:&cproc86:&chibicc:&z88dk:&compcert:www.godbolt.ms@443:godbolt.org@443/winprod +compilers=&cgcc86:&cclang:&armcclang32:&armcclang64:&cmosclang-trunk:&rvcclang:&wasmcclang:&ppci:&cicc:&cicx:&ccl:&ccross:&cgcc-classic:&cc65:&sdcc:&ctendra:&tinycc:&zigcc:&cproc86:&chibicc:&z88dk:&compcert:www.godbolt.ms@443:godbolt.org@443/winprod:&movfuscator defaultCompiler=cg131 demangler=/opt/compiler-explorer/gcc-13.1.0/bin/c++filt objdumper=/opt/compiler-explorer/gcc-13.1.0/bin/objdump @@ -2459,6 +2459,21 @@ compiler.ccx8632_310.semver=3.10 compiler.ccx8632_309.exe=/opt/compiler-explorer/compcert/CompCert-x86_32-3.9/bin/ccomp compiler.ccx8632_309.semver=3.9 +################################# +# Movfuscator compiler +group.movfuscator.compilers=movfuscatortrunk +group.movfuscator.groupName=Movfuscator +group.movfuscator.baseName=movfuscator +group.movfuscator.versionFlag=--version +group.movfuscator.supportsBinary=true +group.movfuscator.licenseLink=https://github.com/xoreaxeaxeax/movfuscator/blob/master/LICENSE +group.movfuscator.licenseName=BSD Style License +group.movfuscator.compilerType=movfuscator + +compiler.movfuscatortrunk.exe=/opt/compiler-explorer/movfuscator-trunk/build/lcc +compiler.movfuscatortrunk.semver=(trunk) +compiler.movfuscatortrunk.name=movfuscator (trunk) + ################################# ################################# # Libraries diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index c5d6448c3..85a878cc6 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -408,7 +408,7 @@ export class BaseCompiler implements ICompiler { const key = this.getCompilerCacheKey(compiler, args, optionsForCache); let result = await this.env.compilerCacheGet(key as any); if (!result) { - result = await this.env.enqueue(async () => await exec.execute(compiler, args, options)); + result = await this.env.enqueue(async () => await this.exec(compiler, args, options)); if (result.okToCache) { this.env .compilerCachePut(key as any, result, undefined) diff --git a/lib/compilers/_all.ts b/lib/compilers/_all.ts index 2d6578d52..a66343ecd 100644 --- a/lib/compilers/_all.ts +++ b/lib/compilers/_all.ts @@ -74,6 +74,7 @@ export {LDCCompiler} from './ldc.js'; export {LLCCompiler} from './llc.js'; export {LLVMmcaTool} from './llvm-mca.js'; export {LLVMMOSCompiler} from './llvm-mos.js'; +export {MovfuscatorCompiler} from './movfuscator.js'; export {MLIRCompiler} from './mlir.js'; export {GM2Compiler} from './gm2.js'; export {MrustcCompiler} from './mrustc.js'; diff --git a/lib/compilers/movfuscator.ts b/lib/compilers/movfuscator.ts new file mode 100644 index 000000000..3a0ddf69a --- /dev/null +++ b/lib/compilers/movfuscator.ts @@ -0,0 +1,47 @@ +// Copyright (c) 2023, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import {ExecutionOptions} from '../../types/compilation/compilation.interfaces.js'; +import {BaseCompiler} from '../base-compiler.js'; +import * as exec from '../exec.js'; + +export class MovfuscatorCompiler extends BaseCompiler { + static get key() { + return 'movfuscator'; + } + + override isCfgCompiler(compilerVersion: string) { + return true; + } + + override async exec(filepath: string, args: string[], execOptions: ExecutionOptions) { + return await exec.execute(filepath, args, { + ...execOptions, + env: { + MOVBUILDDIR: '/opt/compiler-explorer/movfuscator-trunk/build', + ...execOptions.env, + }, + }); + } +}