gpt4 book ai didi

swift - 为 Swift 添加对 32 位 Ubuntu 的支持

转载 作者:行者123 更新时间:2023-11-28 06:08:27 26 4
gpt4 key购买 nike

我正在尝试在 32 位 Ubuntu 虚拟机上从源代码构建 Swift。

我做了以下修改,主要是在构建脚本中:(参见 https://pastebin.com/rmWecTu7)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 112b5d6..16db3ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -538,12 +538,16 @@
endif()
endif()

+message(STATUS ">>> CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
+
# If SWIFT_HOST_VARIANT_ARCH not given, try to detect from the CMAKE_SYSTEM_PROCESSOR.
if(SWIFT_HOST_VARIANT_ARCH)
set(SWIFT_HOST_VARIANT_ARCH_default, "${SWIFT_HOST_VARIANT_ARCH}")
else()
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set(SWIFT_HOST_VARIANT_ARCH_default "x86_64")
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
+ set(SWIFT_HOST_VARIANT_ARCH_default "i686")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
set(SWIFT_HOST_VARIANT_ARCH_default "aarch64")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
@@ -613,10 +617,14 @@
set(SWIFT_HOST_VARIANT "linux" CACHE STRING
"Deployment OS for Swift host tools (the compiler) [linux].")

+ message(STATUS ">>> SWIFT_HOST_VARIANT_ARCH: " ${SWIFT_HOST_VARIANT_ARCH})
+
# Calculate the host triple
if("${SWIFT_HOST_TRIPLE}" STREQUAL "")
if("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "x86_64")
set(SWIFT_HOST_TRIPLE "x86_64-unknown-linux-gnu")
+ elseif("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "i686")
+ set(SWIFT_HOST_TRIPLE "i686-unknown-linux-gnu")
elseif("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "aarch64")
set(SWIFT_HOST_TRIPLE "aarch64-unknown-linux-gnu")
elseif("${SWIFT_HOST_VARIANT_ARCH}" MATCHES "(powerpc64|powerpc64le)")
diff --git a/stdlib/public/SwiftShims/LibcShims.h b/stdlib/public/SwiftShims/LibcShims.h
index e726a62..5fd7826 100644
--- a/stdlib/public/SwiftShims/LibcShims.h
+++ b/stdlib/public/SwiftShims/LibcShims.h
@@ -33,7 +33,9 @@

// This declaration is not universally correct. We verify its correctness for
// the current platform in the runtime code.
-#if defined(__linux__) && defined (__arm__)
+#if defined(__linux__) && defined(__arm__)
+typedef int __swift_ssize_t;
+#elif defined(__linux__) && defined(__i386__)
typedef int __swift_ssize_t;
#elif defined(_WIN32)
#if defined(_M_ARM) || defined(_M_IX86)
diff --git a/utils/build-script-impl b/utils/build-script-impl
index 1bfbcc5..b058b22 100755
--- a/utils/build-script-impl
+++ b/utils/build-script-impl
@@ -449,6 +449,9 @@
--$(tolower "${PLAYGROUNDLOGGER_BUILD_TYPE}")
)
;;
+ linux-i686)
+ SWIFT_HOST_VARIANT_ARCH="i686"
+ ;;
linux-armv6)
SWIFT_HOST_VARIANT_ARCH="armv6"
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py
index f4b5bb0..690a3d3 100644
--- a/utils/swift_build_support/swift_build_support/targets.py
+++ b/utils/swift_build_support/swift_build_support/targets.py
@@ -112,6 +112,7 @@
is_simulator=True)

Linux = Platform("linux", archs=[
+ "i686",
"x86_64",
"armv6",
"armv7",
@@ -174,6 +175,8 @@
return StdlibDeploymentTarget.Linux.powerpc64le
elif machine == 's390x':
return StdlibDeploymentTarget.Linux.s390x
+ elif machine == 'i686':
+ return StdlibDeploymentTarget.Linux.i686

elif system == 'Darwin':
if machine == 'x86_64':

尝试构建 stdlib 时构建失败,给出一些与 Float80 相关的错误:(参见 https://pastebin.com/ue8MRquU)

swift: /home/gigi/local/Source/apple/swift/lib/IRGen/StructLayout.cpp:357: void swift::irgen::StructLayoutBuilder::setAsBodyOfStruct(llvm::StructType *) const: Assertion `(!isFixedLayout() || IGM.DataLayout.getStructLayout(type)->getSizeInBytes() == CurSize.getValue()) && "LLVM size of fixed struct type does not match StructLayout size"' failed.
/home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/bin/swift[0xc335ea0]
Stack dump:
0. Program arguments: /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/bin/swift -frontend -c -filelist /tmp/sources-628097 -disable-objc-attr-requires-foundation-module -target i686-unknown-linux-gnu -disable-objc-interop -sdk / -I /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/./lib/swift/linux/i686 -warn-swift3-objc-inference-complete -module-cache-path /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/./module-cache -module-link-name swiftCore -nostdimport -parse-stdlib -resource-dir /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/./lib/swift -swift-version 3 -O -D INTERNAL_CHECKS_ENABLED -group-info-path /home/gigi/local/Source/apple/swift/stdlib/public/core/GroupInfo.json -enable-sil-ownership -Xllvm -sil-inline-generics -Xllvm -sil-partial-specialization -Xcc -D__SWIFT_CURRENT_DYLIB=swiftCore -parse-as-library -module-name Swift -o /home/gigi/local/Source/apple/build/Ninja-ReleaseAssert/swift-linux-i686/stdlib/public/core/linux/i686/Swift.o
1. While running pass #147 SILFunctionTransform "SIL alloc_stack Hoisting" on SILFunction "@_T0s7Float80V15_representationAB01_A14RepresentationVvg".
for getter for _representation at /home/gigi/local/Source/apple/swift/stdlib/public/core/FloatingPointTypes.swift.gyb:342:16
2. While converting type 'Float80' (declared at [/home/gigi/local/Source/apple/swift/stdlib/public/core/FloatingPointTypes.swift.gyb:74:8 - line:3662:1] RangeText="struct Float80 {
public // @testable
var _value: Builtin.FPIEEE80

/// Creates a value initialized to zero.
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public init() {
let zero: Int64 = 0
self._value = Builtin.sitofp_Int64_FPIEEE80(zero._value)
}

@_inlineable // FIXME(sil-serialize-all)
@_transparent
public // @testable
init(_bits v: Builtin.FPIEEE80) {
self._value = v
}
}")
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
ninja: build stopped: subcommand failed.
/home/gigi/local/Source/apple/swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
gigi@gigi-VirtualBox:~$ ]

使用 ~/local/Source/apple/swift/utils/build-script --release 进行构建。

我猜错误与此修改有关:

#elif defined(__linux__) && defined(__i386__)
typedef int __swift_ssize_t;

最佳答案

Swift 官方项目还不支持 32 位架构。有官方票:Port Swift to Linux x86 32-bit
如果您想自己添加此端口,您将有更多机会获得此票证的支持。

关于swift - 为 Swift 添加对 32 位 Ubuntu 的支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47475927/

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