Skip to main content

cexpl

Command-line tool to interact with Compiler Explorer.

asciicast

Overview

cexpl is able to query all available languages, compilers, build and execute your source code. You can also give some extra arguments, like compiler flags, command-line arguments and STDIN.

The Compiler Explorer API host can be specified with the -H/--host option.

List available languages

The --list-langs option lists all languages and their IDs:

$ cexpl --list-langs
ada - Ada
analysis - Analysis
assembly - Assembly
c - C
c++ - C++
carbon - Carbon
circle - C++ (Circle)
circt - CIRCT
clean - Clean
cpp2_cppfront - Cpp2-cppfront
...

The language ID can be used with the -l/--lang option.

List available compilers

The --list-compilers option lists all compilers and their IDs:

$ cexpl --list-compilers
386_gl114 - 386 gc 1.14
386_gl115 - 386 gc 1.15
386_gl116 - 386 gc 1.16
386_gl117 - 386 gc 1.17
386_gl118 - 386 gc 1.18
386_gl119 - 386 gc 1.19
386_gltip - 386 gc (tip)
6g141 - amd64 gc 1.4.1
aarchg54 - ARM64 gcc 5.4
arduinomega189 - Arduino Mega (1.8.9)
...

It is also possible to list the compilers for a specific language. For example, cexpl --list-compilers python will list all available Python compilers.

The compiler ID can be used with the -c/--compiler option.

Compilation and execution

In order to compile, you need to pass the file containing the source code. cexpl will try to figure out the language and its default compiler based on the file extension. You can specify the language and/or the compiler with --lang and/or --compiler option, as said above.

$ cexpl love.c
.LC0:
        .string "<3"
main:
        push    rbp
        mov     rbp, rsp
        mov     edi, OFFSET FLAT:.LC0
        call    puts
        mov     eax, 0
        pop     rbp
        ret

The source code:

#include <stdio.h>

int main() {
    printf("<3\n");
    return 0;
}

You can pass options to the compiler with the --cflags option.

Comparing source code and assembly

Use the -C/--compare option to compare the source code with the assembly:

$ cexpl --compare --cflags=-Ofast love.c
.LC0:
        .string "<3"
main:
3 int main() {
        sub     rsp, 8
4 printf("<3\n");
        mov     edi, OFFSET FLAT:.LC0
        call    puts
6 }
        xor     eax, eax
        add     rsp, 8
        ret

Execution

The -e/--exec option executes the code:

$ cexpl --exec --skip-asm love.c
STDOUT:
<3

If you don't want to see the generated assembly, use the -s/--skip-asm option.

Arguments and input

You can pass a list of arguments with the -a/--args option. For example, cexpl --args one two three --exec main.c. The same applies to the --stdin option:

$ cexpl --skip-asm --exec --stdin "Gustavo Costa" 20 -- hi.py
STDOUT:
Gustavo Costa, 20 years old

The source code:

name = input()
age = input()
print(f'{name}, {age} years old')

Saving your results

You can generate a short link for the compilation with the -L/--link option.

License

Copyright (c) 2022 Gustavo Costa. Distributed under the MIT license.

Metadata

Release files for cexpl 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cexpl 0.1.0
File Size Uploaded Provenance Actions
cexpl-0.1.0.tar.gz 8.2 kB Without provenance Details for cexpl-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cexpl 0.1.0
File Interpreter ABI Platform Actions
cexpl-0.1.0-py3-none-any.whl Python 3 none any Details for cexpl-0.1.0-py3-none-any.whl

Total release size: 17.5 kB

Release files / cexpl-0.1.0.tar.gz

Download URL cexpl-0.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9504a108e3dd7b09b8dbde22001dfd9f50adfcadb3089b2999f7295f6bb02c47
BLAKE2b-256 checksum
How to use checksums
2ab748a64b152b6bc1e2a258dcccafb29dfe016c06d303a2f5ce40bca0a0eaec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0rc2

Release files / cexpl-0.1.0-py3-none-any.whl

Download URL cexpl-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce636ed908ccbcd56344be6489d95879950a26a22a9601cc35c92d79668d668a
BLAKE2b-256 checksum
How to use checksums
a5f581cd9532b5e545926ed013ba60ecda8ca1596945e69604395d129f5bbc58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0rc2

Security for cexpl 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page