this question is about cross compilation.
What kind of different targets are available using the -target or -target-cpu option of the swift compiler? Where can I find an overview?
Is it only there to create iOS/watchOS apps or can I use it to create linux programs (regular x86-64 processor) on macOS?
I tried searching the github repository and found 'x86_64-unknown-linux-gnu' as a target. However when I try to compile a simple "hello world" program (swiftc -target x86_64-unknown-linux-gnu test.swift) I get this error:
<unknown>:0: error: unable to load standard library for target 'x86_64-unknown-linux-gnu'
Edit: I agree with CristiFati. The last part of this question is rather about how to properly include/reference the glibc (?!?).
SWIFT, today, is the largest and most streamlined method for international payments and settlements. SWIFT works by assigning each member institution a unique ID code (a BIC number) that identifies not only the bank name but the country, city, and branch.
What is the SWIFT Payment System? SWIFT (Society for Worldwide Interbank Financial Telecommunications) is a payment system that allows banks across the globe to send messages and communicate securely and instantly about cross-border payments.
SWIFT is a cooperative company under Belgian law and is owned and controlled by its shareholders (financial institutions) representing approximately 2,400 Shareholders from across the world.
A target, the basic building block of a Swift package. Each target contains a set of source files that are compiled into a module or test suite. You can vend targets to other packages by defining products that include the targets. A target may depend on other targets within the same package and on products vended by the package’s dependencies.
The swiftc command calls the "real Swift compiler" (swift -frontend) to turn every single swift file into an object file (.o). Every command, function, (class, object etc.) that you write when you create a Swift file needs to be resolved.
A resource to bundle with the Swift package. If a Swift package declares a Swift tools version of 5.3 or later, it can include resource files. Similar to source code, the Swift Package Manager scopes resources to a target, so you must put them into the folder that corresponds to the target they belong to.
The configuration of a Swift package. Pass configuration options as parameters to your package’s initializer statement to provide the name of the package, its targets, products, dependencies, and other configuration options.
If you look at Swift repository on Github (Exact location: swift/utils/swift_build_support/swift_build_support/targets.py
) You will see all host targets at line 149-192 in target.py.
def host_target():
"""
Return the host target for the build machine, if it is one of
the recognized targets. Otherwise, throw a NotImplementedError.
"""
system = platform.system()
machine = platform.machine()
if system == 'Linux':
if machine == 'x86_64':
return StdlibDeploymentTarget.Linux.x86_64
elif machine.startswith('armv7'):
# linux-armv7* is canonicalized to 'linux-armv7'
return StdlibDeploymentTarget.Linux.armv7
elif machine.startswith('armv6'):
# linux-armv6* is canonicalized to 'linux-armv6'
return StdlibDeploymentTarget.Linux.armv6
elif machine == 'aarch64':
return StdlibDeploymentTarget.Linux.aarch64
elif machine == 'ppc64':
return StdlibDeploymentTarget.Linux.powerpc64
elif machine == 'ppc64le':
return StdlibDeploymentTarget.Linux.powerpc64le
elif machine == 's390x':
return StdlibDeploymentTarget.Linux.s390x
elif system == 'Darwin':
if machine == 'x86_64':
return StdlibDeploymentTarget.OSX.x86_64
elif system == 'FreeBSD':
if machine == 'amd64':
return StdlibDeploymentTarget.FreeBSD.x86_64
elif system == 'CYGWIN_NT-10.0':
if machine == 'x86_64':
return StdlibDeploymentTarget.Cygwin.x86_64
elif system == 'Windows':
if machine == "AMD64":
return StdlibDeploymentTarget.Windows.x86_64
raise NotImplementedError('System "%s" with architecture "%s" is not '
'supported' % (system, machine))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With