2312 Commits
Author SHA1 Message Date
David Spickett 4e272f73c0 flang: Use -masm to enable Intel syntax (#6145)
Since
https://github.com/llvm/llvm-project/commit/9ca1a1575a337931d0e49859f83a0d5b70916abd,
flang supports the use of `-masm` without having to use `-mllvm`. flang
converts this into `-mllvm...` so the result is the same.

The check still looks for `-mllvm`, as this is the best way to tell
flang and flang-to-external-fc apart. As `-masm` doesn't appear in the
--help output of flang.
2024-02-19 17:48:40 -06:00
Marc Auberer 9fa88d50d5 [Spice] Add std dir to default exec options (#6146) 2024-02-15 12:37:20 +01:00
Patrick Quist 9c5a6d3d95 Clang time trace support in execution pane (#6139) 2024-02-14 19:09:31 +01:00
David Spickett 282637dd0f flang: Enable the Intel asm syntax option (#6128)
flang-new doesn't support `-masm=intel` (though it seems likely it
eventually will), so this uses `-mllvm ...` to achieve the same thing.

flang-to-external-fc is a wrapper script that will be removed once
flang-new becomes flang, so it is not being updated and won't support
-masm or -mllvm ever.

(and you'll get the same output by choosing a gfortran compiler, since
that's what the script uses for codegen)
2024-02-12 21:53:13 -06:00
Marc Auberer c8f0409c25 Accept tail calls for llvm.dbg filters (#6129)
This adds support for filtering tail calls to `llvm.dbg.*` intrinsics
using the regex-based filter mechanism.
Previously, normal calls were filtered out, but tail calls are not
caught by the regex so they remained in the output.
Example with the previous state: https://play.spicelang.com/z/MGGn98
2024-02-12 21:52:45 -06:00
Marc Auberer 54dda76f22 New language: Spice (#6105)
Add support for the Spice programming language.

Spice (`spicelang`) is a simple, AOT compiled, LLVM-based systems
language with focus on practicality and performance.

**Key features of Spice**
- simplicity - see what you get aproach with batteries included
- performance: As Spice uses LLVM as its primary backbone, it competes
with the performance of other LLVM-based compilers
- enhanced safety: Spice implements an enhanced safety mechanism, which
includes builtin heap type with auto-free and more
- cross-compile support: Currently x86_64, AArch64 and wasm32 are
supported cross-compilation targets, but more to come
- Pretty good C and C++ interop

**Links**
- Source code: https://github.com/spicelang/spice
- Website: https://spicelang.com
- Playground (own CE instance): https://play.spicelang.com
- Infra PR: https://github.com/compiler-explorer/infra/pull/1229

**Things this PR addresses**
- General support for Spice
- Three code examples
- Spice mode (Syntax highlighting)
- Opt pipeline support
- LLVM mca and osaca support
2024-02-12 21:50:33 -06:00
Andrea TomasiandMatt Godbolt 4d39fdddb8 View Erlang jitted assembly (#6104)
Hi, this PR adds a way to view the assemply code of Erlang code.

Since OTP 24 inside the Erlang VM there is a jitter that runs while we
load the code.

The standard way to dump the asm code is to pass an option during the
startup. The main issue is that this triggers the dump of all the
modules we are loading (and it is slow).
To avoid this I'm using some instrinsics of OTP 26 but at least we dump
only what we need.

(I'm planning to add it to `infra` and then to awmason

Some references:
-
https://www.erlang.org/blog/otp-26-highlights/#improvements-in-the-erlang-compiler-and-jit
-
https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_bif_info.c#L5255

---------

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2024-02-12 21:49:03 -06:00
partouf b699a65984 fix 2024-02-10 13:40:10 +01:00
partouf 967e1dcf7d fix inputfilename to be correct for postprocess and move cleanup to the end 2024-02-10 13:36:19 +01:00
Ofek Shilon d8fba38400 Fix #6091: Add consideration for negative prefix matches 2024-02-10 09:22:42 +02:00
Patrick Quist 4605ebfb4b Add Fortran library support (#5533) 2024-02-09 23:31:05 +01:00
Cassandra Beckley 4006b0a941 [SPIR-V parser] Filter OpMemberName as directive (#6106)
Filter `OpMemberName` as directive, to be consistent with `OpName`.
2024-02-09 18:45:33 +01:00
Ofek Shilon 04fe14445f Fixes for two llvm-cfg glitches caught by Sentry 2024-02-09 17:58:55 +02:00
kevinjeon-g 3953a3b09c Update dex2oat version string (#6096)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE
IT
Thanks for taking the time to improve CE. We really appreciate it.
Before opening the PR, please make sure that the tests & linter pass
their checks,
  by running `make check`.
In the best case scenario, you are also adding tests to back up your
changes,
  but don't sweat it if you don't. We can discuss them at a later date.
Feel free to append your name to the CONTRIBUTORS.md file
Thanks again, we really appreciate this!
-->
2024-02-05 21:27:59 -06:00
Andrea Tomasi 1cacc9ce79 Add Elixir language support (#6081)
Hi, I am adding support for the Elixir language
(https://github.com/compiler-explorer/compiler-explorer/issues/3947)
I have done this so far. It is not perfect but at least is something I
can work with.
 
In Elixir you can write several modules in the same file, so I show the
different compile utins as a list.

It works locally but I don't know how to add the Elixir language to
[infra](https://github.com/compiler-explorer/infra/)

Some notes:
- I think Elixir's macro system may be a potential security issue
because I can run code during compilation.
- The decompiled code contains a reference to the file path on the
system machine.


![elixir_compiler](https://github.com/compiler-explorer/compiler-explorer/assets/11353602/59e46c98-646d-4275-9c03-e4097a4977ef)
2024-02-05 20:54:01 -06:00
Matt Godbolt 7ba2635029 Check for non-string values in exec's env (#6087)
- warns
- fixes the case I found
2024-02-04 17:53:48 -06:00
Patrick Quist 68efdcbd97 transform paths given through options.ldPath (#6086) 2024-02-04 16:51:46 -06:00
Matt Godbolt 01b7992ada Fix nsjail environment variables that need mapping to destination paths (#6084)
Maps env vars just like we map everything else, to catch all cases where
"app dir" is an input to jailed processes, the jailed process only sees
the "right" path (`/app/something`).

Tested locally and fixes the dot net "read only `/nosym`" thing while
keeping the `/nosym` behaviour etc
2024-02-04 13:53:50 -06:00
Matt Godbolt c26a2924fc Add more typings (#6082) 2024-02-04 13:33:19 -06:00
Ofek Shilon 31dd08be80 Capture more info on Sentry makeLlvmEdges reports 2024-02-04 21:11:35 +02:00
David Spickett 238aecd870 flang: Enable llvm-ir viewer for flang-new (#6046)
flang supports the -emit-llvm option but the difference from clang is
that while clang allows `-Xclang -emit-llvm`, flang does not allow
`-Xflang -emit-llvm`. Instead we need to use `-emit-llvm` alone.

This is a deliberate choice by the flang driver to make sure the user
isn't asking the compiler to do 2 things at once. In this case assemble
and emit llvm IR.

The way compiler explorer calls clang, the IR ends up not in the `-o`
file path but in a file named after the input file but with the
extension `.ll`. For flang we will get the IR in the file specified by
`-o`.

To handle this I've copied code from ISPCCompiler which does the same
thing. We could dedupe this, but I'm not sure whether it's worth it
while we have only 2 compilers doing this.

(clang supports `clang ... -emit-llvm` as well, so perhaps the flang
style could become the majority mode eventually)

Final note, flang-to-external-fc could support this with changes but
users are better off just using flang-new, the result is the same (as
flang-to-external-fc doesn't advertise -emit-llvm, it won't be
selectable anyway).
2024-02-03 22:27:29 +02:00
kevinjeon-g 71b2065c8c Override getVersion() for dex2oat (#6076)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE
IT
Thanks for taking the time to improve CE. We really appreciate it.
Before opening the PR, please make sure that the tests & linter pass
their checks,
  by running `make check`.
In the best case scenario, you are also adding tests to back up your
changes,
  but don't sweat it if you don't. We can discuss them at a later date.
Feel free to append your name to the CONTRIBUTORS.md file
Thanks again, we really appreciate this!
-->
2024-02-03 22:21:53 +02:00
Fábio de Souza Villaça Medeiros 56911da919 Move Hook to hook-lang organization (#6066) 2024-01-30 23:18:40 +01:00
Matt Godbolt ba215bdc37 Support a new sponsor layout (#6063) 2024-01-29 22:16:14 -06:00
Matt Godbolt 613d7f688a Unify the way tmp dir is used (#6052)
Instead of having several globals, set via environment variables,
explicitly set the "correct" env var if passed `--tmpDir` and then
consistently use it in the rest of the program.

See @apmorton's comments in #1707
2024-01-28 18:50:46 -06:00
Jeremy Rifkin c43e69bfdd Use CompilerInfo[] in a couple places that were previously any or never (#6029)
Depends on #6028
2024-01-22 21:47:45 -06:00
Jeremy Rifkin 8c1c3eab2a Add Wyrm transpiler (#6028)
https://github.com/compiler-explorer/compiler-workflows/pull/22
https://github.com/compiler-explorer/infra/pull/1218
https://github.com/compiler-explorer/misc-builder/pull/76

Depends on #6027
2024-01-21 10:43:20 -06:00
Jeremy Rifkin e5fb8e1afc Improve typings for the now-global HandlerConfig (#6027)
This PR populates types in the HandlerConfig
2024-01-21 10:29:58 -06:00
Patrick Quist 76e185b3d7 Dex2oat error handling and fixes (#6022) 2024-01-20 17:15:13 +01:00
Jeremy dab53cb916 Fix opt output to highlight as llvm ir rather than asm 2024-01-16 20:23:40 -06:00
Jeremy eddcea8171 Fix issue with llvm language detection for cfg generation, fixes #6014 2024-01-16 20:09:11 -06:00
Ofek 5b9af2f7b6 Fix #5987: make rustc generate *only* IR output in generateIR (#5988)
All compilations run asynchronously under `await Promise.all` in
`BaseCompiler.doCompilation`:

https://github.com/compiler-explorer/compiler-explorer/blob/f3277b8aed2ca12ce961d08ef792c4061a3331ac/lib/base-compiler.ts#L2256-L2263

ASM and MIR processing is done from the main `runCompiler` and IR from
the auxiliary `generateIR`. But both compilation calls are passed the
same `options` - which include `--emit asm` for generation of `output.s`
assembly file and `--emit mir=...` for generation of MIR file. So these
2 identically-named file pairs are generated *and cleaned up* in both of
the parallel compilations, sometimes one compilation cleans up its
output before the other one tries to process its own, and mayhem ensues.

This PR makes rust's `generateIR` indeed generate *just* IR by filtering
switches.

From a design perspective: ideally CE would be more opinionated on which
outputs are generated on the main compilation and which on auxiliary
ones. I see no reason for MIR to be generated by an additional switch on
the main compilation and IR require a different compilation (there's
also something called `generateRustHir` - I don't know what it does and
am slightly afraid to ask).
I *think* most (all?) asm/IR outputs could be generated in a single main
compilation, and just post-processed for the different panes in parallel
- which could spell very good news also for servers load. But I don't
dare say anything categorical about *all* languages, compilers and
output (probably no one does). Would be happy to hear opinions.
(Anyway that's just for sake of discussion, this PR does nothing fancy
of that sort)
2024-01-16 07:27:06 +02:00
kevinjeon-g 2f6a7328b2 Add support for dex2oat (latest) (#5916)
Adds Dex2OatCompiler, which applies to the Android Java and Android
Kotlin languages. Dex2OatCompiler runs on .dex files output by
D8Compiler, which in turn runs on .class files output by JavaCompiler or
KotlinCompiler. A parser has been added for dex2oat optimization passes.
2024-01-15 15:15:05 -06:00
Ofek 696cc79133 Fix #5630: filter out --emit mir=.. in RustCompiler.buildExecutable (#5991)
With a small added ts'ification in base-compiler.
2024-01-13 22:34:39 +02:00
Ofek 21fe5523c0 Since ES6 there's no reason to use underscores map and filter (#5989)
Mindless replacements of the form 
`_.filter(options, option =>...`  --> `options.filter(option =>...`.

One not *entirely* mindless replacement at the bottom of
compiler-dropin-tool.ts :
```
-        return _.filter(pathFilteredFlags) as string[];
+        return pathFilteredFlags.filter(Boolean) as string[];
```
6 files can now stop importing underscore.
2024-01-13 18:35:11 +02:00
Ofek b9c23122be Fix a leftover case of bad file-extension replacement in rust (#5981)
Seems I missed this one when doing PR #5700. This caused *some* of the
grief mentioned in the discussion of issue #5667, but certainly not all
of it.
2024-01-12 22:29:54 +02:00
Ofek 2b917c98a9 Stop forcing debug builds in pony (#5979)
Following the discussion in #3864.

@RossSmyth  FYI
2024-01-12 18:04:23 +02:00
Ofek f2956cdce7 Fix3864: pony created an .ll file that processIrOutput didn't expect (#5977) 2024-01-12 17:57:00 +02:00
Patrick Quist 730437464d Fix semver ordering for libraries (#5959)
Fix #5951
Fix #5085

Extended the fictitious version number for non-numbers, so that trunk
can be listed higher than a `yyyymmdd` as a version (EVE uses this)
2024-01-08 22:10:25 -06:00
Anirudh Sundar Subramaniam c3f8f8665b Handle ir and machine functions separately in OptPipeline (#5902)
This patch makes a small change in how functions are handled while
parsing LLVM opt pipeline output. Specifically, it differentiates
between IR function and machine function, and while checking for the
close of function, it only checks if the corresponding function is open.

This was needed because in some targets like hexagon, the machine
functions could contain `BUNDLE`s as part of the dump and `BUNDLE`s are
also represented with opening and closing braces ({}). This was causing
assertion because the close brace for a BUNDLE was considered to be a IR
function close statement.
2024-01-08 15:32:45 -06:00
Ofek d811013363 Fix #5941: mark mrustc compilation result with languageId='c' (#5944)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE
IT
Thanks for taking the time to improve CE. We really appreciate it.
Before opening the PR, please make sure that the tests & linter pass
their checks,
  by running `make check`.
In the best case scenario, you are also adding tests to back up your
changes,
  but don't sweat it if you don't. We can discuss them at a later date.
Feel free to append your name to the CONTRIBUTORS.md file
Thanks again, we really appreciate this!
-->
2024-01-05 19:31:16 +02:00
Ofek 464536e884 Fix #5945: tiny fix to stdout-parsing regexes (#5946)
Tiny change to regexes parsing compiler stdout lines, to make them stop
classifying lines like "(0.00 s) Setup: DONE" as errors.

One could imagine other, more thorough, fixes to [this
code](https://github.com/compiler-explorer/compiler-explorer/blob/ec8f8e5d50f81f4fb65b37bc5337f1ad93784f38/lib/utils.ts#L195-L202)
- it currently attempts to capture errors from all compilers, *not*
differentiating by compiler but instead by some general output formats
(`<source>`:line:col , or "file.ext":line, etc.). I settled for a 1-char
fix that seems to makes sense by itself.
2024-01-05 19:30:36 +02:00
Ofek ec8f8e5d50 Fix #5411: generate opt-pipeline for failed comilations too (#5938) 2024-01-05 16:36:45 +02:00
partouf 3c57dca1bd fix proxy remote for cmake calls 2024-01-01 19:42:58 +01:00
Ofek a0f14383a6 Fix #5923: consider the IR comment mark ; only when outside quotes (#5929) 2023-12-31 18:07:15 +02:00
Ofek a62c5a84b5 Fix #5889: add block-lookahead logic to processAST (#5903)
The code here assumes a top-level AST subtree can be in 3 states:
1. The header line indicates it's system code (e.g. includes `/usr`
etc.)
 2. The header line indicates it's user code (includes `<source>`)
3. The header contains no such info (typically it includes `<invalid
sloc>`)

For the 3rd case this PR looks-ahead inside the current subtree and
decides based on its contents.
This is enough to filter out `<vector>` or `<string>` contents, as
demonstrated in issue #5889 (added a test). This solution holds also for
the case from issue #3849.
2023-12-28 16:10:09 +02:00
Vadim Zaliva 0781e2b1be Compilers for exectuable Cerberus CHERI C and ISO C semantics (#5864)
# Cerberus

[Cerberus](https://www.cl.cam.ac.uk/~pes20/cerberus/) offers executable
semantics for a substantial fragment of C and
CHERI-C languages. It is implemented via an elaboration into a simpler
Core language, which is displayed as the compiler
output in the Compiler Explorer. Evaluation of C programs (execution) is
also supported.

## Prerequisites

The easiest way to install both the Cerberus and Cerberus-CHERI
compilers is by using Docker:

`docker pull vzaliva/cerberus-cheri`

Then, for example, you can print the _Core_ elaboration for `test.c`
using ISO C semantics:

`docker run -v $HOME/tmp:/mnt -it vzaliva/cerberus-cheri cerberus
--pp=core --exec /mnt/test.c`

## Configuration

The file `etc/config/c.defaults.properties` defines a group of two
compilers: 'cerberus' for ISO C and 'cerberus-cheri'
for CHERI-C. It assumes that the corresponding executables are in the
path.

## Limitations and Future Improvement

Presently, only simple Core output is shown. It is not syntactically
highlighted nor linked to C source code locations.
Some potential future improvements include:

1. Error location handling in warning and error messages
2. Specifying execution flags
3. Core syntax highlighting
4. Display of AST
5. Display of other intermediate languages (Cabs, Ail)
6. Tooltips/links to the ISO C document from Core annotations

## See also:

- [Cerberus (project page)](https://www.cl.cam.ac.uk/~pes20/cerberus/)
- [Cerberus (GitHub
repository)](https://github.com/rems-project/cerberus)
- ["Formal Mechanised Semantics of CHERI C: Capabilities, Undefined
Behaviour, and Provenance" (paper,
preprint)](https://zaliva.org/cheric-asplos24.pdf)
- ["CHERI C semantics as an extension of the ISO C17 standard" (tech
report)](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-988.html)
2023-12-23 18:05:35 -06:00
J. Ryan Stinnett e7b22b41be Limit exec streams to max string length (#5898)
Some operations set `exec`'s `maxOutput` to a value larger than the max
string length. This change ensures we always cap output to the engine's
string limit (currently 512 MB in recent Node versions).

This also tweaks handling when reaching the string limit to ensure
adding the "truncated" message itself does not send us beyond the limit.
2023-12-23 17:54:46 -06:00
Ofek cc1e0ea283 Fix #5854: just filter out -E when generating IR (#5885) 2023-12-16 14:28:42 +02:00
J. Ryan Stinnett 43bdf65d54 Customise opt pipeline language by compiler (#5880)
This allows each compiler to override the default Monaco language used
by the opt pipeline view.
2023-12-12 00:54:43 -05:00