libswiftDemangle.so on Linux



在 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构建项目,最终它会cmake运行并ninja构建项目。

有什么想法吗?

我可以尝试解释为什么库不是在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()

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

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 之上。

最新更新