Swift compiler options in Compiler Explorer ('Godbolt')

When trying out Swift code on Compiler Explorer (‘Godbolt’), what codes can you type into the Compiler Options textbox in the output window? I’d like to add the Build Settings I use for my current project. Traditional C options like “-O3” just give a “Compilation failed” error, as do copying XCode Build Settings codes (e.g. “GCC_OPTIMIZATION_LEVEL=fast”). What’s the proper syntax here?

the compiler explorer interface essentially just wraps an invocation to a swiftc binary. any of the options that the compiler supports should work (such as those enumerated by swiftc --help). Xcode build settings usually have some translation to underlying flags, which you can perhaps find by inspecting the build output log.

here is an example that builds the default swift sample code in two compilers – one with optimizations (-O) and one without (-Onone).

I would try the swiftc --help command for the list of available options.
Edit: Oh, Jamie beat me to it :)

2 Likes

Thanks, that works; I typed in -Ounchecked and got output. Looks similar to what I’ve seen in Time Profiler in Instruments, with a lot of boilerplate tacked onto the end.