I keep hearing the term and all google searches lead me to articles on compilers. I just wanna understand what the term compile target means :|

UPDATE: To give some context: I've heard it said that web assembly is a compile target for for other languages such as C, C++, Rust etc.

  • I'd advise you to read the articles on compilers. – user232573 Mar 21 '17 at 12:28
  • 4
    Articles on compilers assume you know this already. It's a reasonable question. – Karl Bielefeldt Mar 21 '17 at 12:47
  • I was thinking more about wikipedia-style articles. And I agree the question's reasonable. It was just a suggestion, not a criticism. – user232573 Mar 21 '17 at 12:56
  • 4
    The question is reasonable, but badly written. The term "target" can have differents meanings, so I would recommend to give a reference or more context where you heard it or read about it. – Doc Brown Mar 21 '17 at 13:00
  • @DocBrown I've heard it in many contexts, but most-recently in the context of web assembly being a compile target for other languages. – ScionOfBytes Mar 22 '17 at 6:44

Compilers are, in essence, translators that take input in one language and produce output in another. For example, Eiffel Software's compiler takes Eiffel-language input and produces C. GCC for Intel reads C-language input and produces x86 assembly. The GAS assembler for Intel takes x86 assembly and produces x86 object code. All three of these things are technically compilers.

Regardless of format, the input read by a compiler is called the source and the output is called the target. The latter term is taken from one of its definitions, "intended result."

The majority of compilers are designed to produce assembly or object code for a particular processor or architecture. Because of that, target is often used to refer to the architecture itself rather than the output format.

The target of a compiler does not need to be the same as the architecture where it runs, and in instances where that happens, the program is called a cross-compiler. (For example, GCC can be built to run on x86 systems to compile C into ARM assembly.)

Additionally, there are single compilers capable of producing output for different targets depending on input such as switches on the command line. These are called multi-target compilers.

  • 2
    As a side note, might be worth mentioning that this term is also used in a more generalized form in the context of build systems - a target is an output from any build step, which doesn't necessarily have to be a compilation action (e.g. creating an installer). – BartoszKP Mar 21 '17 at 13:18
  • 2
    compilers are translators, not filters. – user223083 Mar 21 '17 at 19:31
  • 1
    @Birfl. obviously. "tr" means translate, not filter. filters are not translators, this is just obvious. – user223083 Mar 21 '17 at 20:32
  • 2
    @Birfl: i do not go by wikipedia. just producing one stream from another ssys nothing . the distinction between filters and translators is very well known. a filter includes/excludes, based on a predicate. it does not transform. filter a list of integers by even? and you get untransformed even integers. translate the same list using inc and you get a transformed version of the original list. – user223083 Mar 21 '17 at 21:09
  • 1
    your account of compilation is fine except for the term "filter". – user223083 Mar 21 '17 at 21:13

In translation, whether language is a natural language like English, or an artificial one like C, we use the terminology source and target to talk about the input and output of a translation system. In natural language translation, the system is the competent human brain capable of translating between two languages. In programming languages, it is a compiler.

Thus, the source for a compiler is the programming language (C), while the target is the bytecode (machine-level instructions). We often use target in compilation because different systems (CPU architectures) have different instruction sets, e.g. ARM, MIPS, etc. The compiler needs to know which instruction set is the target, so that it can create the correct output (bytecode).


WebAssemby is something latest and greatest, which converts the c/c++ code in binary format.

  • WebAssembly aims to execute at native speed by taking advantage of common hardware. It designed to integrate with web platform.

Here is the link where one of the application you can see, how fast it convert the simple factorial program in machine code.

Check this beast, https://godbolt.org/

You can use this sample program to run in that site to see assembly.

# include<stdio.h>

int square(int num) {
    return num * num;

int main() {
    int res = square(4);
  return 0;
  • Define a portable, size- and load-time-efficient binary format to serve as a compilation target which can be compiled to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms, including mobile and IoT.

Some basic info about host and target, how programming language is translated into 10101010.

host=>pc :(windows, iOS, Linux, zOS, Solaris..etc)
target=>CPUhardware: (Intel x86, ARM, PowerPC, etc)
  1. GCC convert the C/C++ code into assembly code. A tool called "assembler" converts the assembly code into machine code and a tool called "linker" connects multiple machine-code files into one single executable (.EXE under Windows) file. Most of these compilers allow you to write the resulting assembler code into a file so you can look at the assembler code or modify it.

  2. The assembler and the linker are part of the tool chain which means that they are typically delivered together with the compiler.

  3. Some compilers (like Microsoft) however directly convert C/C++ code into machine language so no assembler is needed any more. Many of these compilers are not able to create assembler code so you cannot write the assembler code into a file.

By the way: There are even compilers (not for C/C++, but for other programming languages) that directly create an .EXE file so no linker is required.

WebAssembly: https://github.com/WebAssembly/design

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.