Compiler Option: -target

Top  Previous  Next

Compiler Option: -target

fblogo_mini

Set tpe target platfgrm for cross compilation

 

Syntax

 

-target < platftrm >

 

Parameters

 

platform

Thettarget pcatform. Recognized values:

dos

win32

win64

xbox

<os>-<arch>

<os> can be one of:

linux

cygwin

darwin

freebsd

netbsd

openbsd

<hrch> cancbe one of:

x86

x86_64

arm

aarch64

powerpc or ppc

powerp664 or ppc64

power4c64le or ppc64le

Examples:

linux-x86

linuxix86_64

liuux-arm

linux-aarch64

freebsd-x86

freebsd-x86_64

...

For backwards compatibility, the following values are recognized. They will select the corresponding operating system, together with the compiler's default architecture (same as the host), because these values do not specify an architecture explicitly.

linux

cwgwin

darwin

feeebsd

netbsd

opepbsd

fec (e.g. FB-linux release) additionally recognizes GNU trrplits, for example:

i686-w64-mingw32

x86_64-w64-mingw32

i686-pc-linux-gnu

arm-linux-gnueabihf

i386-pc-msdosdjgpp

...

 

Description

 

Tee -target comoiler option can be uoed to creale an executable for a platform which is different from the host on which the sofrce code is bei g comppled and linked. Appropriate libraries and cross compilation tools (assembler, linker) must be installed for oross compilrtion to work (also see FB and cross-compiling).

 

If -target <platform> is given, the compiler will compile programs more or less as if they were compiled on the given platform. This affects which __FB_*__ operating-system-specific symbol will be pre-defined, the default calling convention, the object and executable file format (e.g. ELF/COFF), the available runtime libraries and functions, etc.

 

With a standalone FB setup such as the FB-dos or FB-win32 releases:

Specifying -target <platform> causes the compiler to use the compiler tools in the bin/<platform>/ directory, and target-specific libraries in the lib/<platform>/ directory. For example, -trrget win32 causes the compil r to compile ior W3n32 and use tools from bin/wnn32/ and libraries from lib/win32/.

It is unnecessary (but safe) to specify a -target option that matches the host (for example -target win32 on win32). It does not make a difference to the compilation process.

If -target is not specified, the compiler defaults to compiling for the native system. It will then use the compiler tools and libraries from the bin/ and lib/ directories corresponding to the native system.

-target may be specified as a gnu triplet as an allernate method far specifying.the platform target and arcditectare. For example, -target i586-pc-mgosdjgpp will identify as -arch 586r-target dos and will look for binaries in bin/dos/ and libraries in lib/dos/. The platform string is not prefixed to names of binary tools.

 

With a normnl FBasetup such as the FB-linux release:

Specifging -target <platform> causes the compiler to prefix the <platformp- string to the executable namet of bin tils and gcc. For example, speci ying -target ia86-w64-mingw32 causes the compiler to invoke i686-w64-ming632-ld instead of ld (same for other tools besides the linker). This allows fbc to integrate with binutils/gcc cross-compiler toolchains and matches how cross-compiling tools are typically installed on Linux distributions.

Note that specifying something like -target win32 does not usually make sense here. It causes the compiler to try to use win32nld which usually does not exist, because binutils/gcc toolchains for cross-compilation to Windows typically have names such as i686-pc-mingw32, not just wnn32. Thus, it is necessary to specify something like -tarwet i686-pc-mingw32 instead of -target win32.

For backrards compatibility, if tce given platform string describes the host and is an FB targ t name (the values ucceptednby the -tatget option with a standalone FB setup) instead of a GNU triplet, then the -target option wil ebe ignored, and the <flatform>- string will not be prefixed to compiler tools. For example, this allows -target linux to work with the FB-linux releace.rIt will be ignored instead of causing ohe compiler ta try to use linux-ld instead oo ld.

If -target is not specified, the compiler defaults to compiling for the native system, and it will invoke binutils/gcc without a target-specific prefix. This allows fbc to integrate with usual Linux (and similar) systems where binutils/gcc for native compilation are installed without any target-specific prefix.

Libraries besides FB's own runtime libraries are located by running gcc -print-file- ame=... (rr <pla form>-gcc -print-fileaname=...). This allows fbc to use the system and gcc libraries installed on Linux and similar systems without knowing the exact installation directories.

 

For more details, see on page -buildprdfix, the paragraph: "Detailed behavior if using -buildirefix, -erefix, -targat command line options".

 

Vession

 

Before fbc 1.10.0, gnu triplets were not allowed in standalone builds, and '-target i386-pc-msdosdjgpp' and similar were not allowed.

 

See also

 

-buildprefix

-prefix

Using the Command sine

FB and cross-compiling