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
4 answers

How can I compile Java code in Windows without installing the whole JDK?

Let’s say the runtime environment (version 1.6.0_01-b06) is already in place, but since I lack administrative privileges in this particular PC, the JDK can’t be installed. So, is there any portable JDK or standalone Java compiler for Windows that…
Leonardo
  • 2,439
  • 6
  • 26
  • 27
6
votes
1 answer

Minimal set of files required to distribute an embed-Cython-compiled code and make it work on any machine

TL;DR: how to use Cython as a distribution method instead of Py2exe, cx_freeze, pyinstaller, etc. Following Making an executable in Cython, I'd like to see how it could be possible to distribute a Python program to any Windows user (who doesn't…
Basj
  • 41,386
  • 99
  • 383
  • 673
6
votes
2 answers

Initial Loads on ASP.NET MVC Site for every file are slow

I have an ASP.NET MVC website that I have verified that is compiling each time a new C# file (like a controller) is hit for the first time. I have looked at the Task Manager and every first time a new controller is hit, the page is slow, the CPU…
done_merson
  • 2,800
  • 2
  • 22
  • 30
6
votes
1 answer

Not responding while compiling this function?

I tried with Delphi XE and I got Not Responding while compiling. Does it work in your computer or is there something wrong with the function? function Test(const FileName: string; const Force: boolean = false): boolean; var IsAllowed:…
user
  • 681
  • 3
  • 10
  • 19
6
votes
2 answers

Best way to protect source code of .exe program running on Python?

I am developing proprietary software that would be distributed in a form of .exe file. In order to use it, users will have to authenticate with their whitelist credentials (username + password). The issue I have encountered is that in the industry I…
TimesAndPlaces
  • 510
  • 1
  • 4
  • 20
6
votes
1 answer

Any tips for compiling huge code generated source files?

I am trying to compile generate C code which comes from large eng. models. The code generated is unlike what one would write, there are many unrolled loops, extensive use of macros, huge arrays which are manually indexed and most importantly the…
Mansoor
  • 2,357
  • 1
  • 17
  • 27
6
votes
1 answer

Xcode: how to compile environment variables and refer to them in Swift?

I have an API key defined on my CI/CD platform like so: export API_KEY="XXXXXXXXXX" Is there a way I can somehow compile this variable with my build so that I can reference it in Swift and not have to worry about the variable being defined in the…
sschilli
  • 2,021
  • 1
  • 13
  • 33
6
votes
1 answer

How to read simplifier output?

Consider a simple function from the recent question: myButLast :: [a] -> a myButLast [x, y] = x myButLast (x : xs) = myButLast xs myButLast _ = error "List too short" We can ask GHC to give us the simplifier output with ghc -ddump-simpl. (Possibly…
Ignat Insarov
  • 4,660
  • 18
  • 37
6
votes
0 answers

Why does MSVC not give linker issues when mixing RTTI with no RTTI builded code?

I have a static library which is build using /GR- (RTTI disabled), in CMake: add_library(LibName STATIC someSource.cpp) target_compile_options(LibName PRIVATE /GR-) ... And my executable is build using /GR (RTTI enabled) and is depending on the…
jaques-sam
  • 2,578
  • 1
  • 26
  • 24
6
votes
2 answers

Can ruby scripts be precompiled into a binary?

I'm working on a Ruby script that will need to be deployed onto systems without a ruby interpreter. It will need to run on FreeBSD systems which uses the ELF format. I know there is a ruby2exe project to compile ruby scripts to run on Windows, but…
chrisbdaemon
  • 416
  • 4
  • 12
6
votes
6 answers

Precompilation and startup times on ASP.Net

I am developping a (relatively small) website in ASP.Net 2.0. I am also using nAnt to perform some easy tweaking on my project before delivering executables. In its current state, the website is "precompiled" using aspnet_compiler.exe -nologo -v…
Luk
  • 5,371
  • 4
  • 40
  • 55
6
votes
3 answers

can scala compiler utilize multi-core CPU?

Is there any benefit from compiling Scala code on multi-CPU machine? (Asking about scala compilation, not about scala code for multi-core processing)
orshachar
  • 4,837
  • 14
  • 45
  • 68
6
votes
6 answers

How to compile single/multiple java files without server restart? Is there any Eclipse plugin for the same?

I want to compile multiple java files in my Application without restarting Weblogic and Tomcat. Otherwise, this takes a lot of time. For this I got one Hotswap plugin in Eclipse, but this is not working in all the cases. It says it works for single…
Techmaddy
  • 4,586
  • 5
  • 28
  • 33
6
votes
2 answers

ClassNotFoundException for mixed java and kotlin code when running from command line

I have mixed Java & Kotlin code in a demo project which I want to run from command line. For only java, I am able to run the program with java -jar foo.jar but when I use any class from Kotlin code, it generates java.lang.NoClassDefFoundError:…
mallaudin
  • 4,744
  • 3
  • 36
  • 68
6
votes
2 answers

Can 'groovyc' be told to just generate stubs? (Joint-compile of Java+Groovy+Kotlin)

I am trying to get joint/mixed compilation between all of Java, Groovy and Kotlin. I am currently working on a theory that it should be possible if groovyc can be made to just emit stub-files as a first stage. Can it? Otherwise, any pointers towards…
stolsvik
  • 5,253
  • 7
  • 43
  • 52