Questions tagged [compilation]

Compilation is the transformation of source text into some other form or representation. The most common usage of this tag is for questions concerning transformation of a programming language into machine code. This tag is normally used with another tag indicating the type of the source text such as a programming language tag (C, C++, Go, etc.) and a tag indicating the tool or compiler being used for the transformation (gcc, Visual Studio, etc.).

Compilation is the transformation of source text into some other form or representation. The software tool used is called a compiler. Most compilers process the source text to generate some sort of machine code for a target hardware machine. Some compilers generate the "machine code" for a target virtual machine (e.g. bytecode for a Java Virtual Machine).

In all of these cases the compiler creates new files of the transformed source text and these new files are used in some other processing step up to and including executing directly on hardware or virtual hardware.

Interpretation is the processing of source text by a software tool called an interpreter. Interpreters immediately execute the sense of the source text without generating a new, externally visible form of the source text. Compilers generate a new, externally visible form of the source text which is then executed by some other device whether actual hardware or virtual machine.

The lines between interpreters and compilers have blurred somewhat with the introduction of languages whose tools generate an intermediate language which is then executed on an internal virtual machine. The traditional compiler generates machine code files which are then further processed into an application to execute. The traditional interpreter parses the source text line by line performing some action indicated by the line of source text at the time the line of source is read.

A C or C++ compiler generates object files containing binary code which are then processed by a linker into an application and executed. A Java compiler generates class files containing Java Virtual Machine byte code which are then combined into a Java application and executed.

Engines for scripting languages such as Php and JavaScript may use an internal compiler to generate an intermediate form of the source text which is then executed by an internal virtual machine. For some types of applications the intermediate form is temporarily stored or cached so that if the same script is being used by multiple threads or multiple repetions in a short time span, the overhead of rescaning the source text is reduced to improve efficiency. However these are not considered to be compilers.

Compilation usually involves the following steps:

  • Scanning - The scanner is responsible of tokenizing the source code into the smallest chunks of information (keywords, operators, brackets, variables, literals etc.).
  • Parsing - The parser is responsible with creating the Abstract Syntax Tree (AST) which is a tree representation of the code according to the source language definition.
  • Optimization - The AST representing the code is sent through various optimizers in order to optimize for speed or space (this part is optional).
  • Code generation - The code generator creates a linear translated document from the AST and the output language definition.

In many languages and compilers there are additional steps added to the process (like pre-processing), but these are language and compiler specific.

In most cases, where compilation is a part of the build/make/publish process, the output of the compiler will be sent to the linker which will produce the ready-to-use files.

Questions using this tag should be about the compilation process, not about how to write compilers for example (use the compiler tag for that).

17181 questions
43
votes
8 answers

Broken c++ std libraries on macOS High Sierra 10.13

I recently bought a new MacBook on which I transferred my old session. Since then, and after i upgraded to 10.13, i can't get clang to compile anything including only iostream. Given this program : #include int main(void) { …
Marcadia
  • 538
  • 1
  • 4
  • 9
43
votes
16 answers

Why is inlining considered faster than a function call?

Now, I know it's because there's not the overhead of calling a function, but is the overhead of calling a function really that heavy (and worth the bloat of having it inlined) ? From what I can remember, when a function is called, say f(x,y), x and…
kodai
  • 3,080
  • 5
  • 32
  • 34
43
votes
25 answers

Xcode 8.0 Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

When I compile my code on Xcode Version 8.0 beta 4 (8S188o) I get this single error bringing the compilation to failure: Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit…
Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
43
votes
7 answers

aidl is missing android studio

Environment: Mac OS 10.10.3 Android studio:1.2.11 grandle:2.2.1 the log: Information:Gradle tasks [:generateDebugSources, :generateDebugTestSources] :preBuild :preDebugBuild :checkDebugManifest :prepareDebugDependencies :compileDebugAidl…
user2580278
  • 631
  • 1
  • 5
  • 8
42
votes
3 answers

How to prevent non-specialized template instantiation?

I have a templated class (call it Foo) which has several specializations. I would like the compilation to fail if someone tries to use an unspecialized version of Foo. Here is what I actually have: template class Foo { Foo() {…
ereOn
  • 53,676
  • 39
  • 161
  • 238
42
votes
3 answers

What is the reason function names are prefixed with an underscore by the compiler?

When I see the assembly code of a C app, like this: emacs hello.c clang -S -O hello.c -o hello.s cat hello.s Function names are prefixed with an underscore (e.g. callq _printf). Why is this done and what advantages does it…
user142019
42
votes
3 answers

Is Clojure compiled or interpreted?

I read somewhere Clojure is compiled. Is it really compiled, like Java or Scala, rather than interpreted, like Jython or JRuby?
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
42
votes
2 answers

TypeScript tsconfig settings for Node.js 10?

Does anyone know which target/libs are required for Node.js v10.x to use the built in async/await without the generators? I see a lot for node 8 but not with node 10.
four43
  • 1,675
  • 2
  • 20
  • 33
42
votes
7 answers

C++ how to manage dependencies (use libraries from github for example)

I'm very new to C++ world, so please, sorry for such a dummy question. I googled a little, but wasn't able to find a proper answer. My question is fairly simple - how should I use libraries in C++ world. For example in Java - there is maven and…
silent_coder
  • 6,222
  • 14
  • 47
  • 91
42
votes
12 answers

How do YOU reduce compile time, and linking time for Visual C++ projects (native C++)?

How do YOU reduce compile time, and linking time for VC++ projects (native C++)? Please specify if each suggestion applies to debug, release, or both.
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
42
votes
6 answers

Xcode 6.1: file was built for x86_64 which is not the architecture being linked (i386)

I've created a Swift framework project for util/extensions that compiles and copies a .framework file to a dedicated location on my system. I want to be able to include this file into other projects (Build Phases/Link Binary with Libraries). The…
BadmintonCat
  • 9,416
  • 14
  • 78
  • 129
42
votes
3 answers

go build works fine but go run fails

I have a few files in the main package under one directory: main.go config.go server.go When I do: "go build" the program builds perfect and runs fine. When I do: "go run main.go" it fails. Output: # command-line-arguments ./main.go:7: undefined:…
Roel Van Nyen
  • 1,279
  • 1
  • 9
  • 19
42
votes
4 answers

How does make know which files to update

I noticed that when I make changes to some files and then I type make, it will run certain commands related to those files. If I don't change anything, then make doesn't do anything, saying that the program is up to date. This tells me that make…
neuromancer
  • 53,769
  • 78
  • 166
  • 223
42
votes
5 answers

Maven skip compile

I want to use Maven to execute a certain plug-in that only needs the source code but I do not want Maven to compile anything (mostly because the project just doesn't compile). How do I tell Maven to skip the compile step and just launch its plug-in…
salbeira
  • 2,375
  • 5
  • 26
  • 40
41
votes
6 answers

How can I use VIM to do .Net Development

Visual Studio is the defacto editor, but what are our other options that avoid a heavy UI while still integrating with a C# build chain? Looking for options which preferably use vi or vim directly, and those which emulate some or all of the…
Tab
  • 1,702
  • 2
  • 19
  • 39