2915 Commits
Author SHA1 Message Date
Patrick Quist d420b3e8b1 Fix the executor's "All compilation options" popover (#9089) 2026-09-02 19:40:00 +02:00
narpfel 18bfed2b3c Show compilation options button in more places (#8960) 2026-09-02 18:57:41 +02:00
Alex Smolya b85f518625 fix: propagate libPath to Cargo IDE execution (#9069) 2026-08-27 22:58:30 +02:00
cb1d043257 Mask temp paths on the compilation cache-hit path (#9057)
### The bug

`cachePut()` stores the compilation result **before** `cleanupResult()`
masks it, and the cache-hit path returns the stored value directly. So
we cache an unmasked result, and every subsequent hit serves it
verbatim.

### What you see

The compilation-options popover shows a different command line for a
warm compile than for a cold one of the same input, naming a temp dir
that belonged to an unrelated earlier request:

```
cold:  -o output.s ... example.cpp
warm:  -o /tmp/compiler-explorer-compilerAbC123/output.s ... /tmp/compiler-explorer-compilerAbC123/example.cpp
```

`inputFilename` gets the same treatment, since `cleanupResult()` masks
both.

Cosmetic rather than a disclosure problem: the temp dir name isn't
sensitive. The reason it's worth fixing is that it means the masking
added in #9033 only ever takes effect on cold compiles, so on a warm
instance most users see the unmasked form.

### The fix

Move `cleanupResult()` above `cachePut()`, so what we store is what we'd
have shown. One statement, no new call site.

Nothing between the two positions reads the fields being masked: the
intervening block only touches `result.execResult` and its
`buildResult`.

### Scope

This covers the main compilation cache path. Two other `cachePut()` call
sites exist, and I have **not** verified them here: the execution cache,
and the cmake `fullResult` path (which caches with `delayCaching` and
whose inner `fullResult.result.compilationOptions` isn't reached by
`cleanupResult()` anyway, since that only masks top level). Worth a look
separately.

Also still unmasked on every path: `irOutput.compilationOptions` and
`optPipelineOutput.compilationOptions`. Being handled as part of the
review of #8960, which adds the panes that surface them.

### On existing cache entries

No migration concern. Cache entries live under `cache/` in
`storage.godbolt.org`, which has a lifecycle rule expiring them after 1
day (`terraform/s3.tf`, "Remove cached items"), so anything cached
unmasked before this ships ages out by itself.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 19:41:35 -05:00
narpfel 09141c9de3 Replace exact string comparison with semver comparison for tool excludes (#9055)
The existing `clippy` excludes would need to be changed for Rust 1.100’s
release anyways (to all use `$` as e. g. `r1100` would match `r11000`),
and additionally a semver comparison is simpler for exclude lists that
exclude a larger number of versions, e. g. if someone were to add
`llvm-cov` as a tool, which is only available in Rust >= 1.49.
2026-08-24 20:24:59 -05:00
Luan Taraschi 99513c8778 Keep the /app/ prefix in the compilation options shown to the user (#9033)
Fixes #8648.

`maskRootdir` strips a leading `/app/`, so the "All compilation options"
popup shows the source as `example.cpp` while the compiler is handed
`/app/example.cpp`. The same line already shows `-I/app/include` and
`-o/app/output.s`, because those keep the prefix, so today it is
inconsistent with itself.

Checked against production before touching anything, compiling `const
char* f = __FILE__;`:

```
compilationOptions: ['-g', '-o', 'output.s', '-masm=intel', '-fno-verbose-asm', '-S', '-fdiagnostics-color=always', '-O0', 'example.cpp']
asm:                .string "/app/example.cpp"
```

That is what makes it worth fixing rather than cosmetic: `__FILE__` in
C, `file!()` in Rust and anything else that echoes the input path give
the user a value the popup contradicts.

The change adds `maskRootdirKeepingAppPrefix` and uses it in
`maskPathsInArgumentsForUser`, which is the only caller feeding that
popup. Output lines keep going through `maskRootdir`, so diagnostics are
untouched.

`npm run check` passes here except for the Maven Kotlin test, which
fails the same way on a clean checkout on this machine (symlink realpath
on Windows).

One part of the issue I did not fix: the
`/nosym/tmp/compiler-explorer-.../example.rs` path reported on the first
compilation. `maskRootdir` handles that shape correctly when I feed it
directly, so it looks like a result that never reaches the masking, and
I could not reproduce it.
2026-08-24 20:02:42 -05:00
Luan Taraschi 8040a92032 Keep inline asm directives when filtering directives (#9037)
Fixes #8964.

Directive filtering runs over the whole listing, including the region
between `#APP` and `#NO_APP`. That region is the user's own inline asm,
so filtering it changes what the block says. For the case in the issue:

```cpp
int square(int num) {
    asm(".rept 5\nnop\n.endr");
    return num * num;
}
```

`.rept 5` and `.endr` go away and a single `nop` is left, which reads as
one instruction where the source asks for five.

The parser already tracks the region: `updateParsingState` calls
`enterCustomAssembly` on `#APP` and `exitCustomAssembly` on `#NO_APP`,
and `isInCustomAssembly()` was being used only to fix label indentation.
`shouldSkipDirective` now consults it too.

### What still gets dropped

Not everything in the block is the user's. GCC interleaves its own line
markers, as @Alcaro pointed out on the issue:

```
#APP
# 3 "/app/example.cpp" 1
	.rept 5
nop
.endr
# 0 "" 2
	.loc 1 4 5 view .LVU3
# /app/example.cpp:4:     return num * num;
	.loc 1 4 18 is_stmt 0 view .LVU4
#NO_APP
```

So the rule is narrower than "skip filtering inside the block": inside
it, a directive is dropped only when it is a source-location marker.
That set is not a new list, it is the one `SourceLineHandler` already
consumes to build the source mapping (`.loc`, `.d2line`, `.cv_loc`,
`.dbg line`, `.stabn`), exposed as `isSourceLocationDirective`. Anything
the handler does not claim is text the compiler was asked to assemble,
and it stays.

The `#` lines above are comments and are unaffected, they still go with
the comment filter.

### The changed snapshots

`nvcc-x86-host-example` gains three lines: `.section .nv_fatbin, "a"`,
`.align 8` and `.text`, all inside its `#APP` block. The hundreds of
`.quad` lines in that block were already surviving the directive filter,
because `fatbinData:` sets `prevLabel` and `dataDefn` lines under a used
label are kept, so this is three lines added to output that was already
showing the blob, not the blob becoming visible.
`NvccCompiler.removeNvccFatbinaryBlob` is what actually hides it, and it
is unaffected.

No other case in `filters-cases` moves. `bug-577_gcc` and
`bug-577_clang` have `#APP` blocks with no directives in them.

### Tests

Three in `test/asm-parser-tests.ts`: the directives survive, the `.loc`
markers inside the same block still do not, and filtering resumes after
`#NO_APP`. The first and third fail on `main`. I ran the full suite in
`node:22-bookworm`, since `filter-tests.ts` returns early on Windows:
2631 passed.
2026-08-24 19:51:20 -05:00
Matt GodboltandClaude Fable 5 643b6db82a Avoid redundant serialisation work in the startup tail (#9043)
Profiling a production startup (2026-08-20, 6232 compilers) showed two
avoidable CPU costs in the last couple of seconds of startup:

- `setupCompilerChangeHandling`'s `onCompilerChange` ran
`JSON.stringify` over all 6232 compiler objects purely to detect whether
the compiler set had changed since the last discovery. The serialised
form is comparable in scale to the 74MB discovery JSON, and it was
computed (and retained in memory) even in production, where rescanning
is disabled (`rescanCompilerSecs` unset / `--prediscovered`) and so the
comparison can never trigger.
- The `OPTIONS HASH` log line appeared twice per startup:
`ClientOptionsHandler`'s constructor eagerly serialised and hashed the
options blob, only for the result to be immediately discarded and
recomputed by the first `setCompilers()` call.

Changes:

- `lib/app/compiler-changes.ts`: only do change detection when
rescanning is actually enabled, and compare a SHA-256 content hash
instead of retaining the full serialised compiler list. In production
the initial set is now applied with no serialisation at all; with
rescanning enabled, behaviour is unchanged (identical rescans are
skipped, changed sets applied) while dropping the tens-of-megabytes
retained string.
- `lib/options-handler.ts`: drop the constructor's
`_updateOptionsHash()` call. The hash/JSON are computed exactly once at
startup by the first `setCompilers()`, which always runs before the
server starts listening.

Tests: new `test/app/compiler-changes-tests.ts` covering initial
application, no rescan when prediscovered, unchanged rescans skipped,
and changed rescans applied; plus an options-handler test pinning that
the hash is only computed once compilers are set. `ts-check`, `lint`,
and the full test suite pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 19:34:52 -05:00
Luan Taraschi 575a57bef1 Store S3 cache objects as STANDARD rather than reduced redundancy (#9040)
Drops the `redundancy` option from the three `S3Cache` put paths.
`S3Bucket.put` already falls back to `STANDARD` when nothing is passed
(`lib/s3-handler.ts:77`), so the deletion is the whole fix.

One thing beyond what the issue lists: `lib/stats.ts` asks for the same
class when it flushes compilation records, and that is the only other
caller in the tree. Those records are not reconstructible the way a
cache entry is, so the lower durability costs something there and buys
nothing. I moved it across in the same commit rather than leaving a
single RRS write behind, but say the word and I will pull it back out
into its own PR.

For the regression guard I added a case per file, both asserting the
`StorageClass` that reaches the mocked `PutObjectCommand`:
`test/cache-tests.ts` covers `put`, `putWithTTL` and
`putWithTTLAndPath`, and `test/stats-test.ts` covers the flush.
Reverting either source file turns the matching test red with
`REDUCED_REDUNDANCY` instead of `STANDARD`.

Verified in a `node:22-bookworm` container, which is where my
node_modules live: full suite 2630 passed, 1 skipped across 122 files,
plus `npm run ts-check` and `biome check` clean. Committed through the
normal pre-commit hook.
2026-08-22 13:03:32 -05:00
Patrick Quist b0c6715a89 Fix blank right-hand pane in tree shortlink layouts (#9028) 2026-08-18 18:29:04 +02:00
Patrick Quist 58d1561e2e Pass CUDAToolkit_ROOT for cuda clang compilers (#9023) 2026-08-15 15:03:13 +02:00
Patrick QuistandClaude Opus 5 500c09675b MCP: proxy compiles for remotely-hosted compilers (#9016)
cc @mattgodbolt — this is in the MCP endpoint from #8644.

## The problem

`compile` in the MCP tool calls `baseCompiler.compile()` directly, so a
compiler served by a sub-server gets attempted on whichever node handled
the MCP request. There's no compiler binary there to launch, so every
remotely-hosted compiler fails through `/mcp`:

```
runChild():486 Launching child process failed
```

Reproducible on production right now — `vcpp_v19_51_VS18_6_x64` through
`compiler-explorer.com/mcp` fails, while the same id and options through
`/api/compiler/<id>/compile` works. It affects any remote, not just the
Windows ones.

`CompileHandler.handle` has the branch that makes this work for REST:

```ts
const remote = compiler.getRemote();
if (remote) {
    req.url = remote.path;
    this.proxy.web(req, res, {target: remote.target, changeOrigin: true}, ...);
    return;
}
```

There's no equivalent anywhere in `lib/mcp` — `git log -S"getRemote" --
lib/mcp` is empty, so this has been the case since the endpoint landed.

## The change

Check `getRemote()` and, when it's set, POST an equivalent request to
`remote.target + remote.path` rather than compiling locally. A tool call
has no `req`/`res` to hand to `http-proxy`, hence an outbound `fetch`
instead of the proxy. The sub-server returns the same JSON shape
`compile()` returns locally, so truncation, `buildResult` and
`execResult` handling below are untouched.

One wart: `result` is annotated `Awaited<ReturnType<typeof
baseCompiler.compile>>` rather than `CompilationResult`, because the
declared wire type has `asm?: string | ParsedAsmResultLine[]` and
`truncateLines` wants the array form — typing it as `CompilationResult`
doesn't compile. There's a cast on the remote branch with a comment
explaining why. Happy to do this differently if you'd rather.

## Testing

Unit tests: the existing fake compiler had no `getRemote`, so it's added
there; two new cases cover the remote path posting to the sub-server
(and never calling `compile()` locally) and a failing sub-server
response surfacing as a tool error.

Manually, against a local instance configured with the `gpu` and
`winprod` remotes:

| compiler | before | after |
| --- | --- | --- |
| `vcpp_v19_51_VS18_6_x64` `/O2` | `runChild():486` | `code 0`, `lea
eax, DWORD PTR [rcx+1]` |
| `vcpp_v19_51_VS18_6_x86` `/O2 /std:c++20` | — | `code 0`, `mov eax,
DWORD PTR _x$[esp-4]` |
| `clang-cl2216-v19_50_VS18_2` `/O2` | — | `code 0` |

Compile errors propagate too: a deliberate typo returns `code 2` with
`<source>(1): error C2065: 'nope': undeclared identifier`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 17:38:37 -05:00
b34b873577 Add the aburi compiler (#9019)
Supersedes #8872. Thanks to @likecrazy1, whose `AburiCompiler` class is
taken from that PR unchanged and who is credited as co-author — the
reason this is a new PR rather than an edit is that the properties
needed rewriting from scratch once upstream changed direction.

@serjective has
[confirmed](https://github.com/compiler-explorer/compiler-explorer/pull/8872#issuecomment-)
that `godbolt` is the live branch and the pinned `atta-mills` classic
version is abandoned, so this configures the nightly built from
`godbolt`.

## What changed from #8872, and why

**It is not an aarch64 Darwin cross compiler any more.** The new build
reports `Target: x86_64-unknown-linux-gnu`, so the group is plain
`aburi` with `instructionSet=amd64` rather than "Aburi (aarch64 Apple
Darwin)".

**No `--sysroot`.** This is the important one. On Linux, aburi's
`resolve_effective_stdlib` treats an explicit `--sysroot` as a different
root filesystem and **switches off Adinkra**, its own C++ standard
library. That is exactly why the previous configuration compiled CE's
header-free `square` example byte-perfectly and then failed on the first
`#include`. For a Linux target aburi takes its C headers from the host
root and its C++ headers from Adinkra, so it wants no sysroot at all.

**`-std=c++20` is required**, not optional — Adinkra `#error`s below
C++20, so a bare C++ compile fails outright.

**Nightly shape:** `isNightly=true` and `semver=(trunk)` instead of a
pinned `0.1.1`, since it now tracks a moving branch.

**Binary, binary object and execution are off.** Linking does work (I
built and ran a C++ executable against the shipped artifact), but
nothing has exercised those paths on the site, and they need
`-L`/`-Wl,-rpath` pointing at the bundled libc++abi to link at all.
Advertising a control that hard-fails is the exact trap this compiler
fell into last time, so I would rather turn them on as a follow-up once
someone can try them for real.

## Testing

Everything below was run against the artifact that is actually on S3
(`aburi-godbolt-20260814.tar.xz`), installed through the infra
installable:

- `--version` and `--help` both exit 0 (a non-zero version command
silently drops a compiler from the dropdown)
- C++ `-S` emits x86-64 assembly
- C compiles, links and runs
- `--emit-llvm` alone emits valid LLVM IR, which is what `AburiCompiler`
uses for the IR view. Note it rejects `--emit-llvm` combined with `-S`,
and the class already strips `-S` on that path
- `-g` is accepted, which the class always passes
- a TU using `<vector>`, `<string>` and a thrown-and-caught exception
compiles, links and runs — the case the old `--sysroot` broke

`npm run test:props` (90 passed), `npm run ts-check` and `npm run
lint-check` all clean.

## Merge order

This should land after, and only after, the compiler is installed:

- compiler-explorer/misc-builder#142, #143 (builder) — merged
- compiler-explorer/infra#2294 (nightly installable)
- compiler-explorer/compiler-workflows#76 (daily build)

Co-Authored-By: likecrazy1
<157763655+likecrazy1@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: likecrazy1 <157763655+likecrazy1@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 21:03:40 -05:00
Hayden Gray 4ce38e0067 [odin] fix llvm for past two versions and assembly for current version (#9012)
The most recent Odin versions have had an issue where the `output.ll`
filename is actually duplicated to `outputoutput.ll`, resulting in the
LLVM IR view not finding the file. Additionally, `dev-2026-08` fixed an
output assembly naming issue that caused the `.S` extension to always be
uppercase, regardless of filename. This broke the assembly view though
since the filenames now no longer matched.

Both of these issues were fixed by adding explicit version checks with
the corresponding correct codepaths.
2026-08-13 20:56:20 -05:00
Hurairabaloch 62d87f264d Enable clang-tidy for Clang-CUDA builds (#8996)
## Summary
- enable clang-tidy for Clang-CUDA compiler groups in the default and
production CUDA configurations
- resolve clang-tidy from the selected Clang-CUDA toolchain while
preserving version suffixes
- add focused tests for CUDA and non-CUDA executable selection

Closes #6944

## Test plan
- [x] `npm run test:props` (90 tests)
- [x] `npm run ts-check`
- [x] `cross-env SKIP_EXPENSIVE_TESTS=true npx vitest related --run` (39
tests)

## AI assistance
AI assistance was used for codebase navigation and drafting. The final
diff was reviewed and the listed checks were run locally.
2026-08-13 20:54:42 -05:00
1863cec885 Accept GoldenLayout format in /clientstate/ URLs (#8862)
The /z/ stored-link handler already supports both ClientState
(sessions-based) and GoldenLayout (content-based) JSON formats, but the
/clientstate/ endpoint only accepted ClientState and always converted it
to GoldenLayout using the default layout.

Extract a shared configToGoldenLayout() method that checks for a
'content' key (GoldenLayout format) and passes it through directly, or
converts from ClientState otherwise. Both storedStateHandler and
unstoredStateHandler now use this method, making the two endpoints
consistent in what formats they accept.

This allows /clientstate/ URLs to carry full GoldenLayout state
including custom panel layouts (e.g., editor-on-top with conformance
view below), which was previously only possible via stored /z/ links.

<!-- 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!
-->

Co-authored-by: jberne4 <jberne4@bloomberg.net>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-11 11:19:28 -05:00
Trevor Gross 035b31a53d Support Rust in makefiles (#9001)
Similar to `CC` and `CFLAGS`, support `RUST` and `RUSTFLAGS` if a Rust
compiler is selected.
2026-08-10 20:38:20 -05:00
Patrick Quist 764483e54f Pluggable build systems: Cargo, Maven and Make alongside CMake (#8994) 2026-08-09 22:06:51 +02:00
umayyah 87f90be050 Fix crash in CFG generation when a conditional jump is the last instruction (#8974)
Fixes #6902

## What was happening
Reproducing the Clean example from the issue, the CFG pane didn't just
draw
a wrong graph — it actually crashed the whole compile with:

TypeError: Cannot set properties of undefined (setting 'nameId')
    at BaseCFGParser.extractAltJmpTargetName

## Root cause
`extractAltJmpTargetName` assumes a conditional jump is never the last
instruction of a function — it always tries to write a generated name
onto
"the next basic block" (`arrBB[bbIdx + 1]`). When a function's last
basic
block ends in a conditional jump with no fallthrough block after it,
`arrBB[bbIdx + 1]` doesn't exist, and the code crashes trying to set a
property on `undefined`.

I couldn't get a working Clean compiler locally, so I wasn't able to
confirm Clean's exact label format, but I could reliably reproduce the
exact same crash/stack trace with 3 lines of synthetic assembly (see the
added test case) — any input that leaves a conditional jump as the final
instruction of a function hits this.

## Fix
Guard the write so it only happens when a next block actually exists.
The
frontend layout code (`graph-layout-core.ts`) already tolerates edges
that
point at a node ID that doesn't exist (there's an existing comment there
about exactly this: "Backend can return dest: null"), so this degrades
gracefully instead of crashing.

## Note
This fixes the crash. The original report also mentioned Clean's
*labels*
getting misidentified as separate functions in the graph itself — that's
a related but separate issue (in `isFunctionEnd()`'s assumption that
local
labels are dot-prefixed, GNU-`as`-style). I didn't have a way to verify
Clean's actual label format to fix that part with confidence, so I've
left
it for a possible follow-up.

## Testing
Added `test/cfg-cases/cfg-base.cond-jmp-last-instruction.json` and a new
`describe('base', ...)` block in `test/cfg-tests.ts`. Confirmed it fails
with the original crash on unpatched code and passes with the fix.
2026-08-06 07:30:26 -05:00
narpfel 788815da07 Fix stack usage view for GCC nightly (#8973)
GCC nightly has changed its `-fstack-usage` output to include the
mangled function name, so currently the stack usage view shows the
demangled function name instead of the stack frame size, e. g.
`square(int) bytes, static`; see https://godbolt.org/z/xxhWfzqha.
2026-08-06 06:59:52 -05:00
kevinjeon-g d0254d8419 Fix dex2oat class regex for later versions (#8965)
The output format for classes in dex2oat has changed:
- before: 0: LSquare; (offset=0x00001454) (type_idx=1)
- after:  0: Square (offset=0x00001480) (type_idx=1)

This change updates the regex to accept any non-whitespace character for
the class name (LSquare; or Square). The extracted class name is only
used as a key, so the presence of 'L' and ';' aren't important, as long
as it's consistent

This is compatible with both older and newer dex2oat versions, and line
associations + output formatting are still the same.

<!-- 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!
-->
2026-07-29 16:25:33 -04:00
Mahenoor Salat 3289624d0c fix(parsers): clean up and refactor asm-parser-ewavr (#8957)
## Summary

Fixes #4689

Refactors `lib/parsers/asm-parser-ewavr.ts` to clean up logic and
resolve stale TODO item:

- Extracts `getFilenameFromComment` and `getLineNumberFromComment`
helper functions into private instance methods on `AsmEWAVRParser`,
avoiding function allocation on every line per assembly parse.
- Fixes `currentFile === undefined` check (since `currentFile` is
initialized as `string | null` = `null`).
- Verified all unit tests pass (`test/ewavr-asm-parser-tests.ts`).

## Testing

Ran local unit tests:
```bash
npm test -- test/ewavr-asm-parser-tests.ts test/vc-asm-parser-tests.ts
```
Result: 11 tests passed in 2 test files.
2026-07-29 15:52:49 +02:00
1c24af8e76 Cleanup gcc pass dumps from file/line info (#8931)
Following the review in
https://github.com/compiler-explorer/compiler-explorer/pull/8826/changes/c4d8590f6a992b4478f9f08b41af2ac05bff3402#r3476267780,
this PR tries to clean up file/line info from gcc dumps.

Example `expand (rtl)` output, for the default C++ source example:
```

;; Function square (_Z6squarei, funcdef_no=0, decl_uid=2861, cgraph_uid=1, symbol_order=0)


;; Generating RTL for gimple basic block 2

;; Generating RTL for gimple basic block 3


try_optimize_cfg iteration 1

Merging block 3 into block 2...
Merged blocks 2 and 3.
Merged 2 and 3 without moving.
Merging block 4 into block 2...
Merged blocks 2 and 4.
Merged 2 and 4 without moving.
Removing jump 11.
Merging block 5 into block 2...
Merged blocks 2 and 5.
Merged 2 and 5 without moving.


try_optimize_cfg iteration 2



;;
;; Full RTL generated for this function:
;;
(note 1 0 4 NOTE_INSN_DELETED)
(note 4 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(insn 2 4 3 2 (set (mem/c:SI (plus:DI (reg/f:DI 93 virtual-stack-vars)
                (const_int -4 [0xfffffffffffffffc])) [1 num+0 S4 A32])
        (reg:SI 5 di [ num ])) :2:21 -1
     (nil))
(note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
(insn 6 3 7 2 (set (reg:SI 100)
        (mem/c:SI (plus:DI (reg/f:DI 93 virtual-stack-vars)
                (const_int -4 [0xfffffffffffffffc])) [1 num+0 S4 A32])) :3:18 -1
     (nil))
(insn 7 6 10 2 (parallel [
            (set (reg:SI 98 [ _2 ])
                (mult:SI (reg:SI 100)
                    (reg:SI 100)))
            (clobber (reg:CC 17 flags))
        ]) :3:18 -1
     (nil))
(insn 10 7 14 2 (set (reg:SI 99 [ <retval> ])
        (reg:SI 98 [ _2 ])) :3:18 discrim 1 -1
     (nil))
(insn 14 10 15 2 (set (reg/i:SI 0 ax)
        (reg:SI 99 [ <retval> ])) :4:1 -1
     (nil))
(insn 15 14 0 2 (use (reg/i:SI 0 ax)) :4:1 -1
     (nil))
```

---------

Co-authored-by: Ofek Shilon <oshilon@speedata.io>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-29 15:46:52 +02:00
Ardit Tirana 8519254bb8 fix: consolidate /z/<id> URL parsing into a single robust helper (#8847) 2026-07-27 18:54:17 +02:00
Jim McKeeth 24c090550f Fetch remote-compiler libraries over the URL's own scheme (http or https) (#8932) 2026-07-27 17:35:11 +02:00
1eacae7d5b Add TI C29 Clang compiler support (#8911)
Closes #8910 

Depends on https://github.com/compiler-explorer/infra/pull/2225

<!-- 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!
-->

Co-authored-by: Macsen Casaus <m-casaus@ti.com>
Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
2026-07-21 15:34:47 -05:00
07226d33bf Reapply extraBodyClass-driven branding, validating via the manifest in production (#8935)
Reapplies #8755, which was reverted in 463e3e70f after it broke the
staging deploy:

```
error: Top-level error (shutting down): Missing branding assets for extraBodyClass='staging'
in /infra/.deploy/static: favicon-staging.ico, site-logo-staging.svg
```

### What went wrong

`validateBrandingAssets` checked `staticPath` on the local filesystem.
That's correct for dev and local prod runs, but AWS deploys ship **two**
packages (`build-dist.sh`): the node app tarball (no `static/` at all)
and the static bundle, which goes to the CDN
(`staticUrl=https://static.ce-cdn.net/`). Production nodes never have
the branding files on disk, so any env with `extraBodyClass` set
(staging, beta, win\*) died at startup. Prod itself has an empty
`extraBodyClass`, which is why the check short-circuited there and the
bug only surfaced on the staging deploy.

### The fix (second commit)

The webpack manifest **does** ship with the node app, and lists every
asset copied from `public/` into the static bundle. So in production,
validate the derived `favicon-<class>.ico` / `site-logo-<class>.svg`
names against **manifest keys** instead of the filesystem; dev keeps the
on-disk check against `public/`. This preserves the fail-fast-on-typo
behaviour #8755 wanted, checking the thing that actually describes what
shipped to the CDN. If the manifest can't be loaded we're already on the
existing warn-and-fall-back handler, so validation is skipped rather
than fatal.

`setupStaticMiddleware` now takes the parsed manifest (loaded once in
`setupWebServer` via new `loadStaticManifest`) instead of reading it
itself.

### Verification

- Fresh **production** webpack build: all six env asset pairs (dev,
beta, staging, winprod, winstaging, wintest) appear as plain-name keys
in `manifest.json` (the win\* symlink placeholders are dereferenced on
copy).
- Booted the built `out/dist` server code in the exact deploy layout
(`staticUrl` set, nonexistent `staticPath`, `extraBodyClass=staging`):
boots cleanly and renders `favicon-staging.ico` +
`site-logo-staging.svg`; a mistyped class still fails startup with a
clear error.
- New regression tests pin both behaviours at the `setupWebServer` level
with a shipped-manifest-only layout.

⚠️ Merge timing: prod's empty `extraBodyClass` never exercises this path
— the real test is the next **staging** deploy, so this should merge
when someone (me) is ready to deploy staging and watch it.

cc @partouf — sorry again for the breakage; this validates against the
manifest rather than expecting the CDN bundle's files on local disk.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 21:37:49 +01:00
Partouf 463e3e70f0 Revert "Drive env branding from extraBodyClass alone (#8755)"
This reverts commit 13358939ce.
2026-07-19 23:55:46 +02:00
Jim McKeeth d1aff27080 FPC: recognize AArch64 '// [n]' source-line comments (#8933) 2026-07-19 14:13:20 +02:00
13358939ce Drive env branding from extraBodyClass alone (#8755)
The favicon selector and logo overlay used to be hard-coded switches
over the env name array (favicon) and a chained if/else in logo.pug.
Adding a new environment meant editing both, the favicon allowlist, and
the tests.

Convert both to a convention driven by extraBodyClass:
favicon-<class>.ico and site-logo-<class>.svg. logo.pug becomes one
unconditional overlay tag. getFaviconFilename takes the class string
directly.

Add validateBrandingAssets, called once during setupWebServer, which
throws if the configured assets are missing. Typos in extraBodyClass now
fail at startup with a clear error rather than serving a broken favicon.

isFaviconRequest becomes a regex matching favicon-*.ico so the log
filter no longer needs a per-env list (and previously didn't match
because req.path has a leading slash).

A new environment is now: drop two files in public/, set extraBodyClass
in the env properties file. No TS or pug changes.

---------

Co-authored-by: Matt Godbolt <mattgodbolt@hudson-trading.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-14 17:18:25 +01:00
c425932877 Mask temp paths by the CE marker, not the live os.tmpdir() (#8920)
maskRootdir() built its strip-regex from this process's os.tmpdir(), so
it only masked paths whose root matched the current tmpdir. That is
fragile in two real cases:

- The path being masked is recorded when the compile runs and need not
share the masking process's tmpdir. Snapshots/fixtures that freeze
/tmp/... paths only mask on hosts where os.tmpdir() is /tmp (they fail
where it is e.g. /usr/tmp).
- On macOS os.tmpdir() returns /var/folders/... while real temp paths
often resolve via /private/var/folders/..., so masking silently missed.
- A configured temp root (temp dirs created outside os.tmpdir()) was
never matched at all.

Key the regex off the distinctive ce_temp_prefix marker instead,
matching whatever path segments precede it. This is tmpdir-independent
and unifies the Windows and non-Windows branches into one rule (also
masking embedded temp paths like `-I/tmp/.../include` on Windows, which
the old anchored branch missed).

Adds unit tests for maskRootdir (previously untested) covering /tmp,
/usr/tmp, macOS /private/var, Windows, the -I include case, and non-temp
paths left untouched.

<!-- 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!
-->

---------

Co-authored-by: Matt Godbolt <mattgodbolt@hudson-trading.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-07-14 15:30:54 +01:00
Sirui MuandMatt Godbolt 7a6af91bc9 Enable AST output for Python (#8858)
This patch adds support for viewing the abstract syntax tree (AST) of
Python source code in Compiler Explorer, matching the existing AST
viewer feature for C/C++ (Clang AST).

- This patch adds a helper script `ast_dump.py` that parses and dumps
the AST for a Python source code file. `python -m ast` should also work,
but it's not available in old versions of Python.
- This patch adds an AST parser for Python which mimics the structure of
the C/C++ AST parser. It also updates the Python compiler to enable AST
output.
- All existing and new tests pass.

Assisted-by: GitHub Copilot / DeepSeek v4 Flash
Assisted-by: GitHub Copilot / DeepSeek v4 Pro

<!-- 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!
-->

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2026-07-14 08:46:10 +01:00
Cycle1337 ed127f3933 Fix compiler tool ID slimming for cached arrays (#8893) 2026-07-08 09:42:37 +02:00
ef9a1ce7c3 [CUDA] add scale's nvcc compiler (nvidia & amd backends) (#8849)
Hi !

This PR adds the [scale nvcc
compiler](https://docs.scale-lang.com/stable/) to the CE live site for
both AMD and Nvidia backends

It works locally and shows host asm, device LLVMIR and:

 - PTX ans SASS for Nvidia backend,
 - AMDGPU code for AMD backend.
 
There is a bug in scale 1.7.1 that prevents the compilation with both
`-S, -o` flags. As a result I had to make some temp workarounds.

For Nvidia backend, PTX is written in the device `.s` file. I run it
through `ptax` and `nvidasm` to get the SASS. To get the LLVMIR, I
decode the device `.bc` file with `llvm-dis`.

For AMD backend, the `.s` file is the AMDGPU code, and the LLVMIR is
obtained the same way.

I plan to make the `.ts` script closer to say `nvcc.ts` once the flag
bugs are fixed in scale.

Let me know if there is anything I missed for the live site integration.

infra PR: https://github.com/compiler-explorer/infra/pull/2191
Issue:
https://github.com/compiler-explorer/compiler-explorer/issues/8865

I acknowledge the use of generative AI to help drafting the code of this
PR.

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 22:14:19 +01:00
3d5a62fe6b Re-add CI check enforcing license header banners (#8883)
## What & why

We used to enforce the BSD-2-Clause license banner on every source file
via `eslint-plugin-header`. That check was lost when we migrated from
ESLint to Biome (#7033), which has no equivalent rule. This PR
reinstates it as a standalone node script, modelled on the existing
`etc/scripts/check-frontend-imports.js`.

### Why a script rather than a Biome rule
Biome 2.x has no built-in license/header rule and no plugin equivalent
to `eslint-plugin-header`; its experimental GritQL plugins aren't suited
to whole-file-prefix matching. A script needs zero new dependencies and
gives full control over scope and exemptions.

## The check (`etc/scripts/check-license-headers.js`)

A file "has an appropriate banner" if, ignoring an optional shebang, it
opens with a `// Copyright (c) …` line **and** contains the BSD-2-Clause
disclaimer body. The year and copyright holder are intentionally **not**
constrained — the tree legitimately has many holders (Compiler Explorer
Authors, Arm, Microsoft, HRT, individuals). The `(c)`/`(C)` marker is
matched case-insensitively.

**Scope:** `.ts/.js/.mjs/.cjs` under `lib/ static/ shared/ types/ test/
cypress/`.

**Exempt:** generated files (`lib/asm-docs/generated`), vendored
(`docenizer/vendor`), `.d.ts`, and three third-party ports that carry
their own upstream license — `static/ansi-to-html.ts` (MIT),
`lib/node-graceful.ts` (MIT), `shared/rison.ts` (Nanonid/rison port).

**Wired into:** CI (`test-and-deploy.yml`), `npm run check`, the `make
pre-commit` target, the husky pre-commit hook, and `lint-staged` (per
staged file).

Usage:
```
node ./etc/scripts/check-license-headers.js            # scan the tracked tree
node ./etc/scripts/check-license-headers.js <files...> # scan specific files (lint-staged)
```

## Backfill

The check surfaced **42 CE-authored files** missing the banner. This PR
backfills them all with the standard `Copyright (c) <year>, Compiler
Explorer Authors` banner, using each file's **git creation year**
(added-at-this-path, so no `--follow` rename artifacts).

## Verification

- `check-license-headers` → clean (was 42 failures)
- `biome check` on all source → no fixes needed (banner format matches
existing convention)
- `tsc` backend + frontend + tests → clean
- pre-commit gauntlet (lint, ts-check, related tests: 528 passed) ran on
commit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 19:13:21 +01:00
CedricandMatt Godbolt b0726beb5f Fix Triton MLIR source locations (#8718)
## Summary
- resolve nested named MLIR location aliases in the MLIR asm parser
- strip MLIR location metadata from displayed device output
- make Device Viewer source colours and hover linkage use the owning
source editor

## Testing
- npm run test -- test/asm-parser-tests.ts --reporter dot
- npm run ts-check:frontend
- npm run ts-check:backend
- npm run ts-check:tests
- npx biome check lib/parsers/asm-parser-mlir.ts
test/asm-parser-tests.ts static/panes/device-view.ts
- git diff --check -- lib/parsers/asm-parser-mlir.ts
test/asm-parser-tests.ts static/panes/device-view.ts
- pre-commit hook: npm run lint, npm run ts-check, vitest related passed

Note: a standalone npm run test-min run failed in unrelated
test/demangler-tests.ts Rust demangling expectations in this local
environment.

---------

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2026-07-02 18:52:31 +01:00
hkalbasiandMatt Godbolt 9b47e07d14 Add co2 language (#8842)
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>
2026-07-02 18:26:35 +01:00
Ofek f7602b4360 Additional opt-pipeline optimization (#8876)
In an attempt to address #8583.
Also fix the opt-pipeline timing measurement.
2026-06-30 22:26:08 +03:00
OfekandCopilot Autofix powered by AI 64b3ea2428 Optimizations in LLVM opt-pipeline (#8869)
3 Separate optimizations towards resolution of #8583:

1. (probably most substantial:) ``PrefixTree.replaceAll` did O(n^2)
allocations, causing substantial GC time:
```ts
const lineBit = line.substring(idxInOld);
const [oldValue, newValue] = this.findLongestMatch(lineBit);
```
For every character pos in a line this allocated a substring for the
entire remainder. Over one line that's O(n^2) bytes allocated, and
`processPassOutput` runs this on every line of every before/after IR
dump — which for an opt-pipeline run is enormous. This is a major
contributor to both the `replaceAll`/`processPassOutput` self-time and
the 20% GC.
Fix: make `findLongestMatch` accept a start offset and walk the existing
line string in place.

2. `JSON.stringify` large payloads once instead of twice, when caching
to S3

3. `processPassOutput` called `PrefixTree.replaceAll` which did a costly
build of replacement map but didn't use them. Now calls the new
`PrefixTree.replaceAllText`.



-------
The time measurements on the live site and on my machine differ
substantially. Before pursuing more aggressive optimizations I want to
check the impact of these, see if more work is needed.

One additional direction for (major) optimization: I think today each
pass dump is processed twice, once as 'before' and 2nd time as 'after'

---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-26 22:10:36 +03:00
fa456a81f3 Fix #7870: use GCC pass-dump files to enumerate passes (#8826)
Following the discussion at #7870: `-fdump-passes` reports passes
enabled dynamically (e.g. loop2_unroll via `#pragma GCC unroll`) as OFF,
so they were missing from the pass dropdown although they were active.
Fixed by building the pass list from the dump files GCC actually wrote
instead.

While reworking this:
- Read all passes into a `passDumps` map shipped with the result, so
switching passes doesn't trigger a compile.
- Trim each dump to functions defined in the user's source, dropping
header/library functions; strip forced -lineno annotations from GIMPLE
(tree/IPA) dumps when Line Numbers is off, leaving RTL untouched.
- Exclude passes with empty output
- Add a GccDumpOutput type, backend unit tests and a cypress test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-20 16:06:25 +03:00
mert-kurttutan 1545df84e8 Tenstorrent support (#8803)
SFPI C++ is Tenstorrent’s C++ environment for writing custom SFPU/Tensix
kernel code with the `riscv-tt-elf-g++` toolchain.

  infra PRs: 
-
[compiler-explorer/infra#2164](https://github.com/compiler-explorer/infra/pull/2164)
-
[compiler-explorer/infra#2183](https://github.com/compiler-explorer/infra/pull/2183)

  Things this PR adds:
  - General support for SFPI C++
  - A dedicated SFPI compiler implementation
- SFPI config for local and Amazon-style `/opt/compiler-explorer`
installs
  - An SFPI example
  - Ability to compile for specific machines with mcpu flag

  Things not implemented:
  - Program execution
  - Binary output support

  Links:
  - Source code: https://github.com/tenstorrent/sfpi
  - Tenstorrent: https://tenstorrent.com/
2026-06-19 11:31:32 -04:00
0cd84e0c3a Add OpenSearch shortcut for shortlinks (ce <id> in the address bar) (#8836)
## What

Adds
[OpenSearch](https://developer.mozilla.org/en-US/docs/Web/XML/Guides/OpenSearch)
support so browsers can register a `ce` keyword. Once registered, typing
`ce <shortlink>` in the address bar redirects to `/z/<shortlink>`.

## How

- **`views/opensearch.pug`** — an OpenSearch 1.1 description document.
- **`/search.xml` route** (`lib/app/server-config.ts`) — mirrors the
existing `/sitemap.xml` route; serves the doc with `Content-Type:
application/opensearchdescription+xml`.
- **`views/meta.pug`** — advertises it via `<link rel="search">` on the
main page (omitted on embed pages, where OpenSearch discovery doesn't
apply).

The search URL template (`…/z/{searchTerms}`) is built from the request
(`{protocol}://{host}{httpRoot}`, the same pattern as
`lib/storage/base.ts`), and the favicon uses the env-resolved
`staticRoot`/`faviconFilename`, so it's correct across
prod/beta/staging/local.

## Activation note

This is opt-in *discovery*, not automatic activation — browsers register
the engine after visiting the site, and the user typically activates the
`ce` keyword once (Chrome: Settings → Search engines → Site search;
Firefox surfaces it in the address bar). Chrome's auto-discovery is also
gated on a secure context, so this is best validated on an HTTPS
environment (e.g. staging/beta) rather than a plain-HTTP dev box.

## Testing

Verified against a local instance:
- `GET /search.xml` → `200`, correct content-type, well-formed XML,
`{searchTerms}` placeholder preserved, `<Url template>` absolute and
host-derived.
- `<link rel="search">` present on `/`, absent on `/e`.
- favicon URL resolves.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 12:01:51 +01:00
Lumi 938d42ae3f Add RazorForge language support (#8825)
This adds support for
[RazorForge](https://github.com/dj-lumiere/razorforge-suflae),
a precision-focused, ahead-of-time compiled language that lowers to LLVM
IR. It follows
  `docs/AddingALanguage.md`.

  ### What's included
- `lib/languages.ts` — language definition (`.rf`, Monaco mode
`razorforge`, disassembly `llvm-ir`)
  - `types/languages.interfaces.ts` — `razorforge` language key
- `lib/compilers/razorforge.ts` + `lib/compilers/_all.ts` — compiler
driver
- `static/modes/razorforge-mode.ts` + `static/modes/_all.ts` — Monarch
syntax highlighting
- `etc/config/razorforge.{defaults,amazon}.properties` — compiler config
  - `examples/razorforge/default.rf` — default example
  - `.github/labeler.yml` — `lang-razorforge` label

  ### Compiler behavior
RazorForge's CLI takes verbs + positional arguments only (all build
config lives in
`razorforge.toml`, not flags). The driver invokes the `build` verb,
which runs semantic
analysis and code generation and writes LLVM IR next to the source
(`example.rf` →
`example.ll`) without invoking `opt`/`clang`. The primary output is the
emitted LLVM IR,
  so `supportsIrView` is on and `supportsExecute` is off for now.

  ### Notes
  - Install recipe: compiler-explorer/infra#2177
  - No logo yet (`logoFilename: null`); happy to add one in a follow-up.
- Verified locally: `make`, `biome check`, `tsc`, and `vitest related`
all pass; the example
    compiles to valid LLVM IR with the released `v0.0.3-alpha` build.
2026-06-17 09:47:31 +01:00
6774d762ce Construct builtin examples source explicitly at startup (#8828)
Follow-up to #8779 (which fixed #8601, `builtin.sourcePath` being
ignored). Two related changes:

### 1. Construct the builtin source explicitly at startup (restore
fail-fast)

#8779 made the builtin "Examples" source read its config lazily, on the
first `list()`/`load()`. That fixed correctness but moved the failure
mode: a misconfigured `sourcePath` (missing/unreadable dir) no longer
fails at startup. The server boots, passes healthchecks, takes traffic,
and then throws on the first request that opens Examples.

This restores fail-fast by constructing the source explicitly once
configuration is loaded:

- Replace the `builtin` module-level singleton with a `BuiltinSource`
class whose constructor scans the examples directory, plus a
`createBuiltinSource()` factory that reads `builtin.sourcePath`.
- `lib/sources/index.ts` exposes `createSources()` instead of a
top-level `sources` array (a top-level array would re-run config reads
at import time, reintroducing #8601).
- `initialiseApplication` constructs the sources after config load and
passes the `Source[]` to `ClientOptionsHandler` and
`setupControllersAndHandlers` (both already accept injected sources).

A bad `sourcePath` now throws during startup, before the instance
reports healthy. The lazy fix's correctness (config read after
`initialize()`) is preserved.

### 2. Single source of truth for the examples path

`GolangParser` independently re-read `('builtin', 'sourcePath',
'./examples/')` to locate `go/default.go`, duplicating where the
examples directory is defined. Export `getExamplesRoot()` from
`lib/sources/builtin.ts` and use it in both `createBuiltinSource()` and
`GolangParser`, so the config key and default live in one place.
Behaviour is unchanged (same value resolved); it removes the drift risk
if the key or default ever changes.

### Tests
Tests construct `BuiltinSource` directly with a fixture directory (no
import-order/`resetModules` dance), cover the unknown-example path,
assert fail-fast on a non-existent dir, and verify
`createBuiltinSource()` reads the configured path.

- `npx vitest --run test/sources/builtin-tests.ts
test/compilers/argument-parsers-tests.ts`
- `npm run ts-check`
- `npm run lint-check`

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 22:38:23 +01:00
Puneet DixitandDeepak kudi 6f9f064a84 Fix builtin sourcePath configuration (#8779)
## Summary

- defer scanning builtin examples until `list()` or `load()` is called
- refresh the cached examples if `builtin.sourcePath` changes
- add a regression test that imports the builtin source provider before
properties are initialized, then verifies a custom `sourcePath` is used

Closes #8601.

## Tests

- `npm run test -- --run test/sources/builtin-tests.ts --reporter=dot`
- `npm run test-min -- --run test/sources/builtin-tests.ts
--reporter=dot`
- `npm run ts-check`
- `npx biome check lib/sources/builtin.ts test/sources/builtin-tests.ts
--write`
- `npm run lint-check -- lib/sources/builtin.ts
test/sources/builtin-tests.ts`
- `git diff --check`

Co-authored-by: Deepak kudi <deepakkudi23@adsl-172-10-9-116.dsl.sndg02.sbcglobal.net>
2026-06-14 22:02:37 +01:00
Nerixyz 33bbd5792a clang-cl: Remove unused /Fm argument (#8792)
clang-cl doesn't write mapfiles like MSVC, so it doesn't support `/Fm`
and it used to report a warning:
```
clang-cl: warning: argument unused during compilation: '/FmC:\Windows\TEMP\compiler-explorer-compiler6Pv4en\output.s.exe.map' [-Wunused-command-line-argument]
```

To still get the function labels, we should use `llvm-objdump`. However,
that doesn't read the generated debug info file right now. I've opened
https://github.com/llvm/llvm-project/pull/201150 to fix this.
2026-06-14 21:53:04 +01:00
Nerixyz 13043fa989 clang-cl: fix IR/AST arguments (#8790)
When the user specified `/link` in the options or enabled "Link to
binary", clang-cl wouldn't generate IR or an AST.
Two changes fix this:
- Strip `/link` and all options after it. These are unused for IR and
AST generation anyway.
- Always specify `-c` for IR generation. For the AST, `-fsyntax-only` is
already specified in the base class.
2026-06-14 21:51:04 +01:00
Nerixyz fab9e1f545 Use compiler's demangler type for LLVM IR (#8789)
The `LLVMIRDemangler` derived from `BaseDemangler`. It called the
demangler executable as-if it was `c++filt`. This would fail if the
demangler was `(llvm-)undname` (demangler for Microsoft names), because
it has a different output.

This PR refactors `LLVMIRDemangler` to take a demangler instance that it
calls into. `BaseDemangler` was extended to allow demangling a fixed set
of symbols and to skip applying the names. Both are needed for the IR
demangler. This way, the demangler instance can handle the details of
parsing the stdout and `LLVMIRDemangler` can provide the names and apply
the transforms.
2026-06-14 21:50:32 +01:00
05f59881f7 Make --tmp-dir authoritative over inherited environment (#8819)
Fixes #8816.

- `setupTempDir()` exports the configured dir as `TMPDIR`, `TMP` *and*
`TEMP`. POSIX `os.tmpdir()` consults `TMPDIR` first, so the old TMP-only
export meant an inherited `TMPDIR` silently defeated `--tmp-dir`
(verified empirically; prod was protected only by `sudo env_reset` in
start.sh). Setting all three also covers native Windows (`TEMP` > `TMP`
there) and WSL, and means spawned tools reading any of the variables
agree.
- Restores the `os.tmpdir() !== tmpDir → throw` sanity check from
613d7f688 (#6052), lost in the #7681 split refactor.
- The startup log now prints `os.tmpdir()` — the value that actually
matters — instead of `TEMP || TMP`, which printed `undefined` on a
default Linux run.
- The `lib/temp.ts` exit hook was `process.on('exit', async ...)`: exit
handlers can't await, so it never removed anything. Replaced with a
synchronous `cleanupSync()` (tested).
- Test hygiene fix that the work surfaced: the temp-dir tests restored
the environment by reassigning `process.env` wholesale; a replaced
`process.env` is a plain object whose writes never reach the real
environment, while `os.tmpdir()` reads the real environ via `safeGetenv`
— so the suite silently leaked env state across tests (and into any test
running later in the same worker). Now saves/restores the individual
variables.

The WSL `%TEMP%`-discovery-failure path (`wsl-vc.ts` parsing garbage on
fallback, #8816 item 4) is deliberately untouched — Windows-specific and
unverifiable here.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-14 20:11:35 +01:00
19ae5abcf3 Count queue jobs as completed when they settle, not when dequeued (#8821)
The last loose end from the incident issue —
`ce_compilation_queue_completed_total` incremented in a `finally` that
ran as soon as the job *returned its promise*, so it counted dequeues,
in lockstep with `ce_compilation_queue_dequeued_total`, and
`status().running` was almost always 0.

Completion is now counted when the job settles (fulfilled or rejected),
via a settlement callback rather than by awaiting in the wrapper. The
non-awaiting detail matters: my first attempt awaited `job()` so the
`finally` ran at settlement — and the existing "times out a job that
never settles" test immediately caught that this keeps `_running`
populated forever for a wedged job, reintroducing the exact
`busy`-forever wedge #8813 fixed. (A nice demonstration of that test
paying for itself.) With the callback approach, a never-settling job
correctly never counts as completed, so `dequeued − completed` now
exposes wedged/in-flight jobs — which would have made the original
incident visible directly in Grafana.

New test pins the semantics: counter unchanged while a job is running,
+1 once it settles.

Per discussion: no temp-dir sweeps of any kind (instances are replaced,
never restarted; and multiple CE processes may share a machine), so the
orphaned-dirs observation in #8811 is closed as won't-fix.

Closes #8811.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 23:02:35 +01:00