libswiftDemangle.so on Linux
Asked Answered
G

1

9

While compiling Swift on Mac machine, there is a dynamic library libswiftDemangle.dylib created. I need the dynamic library created on Linux machine as well, however, the dynamic library isn't created after a compilation of a source code.

The file CMakeLists.txt at lib/SwiftDemangle/CMakeLists.txt contains:

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

directive, however the library isn't created.

I use this command ./swift/utils/build-script -R -c --build-subdir build --install-prefix /mnt/servers/swift/install -j4 to build the project, eventually it runs cmake and ninja to build the project.

Any ideas?

Garfield answered 31/5, 2016 at 9:4 Comment(4)
Take a look at definition of add_swift_library, maybe it would give you some clues.Flatcar
however the library isn't created. - What is this mean? Output of build process doesn't show that library is built? Or you just cannot find created .dylib file?Parrisch
@Flatcar good idea, i was lost in the function however - it's huge! ./cmake/modules/AddSwift.cmakeGarfield
@Parrisch it isn't created when compiling on linuxGarfield
C
2

I can take a shot at explaining why the library is not getting built on Linux, even if it's late probably.
The main subdirectory containing the library you mention is:

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

To build the libs in that directory, which are organized in subdirectories, the following CMakeLists.txt is used:

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

As can be clearly seen in this file, the library that you mention is only built if the system is OSX/Darwin and not in the Linux case. The relevant code in the aforementioned CMakeLists.txt is:

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)  

As you can see it,

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

prevents SwiftDemangle to be built on Linux.
A superficial double check can be to look at:

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

which will install or simlynk only *.dylib files.
It it worth mentioning that the swift-demangle tool (different from what you asked)

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

is built on Linux.

Caprifig answered 7/1, 2017 at 13:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.