mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-07-16 17:26:58 -04:00
This PR adds [CO2](https://github.com/hkalbasi/co2) which is a language backward compatible with C, with some Rust interop features that compiles to Rust's MIR. I added two compiler `co2rustc` and `co2cc`, and a tool `co2miri` which is Miri for CO2. I added `co2cc` under C compilers, to make it possible to view diff of assembly for a C code compiled with CO2 and clang or gcc. `co2cc` is a CO2 frontend which accepts gcc-like flags, and can (or at least should) compile almost every ISO compatible C23 code. `co2rustc` accepts Rust like flags, and added under a new `CO2` language. Tested locally and it seems to work. I need some help in setting up artifacts (which, if I understand correctly, needs to happen in `infra` or `compiler-workflows`). I make an artifact `co2-multicall` in my CI, which needs to get symlinked in `co2cc`, `co2rustc` and `co2miri`, and it needs to run a simple project with miri to create the miri sysroot. If you show me a similar project, I will do the job. Disclaimer: Written partially by LLM. --------- Co-authored-by: Matt Godbolt <matt@godbolt.org>
46 lines
2.1 KiB
TypeScript
46 lines
2.1 KiB
TypeScript
// Copyright (c) 2026, 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 {CompilationInfo} from '../../types/compilation/compilation.interfaces.js';
|
|
import {OptionsHandlerLibrary} from '../options-handler.js';
|
|
import {BaseTool} from './base-tool.js';
|
|
|
|
export class Co2FmtTool extends BaseTool {
|
|
static get key() {
|
|
return 'co2fmt-tool';
|
|
}
|
|
|
|
override async runTool(
|
|
compilationInfo: CompilationInfo,
|
|
inputFilepath?: string,
|
|
args?: string[],
|
|
stdin?: string,
|
|
supportedLibraries?: Record<string, OptionsHandlerLibrary>,
|
|
dontAppendInputFilepath?: boolean,
|
|
) {
|
|
const co2Filepath = inputFilepath?.replace(/\.rs$/, '.co2');
|
|
return super.runTool(compilationInfo, co2Filepath, args, stdin, supportedLibraries, dontAppendInputFilepath);
|
|
}
|
|
}
|