Recently I found myself trying to find a definitive list of the options supported by scalac, the Scala compiler. It turns out that I could have just asked the compiler itself (the -X option lists all “advanced” options and the -Y option lists all “private” options). But this is very difficult to find via Google.
So I thought that I’d create this page and hopefully save anyone else looking for the same information some time.
$ scalac -version Scala compiler version 2.8.0.RC1 -- Copyright 2002-2010, LAMP/EPFL
Advanced Options
$ scalac -X Usage: scalac <options> <source files> Possible advanced options include: -Xassem-extdirs <dirs> List of directories containing assemblies, defaults to `lib' -Xassem-name <file> Name of the output assembly (only relevant with -target:msil) -Xassem-path <path> List of assemblies referenced by the program (only relevant with -target:msil) -Xcheck-null Emit warning on selection of nullable reference -Xcheckinit Add runtime checks on field accessors. Uninitialized accesses result in an exception being thrown. -Xdisable-assertions Generate no assertions and assumptions -Xelide-below Generate calls to @elidable-marked methods only if method priority is greater than argument. -Xexperimental Enable experimental extensions -Xfuture Turn on future language features -Xgenerate-phase-graph <file> Generate the phase graphs (outputs .dot files) to fileX.dot -Xlog-implicits Show more info on why some implicits are not applicable -Xmigration Warn about constructs whose behavior may have changed between 2.7 and 2.8 -Xno-forwarders Do not generate static forwarders in mirror classes -Xno-uescape Disables handling of \u unicode escapes -Xnojline Do not use JLine for editing -Xplugin-disable:<plugin> Disable a plugin -Xplugin-list Print a synopsis of loaded plugins -Xplugin-require:<plugin> Abort unless a plugin is available -Xplugin:<file> Load a plugin from a file -Xpluginsdir <path> Path to search compiler plugins -Xprint-icode Log internal icode to *.icode files -Xprint-pos Print tree positions (as offsets) -Xprint-types Print tree types (debugging option) -Xprint:<phase> Print out program after <phase> or "all" -Xprompt Display a prompt after each error (debugging option) -Xresident Compiler stays resident, files to compile are read from standard input -Xscript <object> Compile as a script, wrapping the code into object.main() -Xshow-class <class> Show class info -Xshow-object <object> Show object info -Xshow-phases Print a synopsis of compiler phases -Xsource-reader <classname> Specify a custom method for reading source files -Xsourcedir <directory> When -target:msil, the source folder structure is mirrored in output directory. -Xstrict-warnings Emit warnings about lots of things. -Xwarninit Warn about possible changes in initialization semantics -Y Print a synopsis of private options
Private Options
$ scalac -Y Usage: scalac <options> <source files> Possible private options include: -Ybrowse:<phase> Browse the abstract syntax tree after <phase> or "all" -Ybuild-manager-debug Generate debug information for the Refined Build Manager compiler. -Ybuilder-debug:<method> Compile using the specified build manager (none,refined,simple) -Ycheck:<phase> Check the tree at the end of <phase> or "all" -Yclosure-elim Perform closure elimination -Ycompact-trees Use compact tree printer when displaying trees -Ydead-code Perform dead code elimination -Ydebug Output debugging messages -Ydetach Perform detaching of remote closures -Yfatal-warnings Fail the compilation if there are any warnings. -Yide-debug Generate, validate and output trees using the interactive compiler. -Yinline Perform inlining when possible -Yjenkins-hashCodes Use jenkins hash algorithm for case class generated hashCodes. -Ylinearizer:<which> Linearizer to use (normal,dfs,rpo,dump) -Ylog-classpath Output information about what classpath is being applied. -Ylog:<phase> Log operations in <phase> or "all" -Yno-completion Disable tab-completion in the REPL -Yno-generic-signatures Suppress generation of generic signatures for Java -Yno-imports Compile without any implicit imports -Yno-predefs Compile without any implicit predefined values -Ypmat-debug Trace all pattern matcher activity. -Ypmat-naive Desugar matches as naively as possible.. -Yrangepos Use range positions for syntax trees. -Yrecursion Recursion depth used when locking symbols -Yrepl-debug Trace all repl activity. -Yself-in-annots Include a "self" identifier inside of annotations -Yshow-trees Show detailed trees when used in connection with -print:phase -Yskip:<phase> Skip <phase> or "all" -Ysqueeze:<enabled> if on, creates compact code in matching (on,off) -Ystatistics Print compiler statistics -Ystop:<phase> Stop after phase <phase> or "all" -Ystruct-dispatch:<method> Selects dispatch method for structural refinement method calls (no-cache,mono-cache,poly-cache,invoke-dynamic) -Ysuppress-vt-typer-warnings Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL! -Ytailrecommend Alert methods which would be tail-recursive if private or final. -Ytyper-debug Trace all type assignements -Ywarn-catches Emit warnings about catch blocks which catch everything. -Ywarn-dead-code Emit warnings for dead code -Ywarn-shadowing Emit warnings about possible variable shadowing.
