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
6
votes
2 answers

missing _socket after compile python 3.6

I've try compile python3.6 with: emc@belvedere:~/py36/Python-3.6.0rc1> ./configure --prefix=/home/emc/py36 --with-system-expat --with-system-expat --with-system-ffi --disable-ipv6 && make && make install Compilation is success I can start…
emcek
  • 459
  • 1
  • 6
  • 17
6
votes
1 answer

How can I see the optimizations that the compiler applies to my Swift code?

Specifically, I have some Swift 3.0 logging functions that wrap all of their statements in an if that only executes when an operation on two static const values bridged in from ObjC has a nonzero result. func logStuff(_ message: @autoclosure () ->…
jbelkins
  • 470
  • 3
  • 15
6
votes
3 answers

How to detect a new value was added to an enum and is not handled in a switch

From time to time I have to add a new value to a enum type in my project. public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, FILENOTFOUND //this one is new one } What I would like is to have a compile time error…
Persimmonium
  • 15,593
  • 11
  • 47
  • 78
6
votes
1 answer

How to exclude frameworks in simulator builds in Xcode

How can I exclude libraries which I have compiled only for the iOS device architecture (libssh2, etc.) from an Xcode project when I am compiling the app to run on the simulator?
titaniumdecoy
  • 18,900
  • 17
  • 96
  • 133
6
votes
7 answers

Building takes long time. How fight with that?

Speaking about compiled languages (c# in my case) I think that problem would always remain, no matter how performant your develop machine is. Build time could be more or less depending on concrete environment, but often it's enough to make your…
x__dos
  • 1,813
  • 3
  • 27
  • 47
6
votes
1 answer

Problem when #import C++ Header File in iPhone/iPad Project

I have a C++ class I would like to use in an iPhone/iPad project. I created this file in different ways (like with "New File" => C++) and the error is always the same. When I compile the project without having any #import (of the .h C++ class), it's…
Vinzius
  • 2,890
  • 2
  • 26
  • 27
6
votes
1 answer

Using memory barriers to force in-order execution

Trying to go on with my idea that using both software and hardware memory barriers I could disable the out-of-order optimization for a specific function inside a code that is compiled with compiler optimization, and therefore I could implement…
izac89
  • 3,790
  • 7
  • 30
  • 46
6
votes
2 answers

Ifort suppress unused variable warning, leave all others intact

i use ifort and gfortran to compile my Fortran program. However i also use a coworkers source and he has got a lot of unused variables. How can i suppress these for the compile, seeing as they are not really an error? However i dont want to…
tarrasch
  • 2,630
  • 8
  • 37
  • 61
6
votes
2 answers

Why ELF executables have a fixed load address?

ELF executables have a fixed load address (0x804800 on 32-bit x86 Linux binaries, and 0x40000 on 64-bit x86_64 binaries). I read the SO answers (e.g., this one) about the historical reasons for those specific addresses. What I still don't…
OfirD
  • 9,442
  • 5
  • 47
  • 90
6
votes
3 answers

Why is "implicit declaration of function" just a warning?

This is NOT a question on how to resolve the "implicit declaration of function" warnings that appear in C programs, that has been answered many times already. I understand that this is a compiler warning, what I'm wondering is why is this a warning…
mahdiolfat
  • 821
  • 1
  • 9
  • 12
6
votes
4 answers

How to compile rhino/javascript files to .class bytecode for java at runtime

I'm making a falling sand game in Java. I want users to be able to write their own engine for it using a simpler language. Falling sand games can be very CPU intensive so I want to have the engine running as fast as possible while not having to…
aexyl93
  • 93
  • 2
  • 4
6
votes
2 answers

replace semicolon by newline in python code

I would like to parse Python code that contains semicolons ; for separating commands and produce code that replaces those by newlines \n. E.g., from def main(): a = "a;b"; return a I'd like to produce def main(): a = "a;b" return a Any…
Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
6
votes
3 answers

Cannot work out how to run .scm (using guile or scm) files

I have created a abc.scm file and tried to compile it to a binary (or whatever guile scheme compiles to) using "guild compile", "scm" and "guile" commands in terminal in Ubuntu. For "guild compile abc.scm", I get the output "wrote…
Tarun Maganti
  • 3,076
  • 2
  • 35
  • 64
6
votes
2 answers

Problems installing Python 3 with --enable-shared

Problem I'm trying to install Python 3 with the --enable-shared option. Installation "succeeds" but the resulting Python is not runnable. Trying to run Python after installation gives the following error: $…
user2100826
  • 335
  • 2
  • 3
  • 13
6
votes
2 answers

Difference between .cma, .cmo, .cmx files and how to use them correctly in compilation?

I am new to the OCaml and I'm confused with the file of .cma, .cmo and .cmx. Sometimes I have to include a .cma file in the compile command but sometimes I have to include a .cmo file. Why is there a such difference for library? Is it the same…
Quincy Hsieh
  • 184
  • 3
  • 11
1 2 3
99
100