Skip to content

build: give BlocksRuntime hidden visibility #394

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

compnerd
Copy link
Member

@compnerd compnerd commented Oct 2, 2018

Since BlocksRuntime is currently built statically, we should ensure that it does
not leak symbols into the target library or executable it is being linked into.
This will require consumers to explicitly link against the BlocksRuntime.

Since BlocksRuntime is currently built statically, we should ensure that it does
not leak symbols into the target library or executable it is being linked into.
This will require consumers to explicitly link against the BlocksRuntime.
@compnerd
Copy link
Member Author

compnerd commented Oct 2, 2018

CC: @kevints @MadCoder

@MadCoder
Copy link
Contributor

MadCoder commented Oct 2, 2018

I don't think this works, there are symbols that need to be unique for all users of the blocks runtime, and if Swift has such a runtime and dispatch, they must agree on the isa's of blocks.

I don't feel I'm competent review this, you need Swift runtime people to look into that.

@kevints
Copy link

kevints commented Oct 2, 2018

This seems like the wrong approach - Block_retain and Block_release are globals, and the Block_retain and Block_release that your program see need to be the same ones that libdispatch see.

Please see my comments in
swiftlang/swift#19640 (comment)
and
swiftlang/swift#19640 (comment) for a detailed explanation of why.

@@ -142,7 +142,9 @@ if(NOT BlocksRuntime_FOUND)
${PROJECT_SOURCE_DIR}/src/BlocksRuntime/runtime.c)
set_target_properties(BlocksRuntime
PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)
POSITION_INDEPENDENT_CODE TRUE
C_VISIBILITY_PRESET HIDDEN
Copy link

Choose a reason for hiding this comment

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

This won't work as it only sets the default visibility (-fvisibility=hidden), source files can still override it with __attribute__(visibility("default")) (which the BLOCK_EXPORT macro defines).

In fact this is already set on line 20: 1eee0f9#diff-af3b638bc2a3e6c650974192a53c7291R20

Since your ultimate goal is one BlocksRuntime per program, have you considered removing STATIC from the add_library(BlocksRuntime) command above? I think that would result in a BlocksRuntime that respects BUILD_SHARED_LIBS. You should also make sure to install it, e.g.

install(TARGETS BlocksRuntime DESTINATION "${INSTALL_TARGET_LIBDIR}")

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, there is already a PR for that (and this was meant as a stop gap until we get that merged. Since we discussed that we are going to actively pursue that first, this is no longer relevant.

@compnerd compnerd closed this Oct 3, 2018
@compnerd compnerd deleted the hidden-blocks branch October 3, 2018 17:12
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.

3 participants