-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃憢 Hey, This PR adds support for the Webassembly Text Language (#1871). Currently it only supports the [wasmtime](https://github.com/bytecodealliance/wasmtime) compiler, but it should be possible to add others (i.e. v8 / wasmer / etc...). It looks like the monaco does not support the WAT language, so I've added a simple mode for it, that is mostly copied from the clojure mode with some changes. From what I've tested it seems to work reasonably well. ![image](https://github.com/compiler-explorer/compiler-explorer/assets/1357143/9e38b28e-235c-47e5-a71e-50217e5d2056) --------- Co-authored-by: Patrick Quist <partouf@gmail.com>
- Loading branch information
Showing
12 changed files
with
868 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
compilers=&wasmtime | ||
objdumper=llvm-objdump | ||
objdumperType=llvm | ||
binaryHideFuncRe=^.*::(:?native_to_wasm_trampoline|wasm_to_native_trampoline|array_to_wasm_trampoline).*$ | ||
|
||
group.wasmtime.compilers=wasmtime2001 | ||
group.wasmtime.compilerType=wasmtime | ||
group.wasmtime.options=-Ddebug-info=y -Ccache=n | ||
group.wasmtime.supportsBinary=true | ||
group.wasmtime.supportsBinaryObject=true | ||
group.wasmtime.versionFlag=--version | ||
group.wasmtime.isSemVer=true | ||
group.wasmtime.baseName=Wasmtime | ||
|
||
compiler.wasmtime2001.exe=/opt/compiler-explorer/wasmtime-20.0.1/wasmtime | ||
compiler.wasmtime2001.semver=20.0.1 | ||
|
||
################################# | ||
################################# | ||
# Installed libs (See c++.amazon.properties for a scheme of libs group) | ||
libs= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Default settings for Wasm | ||
compilers=&wasmtimelocal | ||
objdumper=llvm-objdump | ||
objdumperType=llvm | ||
binaryHideFuncRe=^.*::(:?native_to_wasm_trampoline|wasm_to_native_trampoline|array_to_wasm_trampoline).*$ | ||
|
||
group.wasmtimelocal.compilers=wasmtimedefault | ||
group.wasmtimelocal.compilerType=wasmtime | ||
group.wasmtimelocal.options=-Ddebug-info=y -Ccache=n | ||
group.wasmtimelocal.supportsBinary=true | ||
group.wasmtimelocal.supportsBinaryObject=true | ||
group.wasmtimelocal.versionFlag=--version | ||
|
||
compiler.wasmtimedefault.exe=/opt/compiler-explorer/wasmtime-20.0.1/wasmtime | ||
compiler.wasmtimedefault.name=Wasmtime default | ||
|
||
################################# | ||
################################# | ||
# Installed libs (See c++.amazon.properties for a scheme of libs group) | ||
libs= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(module | ||
(func $square (param i32) (result i32) | ||
local.get 0 | ||
local.get 0 | ||
i32.mul | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) 2024, 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 path from 'path'; | ||
|
||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; | ||
import {BaseCompiler} from '../base-compiler.js'; | ||
|
||
import {WasmtimeParser} from './argument-parsers.js'; | ||
|
||
export class WasmtimeCompiler extends BaseCompiler { | ||
static get key() { | ||
return 'wasmtime'; | ||
} | ||
|
||
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string, userOptions?: string[]) { | ||
filters.binary = true; | ||
return ['-o', this.filename(outputFilename)]; | ||
} | ||
|
||
override orderArguments( | ||
options: string[], | ||
inputFilename: string, | ||
libIncludes: string[], | ||
libOptions: string[], | ||
libPaths: string[], | ||
libLinks: string[], | ||
userOptions: string[], | ||
staticLibLinks: string[], | ||
): string[] { | ||
return ['compile', inputFilename] | ||
.concat(options) | ||
.concat(libIncludes, libOptions, libPaths, libLinks, userOptions, staticLibLinks); | ||
} | ||
|
||
override getOutputFilename(dirPath: string, outputFilebase: string): string { | ||
return path.join(dirPath, `${outputFilebase}.cwasm`); | ||
} | ||
|
||
override getArgumentParser() { | ||
return WasmtimeParser; | ||
} | ||
|
||
override getSharedLibraryPathsAsArguments() { | ||
// Wasmtime does not have an equivalent to -Wl,-rpath in its driver, return | ||
// an empty list. | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.