这个问题是关于交叉编译的。
使用swift编译器的 -target 或 -target-cpu 选项可以使用哪种不同的目标? 我在哪里可以找到概述?
仅在那里创建iOS / watchOS应用程序,还是可以用它在macOS上创建linux程序(常规x86-64处理器)?
我尝试搜索github存储库并找到' x86_64-unknown-linux-gnu' 作为目标。但是,当我尝试编写一个简单的#34; hello world"程序(swiftc -target x86_64-unknown-linux-gnu test.swift)我收到此错误:
<unknown>:0: error: unable to load standard library for target 'x86_64-unknown-linux-gnu'
修改 我同意CristiFati。这个问题的最后一部分是关于如何正确地包含/引用glibc(?!?)。
答案 0 :(得分:10)
如果您查看Swift repository on Github(确切位置:swift/utils/swift_build_support/swift_build_support/targets.py
),您会在line 149-192的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))