Skip to content

Temporarily workaround CMake dependencies bug #1081

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

Merged
merged 1 commit into from
Nov 17, 2022

Conversation

bnbarham
Copy link
Contributor

Workaround a CMake bug in order to make sure that libraries are rebuilt when their dependencies change.

@bnbarham
Copy link
Contributor Author

swiftlang/swift#62129

@swift-ci please test

Copy link
Member

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

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

It's terrible, but I think it works. A few style comments.
Also, can you add reference to rdar://102202478 in a comment? Thanks.

CC @compnerd any thoughts/feedback?

# part of A. Ideally this file would be generated by each of the targets, but that dependency didn't
# seem to be being tracked.
function(add_forced_dependencies TARGET)
cmake_parse_arguments(ARGS "" "" "PUBLIC" ${ARGN})
Copy link
Member

Choose a reason for hiding this comment

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

The naming here feels a bit weird. I'm not getting that it's linking from the function name, and the PUBLIC seems to come out of nowhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I totally agree about the PUBLIC, but I was basically just aiming at making it a 1:1 replacement for target_link_libraries (at least for the case we use it). I don't really mind either way. Do you have a strong opinion here?

How about I rename it to force_target_link_libraries?

Copy link
Member

Choose a reason for hiding this comment

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

I actually think that this change is far too invasive for what it intends to do. I think that we should be more clever about this workaround. Please rename this function target_link_librares. We can subsequently, at the end of the function passthrough to the underlying implementation of target_link_libraries.

Something like this should do the trick:

function(target_link_libraries target)
  cmake_parse_arguments(TLL_ARGS "" "" "PUBLIC" ${ARGN})

  foreach(dependency ${TLL_PUBLIC})
    ...
  endforeach()

  _target_link_libraries(${target} PUBLIC ${TLL_PUBLIC} ${TLL_ARGN})
endfunction()

This way, in the future, the revert of this will just drop this one function and everything goes back to normal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had no idea you could do that. I've updated the PR to do this instead, but I'll leave the Swift PR as is - once the function is redefined, it's redefined from that point on (not scoped to a subdirectory). This is fine for swift-syntax, but not for the swift-side change (and that only touches the one file anyway). Thanks for the suggestion @compnerd!

@bnbarham
Copy link
Contributor Author

swiftlang/swift#62129

@swift-ci please test

Copy link
Member

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

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

Yeah, I think the new changes are fine given that the goal is to delete the function.

# part of A. Ideally this file would be generated by each of the targets, but that dependency didn't
# seem to be being tracked.
function(add_forced_dependencies TARGET)
cmake_parse_arguments(ARGS "" "" "PUBLIC" ${ARGN})
Copy link
Member

Choose a reason for hiding this comment

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

I actually think that this change is far too invasive for what it intends to do. I think that we should be more clever about this workaround. Please rename this function target_link_librares. We can subsequently, at the end of the function passthrough to the underlying implementation of target_link_libraries.

Something like this should do the trick:

function(target_link_libraries target)
  cmake_parse_arguments(TLL_ARGS "" "" "PUBLIC" ${ARGN})

  foreach(dependency ${TLL_PUBLIC})
    ...
  endforeach()

  _target_link_libraries(${target} PUBLIC ${TLL_PUBLIC} ${TLL_ARGN})
endfunction()

This way, in the future, the revert of this will just drop this one function and everything goes back to normal.

Workaround a CMake bug in order to make sure that libraries are rebuilt
when their dependencies change.
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham merged commit 0e85cf7 into swiftlang:main Nov 17, 2022
@bnbarham bnbarham deleted the fix-dependencies branch November 17, 2022 22:24
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