gpt4 book ai didi

swift - swiftc -target 和 -target-cpu 选项可以使用哪些目标?

转载 作者:IT王子 更新时间:2023-10-29 05:14:34 46 4
gpt4 key购买 nike

这个问题是关于交叉编译的。

使用 swift 编译器的 -target-target-cpu 选项可以使用哪些不同的目标?我在哪里可以找到概述?

它只能用于创建 iOS/watchOS 应用程序,还是我可以使用它在 macOS 上创建 linux 程序(常规 x86-64 处理器)?

我尝试搜索 github 存储库,发现 'x86_64-unknown-linux-gnu' 作为目标。然而,当我尝试编译一个简单的“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'

编辑:我同意克里斯蒂法蒂的观点。这个问题的最后一部分是关于如何正确包含/引用 glibc (?!?)。

最佳答案

如果你看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))

关于swift - swiftc -target 和 -target-cpu 选项可以使用哪些目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43007424/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com