Skip to content

Build both shared and static libraries when ENABLE_SWIFT is ON #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

kevints
Copy link

@kevints kevints commented Oct 1, 2018

@weissi weissi requested a review from compnerd October 1, 2018 15:51
@weissi
Copy link
Contributor

weissi commented Oct 1, 2018

this is great! CC'ing @tkremenek and @das as the Swift overall and Dispatch release managers for 4.2. I'd like to get this into 4.2.1 because it's clearly a regression from 4.1 that should be fixed ASAP.

@ktopley-apple
Copy link
Contributor

@swift-ci please test

@kevints
Copy link
Author

kevints commented Oct 1, 2018

The sourcekitd compilation error is fixed with the change proposed here: swiftlang/swift#19640

@ktopley-apple
Copy link
Contributor

ktopley-apple commented Oct 1, 2018 via email

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not introduce a top-level CMakeLists.txt that just builds it in two configuration? That seems way nicer than wrapping each bit. Furthermore, with the WIndows build target, this needs two effectively do exactly that anyways.

@@ -72,6 +72,7 @@ if(ENABLE_SWIFT)
${SWIFT_RUNTIME_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX})

set(INSTALL_TARGET_DIR "${INSTALL_LIBDIR}/swift/${SWIFT_OS}" CACHE PATH "Path where the libraries will be installed")
set(INSTALL_STATIC_TARGET_DIR "${INSTALL_LIBDIR}/swift_static/${SWIFT_OS}" CACHE PATH "Path where the static libraries will be installed")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not sure I understand the point of these two cached variables. They are part of the resource dir naming scheme for the compiler, so why not always compose them when used?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to drop them

set(dispatch_targets dispatch dispatch_static dispatch_objects)
else()
set(dispatch_targets dispatch)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2-space indents please

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this up in my next patch

LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/swift/${SWIFT_OS}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/swift/${SWIFT_OS}
)
add_library(dispatch_static STATIC $<TARGET_OBJECTS:dispatch_objects>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks for windows. Please do a combined build for Windows. We need to build the objects twice, using the same objects will not work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a Windows machine to test on, can you elaborate on this? Are object libraries just broken in general? On Linux I could instead create a static library (with -fPIC) and then create a .so out of it with ld --whole-archive but that's not portable. Is there any way I can avoid building the objects twice on platforms where that's not required?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, object libraries are fine, just as long as they are built for the final type (e.g. built with knowledge that they will be used for a shared library or not). The best way to accomplish this is to perform two builds with the right CMake flags so that you build the objects the right way.

@compnerd
Copy link
Member

compnerd commented Oct 3, 2018

#395 actually will unconditionally build the shared and static versions of BlocksRuntime now. That should be sufficient for your needs right?

@kevints
Copy link
Author

kevints commented Oct 3, 2018

Closing in favor of a new approach where swift's build-script creates 2 libdispatch build directories, one for shared and one for static after talking this approach through with @compnerd and @gottesmm offline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants