Skip to content
Nathan Myers edited this page Apr 19, 2021 · 19 revisions

Questions about running Compiler Explorer

  • Q: How can I best save the output from Compiler Explorer?

    A: Type Ctrl-S to save your output to a file, or simply preserve the shortened URL. We spend a considerable amount of effort to make sure the saved links you make are permanent. So that should be enough to save it "for another time". The (default) short link stores the code and layout on our servers (where it's backed up and kept as safe as we can configure). The long link encodes the code and layout in a (very long) URL: so at least you know the data's safe.

  • Q: How can I quickly disable automatic compile-on-change?

    A: Type Ctrl-Shift-Enter to toggle the behaviour, or choose the "More" dropdown at the top of the page and deselect "Compile automatically when source changes" under the "Settings" submenu. To trigger a compilation manually, type Ctrl-Enter, or right-click on the listing to pop up a context menu and choose "Compile".

  • Q: How can I tell which compiler options are set?

    A: Click the green/orange checkmark or red cross icon to the right of the compiler, a popup will appear with all the command-line options that were used during compilation.

  • Q: How can I see possible or commonly used compiler options?

    A: Click on the down-arrow button to the right of "compiler options" near the top-right corner of the screen. For a full listing, you can usually use --help or -h to view the help page in the output/error pane.

  • Q: How can I get verbose/debug output from Compiler Explorer when running locally? How do I get it to log the compiler command line executed?

    A: Run Compiler Explorer with the --debug flag e.g. make EXTRA_ARGS="--debug"

  • Q: Is there a simple way to dump GCC intermediate representations from compiler explorer ? -fdump-tree-all shows nothing.

    A: Click the "+" on the compiler output and pick "GCC Tree/RTL Viewer."

  • Q: Can I include a file from an url?

    A: Compiler Explorer has the ability to include raw text to your source, by abusing the #include directive.

    #include <url_to_text_to_include>
    ...

    (See this link a live example: https://godbolt.org/z/Pv0K0c)

    Note that the URL has to allow for cross domain requests for this to work.

  • Q: How long are the short URLs valid for?

    A: To the best of our ability: FOREVER. The short URLs are stored in a backed-up storage on Amazon S3, along with a small database to let us find them quickly. As of current write (March 23rd 2020), the storage takes up ~1GB, and so we don't ever anticipate having issues with storage costs. We also take pains to ensure the compilers and settings specified in the short URLs remain working too.

  • Q: How many threads can I spawn from a program run here?

    A: Normally, three. But if you use -fsanitize=thread, on compilers that support it, that uses up one spawned thread, leaving two for you. You may need to add a compile option such as -pthread. For more advanced cases you might need a support library such as TBB (note the "Include libs" icon above the compile window), and then any other libraries it depends on, such as -ldl -lrt.