9

在 Mac 机器上编译 Swift 时,会libswiftDemangle.dylib创建一个动态库。我也需要在 Linux 机器上创建的动态库,但是,动态库不是在编译源代码后创建的。

该文件包含CMakeLists.txtlib/SwiftDemangle/CMakeLists.txt

add_swift_library(swiftDemangle SHARED
  SwiftDemangle.cpp
  MangleHack.cpp
  LINK_LIBRARIES swiftBasic)

指令,但是没有创建库。

我使用这个命令./swift/utils/build-script -R -c --build-subdir build --install-prefix /mnt/servers/swift/install -j4来构建项目,最终它运行cmakeninja构建项目。

有任何想法吗?

4

1 回答 1

2

我可以解释一下为什么这个库没有在 Linux 上构建,即使可能已经很晚了。
包含您提到的库的主要子目录是:

https://github.com/apple/swift/tree/master/lib

要在该目录中构建库,这些库被组织在子目录中,使用以下CMakeLists.txt内容:

https://github.com/apple/swift/blob/master/lib/CMakeLists.txt.

从这个文件中可以清楚地看到,您提到的库仅在系统是 OSX/Darwin 而不是在 Linux 情况下构建。上述相关代码CMakeLists.txt为:

add_subdirectory(RemoteAST)
add_subdirectory(Sema)
add_subdirectory(Serialization)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  add_subdirectory(SwiftDemangle)
endif()
add_subdirectory(SIL)
add_subdirectory(SILGen)  

如你所见,

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  add_subdirectory(SwiftDemangle)
endif()

防止SwiftDemangle在 Linux 上构建。
一个肤浅的双重检查可以看:

https://github.com/apple/swift/blob/master/lib/SwiftDemangle/CMakeLists.txt

它将仅安装或 simlynk*.dylib文件。
值得一提的是该swift-demangle工具(与您要求的不同)

https://github.com/apple/swift/tree/master/tools/swift-demangle

是在 Linux 上构建的。

于 2017-01-07T13:40:30.313 回答