Giter Site home page Giter Site logo

compiler-explorer / compiler-explorer Goto Github PK

View Code? Open in Web Editor NEW
15.2K 15.2K 1.6K 67.92 MB

Run compilers interactively from your web browser and interact with the assembly

Home Page: https://godbolt.org/

License: BSD 2-Clause "Simplified" License

Makefile 0.14% JavaScript 0.45% HTML 0.02% Shell 0.10% Batchfile 0.07% Python 2.15% Go 0.01% Java 0.02% C++ 0.02% Pug 2.41% SCSS 2.58% Kotlin 0.01% Ruby 0.05% TypeScript 91.71% Pascal 0.01% PowerShell 0.09% Julia 0.15% Dockerfile 0.01% BitBake 0.01%
assembly c-plus-plus compiler cpp dlang go hacktoberfest haskell ispc rust rust-lang swift

compiler-explorer's Introduction

Build Status codecov

logo

Compiler Explorer

Is an interactive compiler exploration website. Edit code in C, C++, C#, F#, Rust, Go, D, Haskell, Swift, Pascal, ispc, Python, Java, or any of the other 30+ supported languages components, and see how that code looks after being compiled in real time.

Bug Report · Compiler Request · Feature Request · Language Request · Library Request · Report Vulnerability

Overview

Multiple compilers are supported for each language, many different tools and visualizations are available, and the UI layout is configurable (thanks to GoldenLayout).

Try out at godbolt.org, or run your own local instance. An overview of what the site lets you achieve, why it's useful, and how to use it is available here.

Compiler Explorer follows a Code of Conduct which aims to foster an open and welcoming environment.

Compiler Explorer was started in 2012 to show how C++ constructs are translated to assembly code. It started as a tmux session with vi running in one pane and watch gcc -S foo.cc -o - running in the other.

Since then, it has become a public website serving over 3,000,000 compilations per week.

You can financially support this project on Patreon, GitHub, Paypal, or by buying cool gear on the Compiler Explorer store.

Using Compiler Explorer

FAQ

There is now a FAQ section in the repository wiki. If your question is not present, please contact us as described below, so we can help you. If you find that the FAQ is lacking some important point, please feel free to contribute to it and/or ask us to clarify it.

Videos

Several videos showcase some features of Compiler Explorer:

A Road map is available which gives a little insight into the future plans for Compiler Explorer.

Developing

Compiler Explorer is written in TypeScript, on Node.js.

Assuming you have a compatible version of node installed, on Linux simply running make ought to get you up and running with an Explorer running on port 10240 on your local machine: http://localhost:10240/. If this doesn't work for you, please contact us, as we consider it important you can quickly and easily get running. Currently, Compiler Explorer requires node 20 installed, either on the path or at NODE_DIR (an environment variable or make parameter).

Running with make EXTRA_ARGS='--language LANG' will allow you to load LANG exclusively, where LANG is one for the language ids/aliases defined in lib/languages.ts. For example, to only run Compiler Explorer with C++ support, you'd run make EXTRA_ARGS='--language c++'. The Makefile will automatically install all the third-party libraries needed to run; using npm to install server-side and client-side components.

For development, we suggest using make dev to enable some useful features, such as automatic reloading on file changes and shorter startup times.

You can also use npm run dev to run if make dev doesn't work on your machine.

Some languages need extra tools to demangle them, e.g. rust, d, or haskell. Such tools are kept separately in the tools repo.

Configuring compiler explorer is achieved via configuration files in the etc/config directory. Values are key=value. Options in a {type}.local.properties file (where {type} is c++ or similar) override anything in the {type}.defaults.properties file. There is a .gitignore file to ignore *.local.* files, so these won't be checked into git, and you won't find yourself fighting with updated versions when you git pull. For more information see Adding a Compiler.

Check CONTRIBUTING.md for detailed information about how you can contribute to Compiler Explorer, and the docs folder for specific details regarding various things you might want to do, such as how to add new compilers or languages to the site.

Running a local instance

If you want to point it at your own GCC or similar binaries, either edit the etc/config/LANG.defaults.properties or else make a new one with the name LANG.local.properties, substituting LANG as needed. *.local.properties files have the highest priority when loading properties.

If you want to support multiple compilers and languages like godbolt.org, you can use the bin/ce_install install compilers command in the infra project to install all or some of the compilers. Compilers installed in this way can be loaded through the configuration in etc/config/*.amazon.properties. If you need to deploy in a completely offline environment, you may need to remove some parts of the configuration that are pulled from www.godbolt.ms@443.

When running in a corporate setting the URL shortening service can be replaced by an internal one if the default storage driver isn't appropriate for your environment. To do this, add a new module in lib/shortener/myservice.js and set the urlShortenService variable in configuration. This module should export a single function, see the tinyurl module for an example.

RESTful API

There's a simple restful API that can be used to do compiles to asm and to list compilers.

You can find the API documentation here.

Contact us

We run a Compiler Explorer Discord, which is a place to discuss using or developing Compiler Explorer. We also have a presence on the cpplang Slack channel #compiler_explorer and we have a public mailing list.

There's a development channel on the discord, and also a development mailing list.

Feel free to raise an issue on github or email Matt directly for more help.

Official domains

Following are the official domains for Compiler Explorer:

The domains allow arbitrary subdomains, e.g., https://foo.godbolt.org/, which is convenient since each subdomain has an independent local state. Also, language subdomains such as https://rust.compiler-explorer.com/ will load with that language already selected.

Credits

Compiler Explorer is maintained by the awesome people listed in the AUTHORS file.

We would like to thank the contributors listed in the CONTRIBUTORS file, who have helped shape Compiler Explorer.

We would also like to specially thank these people for their contributions to Compiler Explorer:

Many amazing sponsors, both individuals and companies, have helped fund and promote Compiler Explorer.

compiler-explorer's People

Contributors

ams21 avatar apmorton avatar bugwelle avatar cppchedy avatar davidspickett avatar dbroemmel avatar dependabot[bot] avatar dkm avatar frederic-tingaud-sonarsource avatar georgegribkov avatar github-actions[bot] avatar hertzdevil avatar hez2010 avatar ibuclaw avatar jaredwy avatar jeremy-rifkin avatar johanengelen avatar junlarsen avatar marcauberer avatar mattgodbolt avatar mpusz avatar nickpdemarco avatar ofekshilon avatar ojeda avatar partouf avatar renovate[bot] avatar rollbear avatar rscohn2 avatar rubenrbs avatar ubsan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

compiler-explorer's Issues

More compiler options

Adding -fverbose-asm doesn't produce any difference.

-fverbose-asm is of great help when reading generated assembler output since variable name are reported in comments.

Remap compiler executables in URLs

The compilers are stored in the URL by their path. Which is great and simple; but means as and when I upgrade to 14.04 and paths change, there will need to be a mapping from old to new.

So, some new naming scheme is needed, plus a static mapping from the old to new (to keep existing URLs valid).

Permutations

Allow for comparison of two or more permutations of code, compiler version or flags.

Please install node.js

I installed the "nodejs" package (Ubuntu 12.10), but when I run 'make', I still get "Please install node.js".

Update arm toolchains, possible introduce Android NDK

Current available arm toolchains are gcc 4.5 and 4.6 which are old. Having at least 4.8 would be great.

I don't know how gcc-explorer includes toolchains but it might be good to utilize Android's NDK distribution as well. It comes packed with many toolchains and updates in a backward compatible way

List of toolchains available:
arm-linux-androideabi-4.6
arm-linux-androideabi-4.8
arm-linux-androideabi-clang3.3
llvm-3.3
mipsel-linux-android-4.6
mipsel-linux-android-4.8
mipsel-linux-android-clang3.3
renderscript
x86-4.6
x86-4.8
x86-clang3.3

Demo site is not working at the moment.

The 'Assembly output' window is only showing '[Processing...].'

I've tried choosing different compilers (and clicking around pretty much everything) and from different browsers (chrome and firefox), it's the same.

The offline version works thought.

Tooltips to show hex values of decimal constants

via Dennis Lubert: "I wouldn't be myself, if I could not find things to enhance even
more... ;) In one of my examples, I was using hex literals, but of
course the asm output was using decimals. While clang is so nice to show
it in hex, gcc isnt. Would it be hard to make a tooltip for the decimal
literals, showing their value in hex too?"

Diff view

When I

  • change the compiler options, or
  • change my code in the editor pane

show me the assembly diffs from the previous run. (Or have history of runs upon which I can generate diffs.)

Use compile time regexes

D supports compile time regex with ctRegex, which will provide a small performance boost to the code in demangle.d

Ubuntu Clang can output intel syntax

By passing this switch to clang -mllvm --x86-asm-syntax=intel the more readable intel syntax can be shown in the assembly output.

It would be great if this can be incorporated into gcc-explorer so that the Intel syntax button isn't grayed out when Ubuntu clang is selected as the compiler.

use for ACM?

I'm building an online Judge system, want to use this online debug, how should I do?

Label filtering removes jump tables

(reported by Dennis Lubert- thanks Dennis)

Today I tried to look at some code that is evaluating into a jumptable,
like:

void foo(unsigned x)
{
swithc(x)
{
case 0:
bar0();
break;
[ same for at least case 4, otherwise it wont be a jump table. Intreting
is the optimization for three cases btw.]
default:
__builtin_unreachable();
};
}

there in asm a location is created and correctly labeled, but it
contains data like:

.quad .L3
.quad .L4
.quad .L5
etc.

and then later
.L3:
jmp bar1()
.L4
jmp bar2()

etc. but when enabling the unused labels filter, then those get removed
too.

greets

Is there a way to output x86 assembly?

From what I can see, all the compilers on the list are spitting out x64 assembly instructions. Can any of them be configured to compiled 32-bit code instead?

Permalinks

Option to store code and settings at a URL for later retrieval/linking.

Plugin API

Make it easier to extend the explorer, maybe adding simulation tools etc.

Improve code sharing URL generator

I have noticed that the share URL generator just inserts the code and the compiler settings in the URL.
That works, but for large code snippets and sites with limitted URL lengths (Yes Twitter/stackoverflow, I'm talking about you...) that URLs cannot be shared easily/directly.

It would be awesome if the web generates better (shorter) urls. I think that URLs are generated in that way because GCC explorer server does not host the sourcecode, only provides a compiler frontend. But would be great if the server push the code automatically to a web like pastebin.com, and when the URL is accessed, that code is pulled from that web and written in gcc-explorer automatically.

Support running as a daemon

Using forever or similar; it would be ideal if gcc-explorer daemonised properly. There are issues with the current code with its use of relative includes which seem to fail in forever.

Java support (no, seriously)

Commands:

javac Foo.java
javap - c Foo

Example code:

import java.util.ArrayList;

class Foo {

  void iterateList() {
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(1);
    list.add(2);
    list.add(3);

    for (int i : list) {
      System.out.println(i);
    }
  }

  void iterateArray() {
    int[] array = {1, 2, 3};

    for (int i : array) {
      System.out.println(i);
    }
  }

}

Example output:

Compiled from "Foo.java"
class Foo extends java.lang.Object{
Foo();
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

void iterateList();
  Code:
   0:   new #2; //class java/util/ArrayList
   3:   dup
   4:   invokespecial   #3; //Method java/util/ArrayList."<init>":()V
   7:   astore_1
   8:   aload_1
   9:   iconst_1
   10:  invokestatic    #4; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
   13:  invokevirtual   #5; //Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
   16:  pop
   17:  aload_1
   18:  iconst_2
   19:  invokestatic    #4; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
   22:  invokevirtual   #5; //Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
   25:  pop
   26:  aload_1
   27:  iconst_3
   28:  invokestatic    #4; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
   31:  invokevirtual   #5; //Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
   34:  pop
   35:  aload_1
   36:  invokevirtual   #6; //Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
   39:  astore_2
   40:  aload_2
   41:  invokeinterface #7,  1; //InterfaceMethod java/util/Iterator.hasNext:()Z
   46:  ifeq    72
   49:  aload_2
   50:  invokeinterface #8,  1; //InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
   55:  checkcast   #9; //class java/lang/Integer
   58:  invokevirtual   #10; //Method java/lang/Integer.intValue:()I
   61:  istore_3
   62:  getstatic   #11; //Field java/lang/System.out:Ljava/io/PrintStream;
   65:  iload_3
   66:  invokevirtual   #12; //Method java/io/PrintStream.println:(I)V
   69:  goto    40
   72:  return

void iterateArray();
  Code:
   0:   iconst_3
   1:   newarray int
   3:   dup
   4:   iconst_0
   5:   iconst_1
   6:   iastore
   7:   dup
   8:   iconst_1
   9:   iconst_2
   10:  iastore
   11:  dup
   12:  iconst_2
   13:  iconst_3
   14:  iastore
   15:  astore_1
   16:  aload_1
   17:  astore_2
   18:  aload_2
   19:  arraylength
   20:  istore_3
   21:  iconst_0
   22:  istore  4
   24:  iload   4
   26:  iload_3
   27:  if_icmpge   50
   30:  aload_2
   31:  iload   4
   33:  iaload
   34:  istore  5
   36:  getstatic   #11; //Field java/lang/System.out:Ljava/io/PrintStream;
   39:  iload   5
   41:  invokevirtual   #12; //Method java/io/PrintStream.println:(I)V
   44:  iinc    4, 1
   47:  goto    24
   50:  return

}

C love

Can we get some C love? The C++ support is great so far but I would find it much more useful if you would add gcc to the list of compilers.

While g++ supports a subset of C there's still C99 and C11. Please add gcc support, not only g++.

PS: sorry for the closed/reopend the mouse went crazy

Support external URL shortening services for permalinks

Needs to be optional so that internal sites don't try and URL shorten with private content. We'll need to change how the permalink button works to do "Just in time" URL shortening somehow too, else will be generating a new URL every key press which might upset the URL services...

PowerPC support

Via Frank Barchard "Although Google focus on x86 and arm, the game industry works on PowerPC for xbox360, Wii and PS3.
Chrome unofficially supports PPC and youtube have an app for consoles.
So after Arm, its the next most interesting CPU, and ensures code works on other cpus. Plus its big endian."

Add compilation timeout

The compiler runtime should be limited. A virtual memory limit would be nice.

Sorry for killing the server.

Checkbox selection of compiler options

In addition to allowing the user to type in the compiler flags into the "Compiler Options:" text area (for example "-O2 -std=c++0x -march=native"), present a checklist of option and option descriptions (perhaps ripped from the manpage. User can go through and check off the ones she'd like to try, generating the command line on-the-fly.

Clang output overflows buffers

include

using namespace std;

int main(int argc, char* argv[]) {
cout << "Test program" << endl;

return 0;
}

with clang 3.0-6 gives "stdout maxBuffer exceeded".

Ideally shouldn't do this; or at least should give a decent error!

Add support for latest GCC and Clang

The latest GCC and Clang have arguably made fairly large performance improvements along with adding additional functionality and flags.

Could we get the latest versions of GCC and Clang on the gcc.godbolt.org website? Here are the links (I think you're in the UK - so I chose mirror servers near there):

Also, if possible, it'd be nice to have Intel's latest compiler if they'd give you this year's copy (the site is on 13.0.1):


Also, thank you so much for creating and hosting the service, @mattgodbolt!

ENOENT in some cases

Error: ENOENT, no such file or directory '/tmp/gcc-explorer-compiler114111-31419-u0oy8k/output.S'

for example, in /var/log/syslog on the gcc explorer machines

Make resistent to trivial DoSes

For example:

$ for i in $(seq 100); do (curl 'http://gcc.godbolt.org/compile' -H 'Origin: http://gcc.godbolt.org' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.91 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://gcc.godbolt.org/' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data "source=%23include+%3Cstring%3E%0Astd%3A%3Astring+a()+%7B+return+%22moose$i%22%3B+%7D&compiler=g490&options=-O3+-std%3Dc%2B%2B0x&filters%5Bintel%5D=true" --compressed &); done

Is pretty good at taking down the site. In theory there should be no more than two compiles at once, but I suspect while the compiles may get gated the responses are not and so eventually the response-sending uses up too much memory. The site dies due to the OOM killer running

Installing problem related to libffi

I'd like to install the gcc-explorer on my machine. However, when trying to install it I'm confronted with the following compile error:

TOUCH Release/obj.target/libffi.stamp
CXX(target) Release/obj.target/ffi_bindings/src/ffi.o
../src/ffi.cc: In static member function ‘static v8::Handlev8::Value FFI::FFICallAsync(const v8::Arguments&)’:
../src/ffi.cc:286:30: error: invalid conversion from ‘void ()(uv_work_t) {aka void ()(uv_work_s)}’ to ‘uv_after_work_cb {aka void ()(uv_work_s, int)}’ [-fpermissive]
/home/benni/.node-gyp/0.10.12/deps/uv/include/uv.h:1432:15: error: initializing argument 4 of ‘int uv_queue_work(uv_loop_t_, uv_work_t_, uv_work_cb, uv_after_work_cb)’ [-fpermissive]

Right now, I have on clue where to search for a solution. Maybe you can give me some hint? Should I blame libffi for the error?

Thanks, Benni

Support internal URL shortening

As per the external URL shortener feature, for internal instances of GCC Explorer it would be nice to have a built-in short URL system.

Add objdump, binary view of the compilation

This is a request asking if it is possible to add objdump, binary view of the compilation.

Sometimes you would like to see what are the binary values for the instructions being shown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.