Commit Graph
2753 Commits
Author SHA1 Message Date
Ofek Shilon 8a2a77fe21 Restrict zig -fllvm to supported versions 2025-07-19 16:17:43 +03:00
OfekandOfek Shilon a0570b37f3 Fix #7908: Restrict zig -fno-strip switch to versions that support it (#7931)
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
2025-07-19 14:17:51 +03:00
OfekandOfek Shilon a08da10ddb Fix #7907: Add fllvm to zig compilations (#7930)
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
2025-07-19 14:01:59 +03:00
OfekandOfek Shilon 4fd9b22fdc Fix #7928: Help labelReference regex handle weird mangled names (#7929)
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
2025-07-19 13:35:23 +03:00
OfekandOfek Shilon 80feb8d42b Fix for py-cfg (#7922)
Following this comment:
https://discuss.python.org/t/python-bytecode-cfg-added-to-compiler-explorer/99008/2

Co-authored-by: Ofek Shilon <oshilon@speedata.io>
2025-07-17 19:47:20 +03:00
Ofek c2e9d61fe9 Adapt python cfg to python 3.13 (#7906)
Along with improved function names.
2025-07-12 18:39:00 +03:00
woruyu 42cf30d7a6 Decouple Site Template images from template name (#7883) 2025-07-04 06:01:20 +00:00
Ofek 1b1055d2cb CFG for Python (#7855) 2025-07-01 21:49:20 +03:00
PartoufandClaude 561603a793 Remove debug logging from SQS compilation queue for performance
This commit removes extensive debug logging that was added for troubleshooting
SQS compilation worker issues. The logging served its purpose in identifying
and fixing the compilation result transmission problems, but is now removed
to improve performance in production.

Changes:
- Removed verbose SQS message parsing debug logs
- Removed WebSocket transmission debug logs
- Removed compilation processing debug logs
- Kept essential error logging for troubleshooting
- Updated documentation to reflect shared parsing utilities

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 20:45:42 +02:00
PartoufandClaude a8cdd43cbe Add comprehensive WebSocket debugging for compilation results
Added detailed logging to diagnose why compilation results aren't being sent
back via WebSocket:

- Log all stages of WebSocket sender creation and result transmission
- Check for both compilequeue.events_url and execqueue.events_url configuration
- Create custom property getter to use compilation-specific events URL
- Log result structure and WebSocket connection details
- Enhanced error reporting with full error details

This will help identify whether the issue is in WebSocket configuration,
connection, or result formatting.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 19:37:50 +02:00
PartoufandClaude 66f565f89e Create shared compilation request parsing utilities
Created shared parsing functions that both web handlers and SQS workers can use:

- Added compilation-request-parser.ts with utilities for parsing user arguments,
  execution parameters, tools, and filters consistently
- Updated web handler parseRequest() to use shared utilities for final parsing steps
- SQS workers now use the same parsing logic as web handlers for consistency
- Ensures both code paths handle argument splitting, tool processing, and
  parameter validation the same way

This provides the foundation for consistent compilation request handling across
different entry points (web API, SQS workers) while maintaining backward
compatibility with existing web handler logic.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 19:15:02 +02:00
PartoufandClaude 01070a8478 Fix SQS compilation message structure parsing
Fixed the issue where SQS messages had incorrect parameter mapping by:

- Added convertSqsMessageToParsedRequest() function that properly maps SQS message
  structure to the format expected by compile handlers
- Updated doOneCompilation() to use shared parsing logic instead of direct field mapping
- Fixed the parameter structure mismatch where msg.filters should be used for filters
  instead of incorrectly passing msg.backendOptions, etc.
- Reused compilation handler patterns from lib/handlers/compile.ts for consistency

This ensures SQS workers use the same parameter structure as the web handlers,
preventing compilation failures due to incorrect option parsing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 19:08:30 +02:00
PartoufandClaude 67760b231e Enhance SQS message logging and add defensive options parsing fix
Identified root cause: Lambda sends 'options' as object instead of string array.
Enhanced debugging to show more of the message content and added defensive fix:

- Increased message logging from 300 to 1000 chars (first) + 500 chars (last)
- Added comprehensive SQS polling debug info
- Added defensive conversion for options object to array
- Extract userArguments string and split into array if available
- Default to empty array if no valid options structure found

This allows compilation to proceed while Lambda can be fixed separately.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 18:26:34 +02:00
PartoufandClaude bbe1ae5f5c Add comprehensive SQS message debugging to diagnose parsing issue
Enhance debug logging in SQS compilation queue to diagnose the issue where
SQS messages are being received as indexed character objects instead of
proper JSON objects. Added detailed logging at multiple levels:

- SQS message structure validation
- Raw message body analysis
- JSON parsing diagnostics
- Post-parse object validation
- Property access testing

This will help identify whether the issue is in SQS client configuration,
JSON parsing, or message corruption between parsing and usage.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 18:04:36 +02:00
PartoufandClaude 3471d4db2d Add debug logging for SQS compilation queue messages
Add info-level logging to show full SQS message content when processing
compilation requests. This helps debug issues where message fields like
'options' might be undefined, causing compilation failures.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-29 17:13:18 +02:00
Patrick Quist 4e8fc37a88 Merge branch 'main' into feat/compilation-workers 2025-06-29 15:43:29 +02:00
Mats Jun Larsen d92de076cb Always specify full non-null paths and fix cpp image (#7871) 2025-06-28 14:49:43 +02:00
Mats Jun Larsen d147341663 Serve all static asset files over the CDN (#7795) 2025-06-28 14:01:36 +02:00
partoufandClaude c95ccb1bb4 Optimize SQS polling with long polling and configurable intervals
- Add WaitTimeSeconds=20 for SQS long polling (immediate message delivery, efficient empty queue handling)
- Change default poll_interval_ms from 50ms to 1000ms (only applies between messages/errors)
- Add error handling to ensure worker threads continue after failures
- Update comments to explain long polling behavior and performance characteristics

With long polling, response time is < 100ms when messages are available, and up to 20s when queue is empty, providing optimal balance of performance and cost efficiency.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-26 17:51:56 +01:00
partoufandClaude 00b91bbe54 Add configurable polling interval for compilation workers
- Add compilequeue.poll_interval_ms property (default: 50ms)
- Make SQS queue polling interval configurable instead of hardcoded 100ms
- Update documentation to include new configuration property
- Log polling interval on worker startup for debugging

This allows fine-tuning the polling frequency based on workload and latency requirements.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-26 10:18:48 +01:00
partoufandClaude 1f3127f51d Refactor compilation workers to use single queue and remove producer code
Changes:
- Remove queue producer code (SqsCompileRequester, RemoteCompilationEnvironment)
- Save producer code reference in compilation-queue-producer-reference.md
- Simplify to single SQS queue for both regular and CMake compilations
- Use isCMake flag in messages to distinguish compilation types
- Update worker to poll single queue and determine compilation type from message
- Remove cmake_queue_url configuration property
- Update documentation to reflect Lambda-based message production approach

The producer functionality will be implemented separately in Lambda functions.
Workers now only consume from queues and process compilation requests.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 22:10:57 +01:00
partoufandClaude 05b0af5c74 Add compilation worker mode infrastructure
This adds a new worker mode for compilation tasks similar to the existing execution worker architecture:

- Add SQS-based compilation queue infrastructure for regular and CMake compilations
- Implement RemoteCompilationEnvironment for client-side queue interaction
- Add worker startup logic in main.ts to detect and initialize compilation workers
- Create proper message types and serialization for compilation requests
- Implement WebSocket-based result delivery using existing EventsWsSender
- Add configuration properties for compilation worker mode
- Include structured logging and basic metrics for worker operations
- Update documentation with worker mode configuration details

The implementation supports:
- Dual queue system (regular compilation + CMake compilation)
- Configurable number of worker threads per queue type
- Language-aware compiler discovery and execution
- Comprehensive error handling and logging
- Backward compatible with existing compilation API

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 20:05:05 +01:00
OfekandOfek Shilon 6a0188a5ed Fix #7852: return processRawOptRemarks back to BaseCompiler (#7860)
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
2025-06-24 07:33:53 +03:00
OfekandOfek Shilon 273a280b73 Fix #7858: Allow for angle brackets in llvm labels (#7859)
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
2025-06-24 06:49:54 +03:00
OfekandOfek Shilon 37ae297d95 Fix #7849: Enable llvm opt-remarks for flang (#7851)
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
2025-06-21 20:56:15 +03:00
Jeremy Rifkin e0958c8613 Add support for demangling quoted labels (#7846)
This PR updates a dozen regular expressions related to labels and
demangling to allow quoted names which gcc trunk is now emitting:


![image](https://github.com/user-attachments/assets/efc727d1-a056-4544-8196-4276bb14fc02)


Resolves #7729
2025-06-20 17:33:49 -05:00
Patrick Quist b5e7219baa Add dedicated PTX assembly parser to fix directive filtering (#7839) 2025-06-20 14:46:24 +02:00
Patrick Quist 4069bf3b3e Fix/msvc lib debug release naming (#7840) 2025-06-19 23:15:55 +02:00
Matt GodboltandClaude c1bee5428a Fix EBADF error in HeaptrackWrapper (#7817)
## Summary
- Fixes EBADF error in HeaptrackWrapper by removing redundant file
descriptor close operation
- The net.Socket takes ownership of the FD and closes it during cleanup,
making manual close unnecessary and dangerous

## Root Cause Analysis
The issue occurred in `lib/runtime-tools/heaptrack-wrapper.ts:133` where
the code attempted to manually close a file descriptor that was already
owned by a `net.Socket`. When creating a socket with `new
net.Socket({fd: fd})`, the socket takes ownership of the file descriptor
and closes it during cleanup operations like `resetAndDestroy()`.

Attempting to close the FD again results in:
1. EBADF errors when the FD hasn't been recycled
2. Potentially closing a different resource if the FD has been recycled
by the OS

## Solution
Removed the manual `oldfs.close(fd)` call since the socket handles FD
cleanup automatically. This prevents both the EBADF error and the more
dangerous scenario of closing recycled file descriptors.

## Verification
Created tests to verify that `net.Socket` takes ownership of file
descriptors:
```javascript
// Test confirms that after socket.destroy(), the FD is no longer valid
const fd = fs.openSync(pipePath, O_RDWR | O_NONBLOCK);
const socket = new net.Socket({ fd: fd, readable: true, writable: true });
socket.destroy();
// fs.fstatSync(fd) throws EBADF - confirming FD was closed by socket
```

## Test Plan
- [x] TypeScript compilation passes
- [x] Minimal test suite passes
- [x] Pre-commit hooks pass
- [x] Created unit test to verify net.Socket FD ownership behavior

Fixes COMPILER-EXPLORER-EA7

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-19 13:54:41 -05:00
Patrick Quist 02b4aa9f02 Fix MSVC library naming for debug/release modes (#7838) 2025-06-19 10:40:07 +02:00
Patrick Quist a01104840d Add CopperSpice GUI support with automatic Xcb plugin deployment (#7822) 2025-06-19 07:04:37 +02:00
Mats Jun Larsen b90ac4c382 Ban unused imports (#7827) 2025-06-18 14:21:25 +00:00
Matt Godbolt 9e9e035b28 Rephrase frontend imports (#7824)
- Removes `rootDirs` so all imports will be relative in the frontend
- Updates (and unifies) imports to be `../types/...` etc instead of
relying on "types" being in the rootDir for the frontend.
- Fixes one type that was being picked up from `lib` in the frontend.
- Adds a precommit hook to check in future

Paves the way to writing _unit_ tests for the frontend for the subset of
the frontend code we can import from `node` (which might be a lot of
it!)
2025-06-18 09:04:23 -05:00
Peter Hill 12fcac5e05 Add more recent LFortran linker flag (#7800)
More recent versions of LFortran use `LFORTRAN_LINKER` env var for
linking, rather than `LFORTRAN_CC`.

Tested locally with 0.42 and 0.51
2025-06-17 16:19:40 -05:00
Patrick Quist c702bed510 Prefer Release builds for MSVC compilers in ceconan (#7760) 2025-06-16 21:19:16 +02:00
OfekandOfek Shilon d59702383b Fix regression in rustc-nightly opt remarks (#7818)
<!-- 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: Ofek Shilon <oshilon@speedata.io>
2025-06-16 21:24:52 +03:00
Ofek daf15af5ab Fix #7809 plus some refactoring (#7812)
Fix #7809 and then some:

Stop processing opt-remarks if none were requested,
Make gcc dump remarks to file,
separate opt-file handling to ClangCompiler and GccCompiler,
make DefaultCompiler inherit GccCompiler,
move some tests around.
2025-06-16 10:13:32 -05:00
narpfel 299d7a251c Fix argument parser for Rust >= 1.88 (#7806)
Resolves #7780.

Basically a follow-up to #7652; the output format of `rustc --help` was
changed to include angle brackets `<` and `>`. This PR updates the
regexes used to parse the help output and adds some tests.
2025-06-16 09:55:02 -05:00
Mats Jun Larsen a6e9541c73 Deduplicate csp/cached functions from middleware (#7813) 2025-06-16 09:54:11 -05:00
Matt GodboltandClaude 04972d6aaa Refactor AsmParser to extract testable components (#7777)
## Summary
- Extracted source line handling logic into a dedicated
`SourceLineHandler` class that consolidates .loc, .stabs, and .6502
directive parsing
- Extracted label processing logic into a `LabelProcessor` class with
methods for finding used labels and filtering
- Created a `ParsingState` class to manage parsing loop state variables
in a centralized way
- Fully integrated all components into the main `AsmParser` class,
replacing the original complex parsing loop

## Changes Made
- **SourceLineHandler**: Unifies `.loc`, `.d2line`, `.cv_loc`, `.dbg`,
`.stabn`, and 6502 debug directive parsing
- **LabelProcessor**: Handles complex label detection, filtering, and
cleanup logic with MIPS/non-MIPS support
- **ParsingState**: Encapsulates state management during parsing
(inNvccCode, inCustomAssembly, etc.)
- **Integration**: All components work together through well-defined
interfaces

## Verification
- ✅ All 1082+ tests pass, including new subclass compatibility tests
from PR #7779
- ✅ All 670+ filter tests pass, confirming exact behavior preservation
- ✅ Added comprehensive unit tests for all new components (32 tests
total)
- ✅ TypeScript compilation and linting pass
- ✅ No performance regression in core functionality

## Bug Fix Discovered
The refactoring inadvertently **fixes issue #7781** - EWAVR label
detection bug:
- **Before**: EWAVR couldn't find labels in usage contexts like `ldi
r16, HIGH(_data)` due to `labelFindFor()` returning definition regex
- **After**: Now correctly uses `identifierFindRe` to find labels in
usage contexts
- Updated tests to reflect the corrected behavior

## Benefits
- Reduced complexity in the main `processAsm` method (from 180+ lines to
more manageable chunks)
- Extracted highly testable, focused components with single
responsibilities
- Eliminated code duplication between source handling methods
- Centralized state management reduces scattered variable handling
- Maintained full backward compatibility and exact behavior
- Fixed EWAVR label detection bug as a side effect

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-11 18:22:44 -05:00
c4bb7f7c68 Fix unsafe type casting in assembly processing tools (#7767)
## Summary

Fixes unsafe type casting in assembly processing tools that was causing
`TypeError: text.split is not a function` runtime crashes.

## Root Cause Analysis

**COMPILER-EXPLORER-C2N** (57 occurrences) and **COMPILER-EXPLORER-AWW**
(184 occurrences):

The issue stemmed from tools making unsafe assumptions about
`compilationInfo.asm` type:

```typescript
// CompilationInfo.asm type (from types/compilation/compilation.interfaces.ts:168)
asm?: ParsedAsmResultLine[] | string;  // "Temp hack until we get all code to agree on type of asm"
```

**The bug sequence:**
1. `base-compiler.ts:3120` converts string assembly to parsed format:
`result.asm = [{text: result.asm}]`
2. Tools unsafely cast back to string: `compilationInfo.asm as string`
3. `AsmParser.processBinaryAsm()` calls `splitLines(asmResult)` 
4. If `asm` is actually `ParsedAsmResultLine[]`, `splitLines()` receives
an array
5. `text.split()` fails because arrays don't have `.split()` method

**Affected tools:** osaca-tool, x86to6502-tool, llvm-mca-tool

## Changes

### New Helper Functions in `utils.ts`:

1. **`extractTextLines(asm: string | any[]): string[]`**
   - Safely extracts text lines from union types
- Throws descriptive errors for unexpected types (will surface in
Sentry)

2. **`normalizeAsmToString(asm: string | any[] | undefined): string`**
- Centralizes the common pattern of converting union type to string for
parser consumption
   - Handles undefined gracefully

### Tool Fixes:

- **Removed unsafe casts**: `compilationInfo.asm as string` →
`normalizeAsmToString(compilationInfo.asm)`
- **Added null checks**: Explicit error handling for missing assembly
data
- **Type safety**: No more runtime type assumptions

## Impact

- Eliminates root cause of `text.split is not a function` errors (241+
occurrences combined)
- Maintains existing functionality - tools continue to work normally
- Better error messages when assembly data is missing
- Centralizes type handling logic for future maintainability

**Note:** The underlying architectural issue (union type "temp hack")
remains, but tools now handle it safely without crashes.

Fixes COMPILER-EXPLORER-C2N
Fixes COMPILER-EXPLORER-AWW

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mats Jun Larsen <mats@jun.codes>
2025-06-11 18:04:25 -05:00
Mats Jun Larsen a3be869e3a Replace PascalUtils class with top-level functions (NFC) (#7610) 2025-06-11 07:11:57 +00:00
Matt GodboltandClaude b6a8963652 Fix JSON parsing error in client state handling (COMPILER-EXPLORER-E53) (#7775)
## Summary
- Fixes COMPILER-EXPLORER-E53: SyntaxError: Unexpected end of JSON input
- Adds robust error handling for malformed client state URLs  
- Prevents Sentry notifications for user-caused errors

## Root Cause
The `extractJsonFromBufferAndInflateIfRequired` function and
`unstoredStateHandler` were not properly handling:
- Invalid base64 data in URLs
- Corrupted or malformed JSON after base64 decoding
- Empty JSON strings

This caused uncaught `SyntaxError` exceptions that were being sent to
Sentry as internal server errors.

## Changes
- Added proper error handling for base64 decoding failures
- Added validation for empty JSON strings before parsing
- Changed logging from `warn` to `debug` since this represents user
error
- Removed Sentry capture for malformed URLs to reduce noise
- Return 400 Bad Request instead of 500 Internal Server Error

## Test Plan
- [x] TypeScript compilation passes
- [x] All existing tests pass
- [x] Manual testing with malformed URLs returns 400 instead of 500
- [x] No Sentry errors generated for user-caused malformed URLs

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-10 12:06:25 -05:00
Christoffer Lerno 112d000ad2 Fix C3 0.6.8 (#7786) 2025-06-09 18:09:01 -05:00
timo bd80d171de Add raku language and rakudo compiler (#7784)
This relies on https://github.com/compiler-explorer/infra/pull/1658 to
put rakudo release versions in the right spot.


![image](https://github.com/user-attachments/assets/30ba7c2b-389a-4d3f-895b-c13da5b5f072)

There are more things that can be added, such as opcode tooltips,
suggested options for `--target=parse`, `--target=ast`,
`--target=optimize`, and probably other things I haven't thought of yet.
But this pull request should be a good starting point, and fine to merge
without waiting for further features.
2025-06-09 12:39:53 -05:00
Matt GodboltandClaude f8974b4f5f Fix Rust hexadecimal literal syntax highlighting with underscores (#7766)
## Summary
- Fixes syntax highlighting issue where Rust hex literals with
underscores after hex letters (like `0x01_02_0a_0b`) would lose
highlighting after the underscore
- Created custom Rust language mode (`rustp`) that patches Monaco's
built-in tokenizer
- Filed upstream issue with Monaco Editor:
https://github.com/microsoft/monaco-editor/issues/4917

## Test plan
- [x] Verified fix works locally with test cases like `0x01_02_0a_0b`,
`0xFF_AA_BB_CC`, etc.
- [x] Confirmed all existing tests pass
- [x] Checked that TypeScript compilation and linting pass

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-06 16:21:27 -05:00
Rob Parolin 157662eb31 [mojo-lang] Fixing LLVM IR panel due to calling the mojo compiler with incorrect args. (#7716)
This PR fixes the LLVM IR output for the Mojo compiler integration,
ensuring the LLVM IR panel works correctly and no longer shows "Internal
error; unable to open output path" errors.
2025-05-30 07:48:28 -05:00
narpfel 20bae12039 Add Miri tool for Rust (#7718)
Resolves
https://github.com/compiler-explorer/compiler-explorer/issues/2563.

`misc-builder` PR:
https://github.com/compiler-explorer/misc-builder/pull/112
`compiler-workflows` PR:
https://github.com/compiler-explorer/compiler-workflows/pull/36
`infra` PR: https://github.com/compiler-explorer/infra/pull/1631

Screenshot:

![miri-tool](https://github.com/user-attachments/assets/d866bb42-a242-445b-be52-6fd0b3c877bb)
2025-05-30 07:17:01 -05:00
Patrick Quist abe7d9c836 fixes for windows execution (#7740) 2025-05-30 04:53:20 +02:00
Partouf 2e0549b3fb more fixes 2025-05-28 15:21:02 +02:00