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?

agoldis
  • 1,067
  • 16
  • 28
  • Take a look at definition of `add_swift_library`, maybe it would give you some clues. – arrowd May 31 '16 at 09:52
  • `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? – Tsyvarev May 31 '16 at 10:15
  • @arrowd good idea, i was lost in the function however - it's huge! `./cmake/modules/AddSwift.cmake` – agoldis May 31 '16 at 11:33
  • @Tsyvarev it isn't created when compiling on linux – agoldis May 31 '16 at 11:33

1 Answers1

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.

fedepad
  • 4,509
  • 1
  • 13
  • 27