Skip to content
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

Adapt rules_foreign_cc for working with libtool instead of ar. #315

Merged

Conversation

irengrig
Copy link
Contributor

@irengrig irengrig commented Sep 9, 2019

  • for CMake, pass "" as the output file when forming linker flags with cc_common. CMake will later replace with the actual output file. Fill CMAKE_C_CREATE_ARCHIVE and CMAKE_CXX_CREATE_ARCHIVE CMake variables with 'CMAKE_AR %Bazel-link-flags% ' call, where CMAKE_AR will take the path to libtool.
    Related documentation: https://cmake.org/cmake/help/v3.15/variable/CMAKE_LANG_ARCHIVE_CREATE.html?highlight=cmake_%20lang%20_archive_create

  • for configure_make, for the libevent example, we need to skip specifying the libtool from Bazel's toolchain as a linker, because libevent script uses it's own libtool and manages to pass the output file to it, but not to the libtool we are passing. Let it do so as it is a customized script.
    Do it with specifying empty string for the $AR environment variable.
    Other examples with configure_make work fine.

This fixes bazelbuild/bazel#9258

- for CMake, pass "<TARGET>" as the output file when forming linker flags with cc_common. CMake will later replace <TARGET> with the actual output file. Fill CMAKE_C_CREATE_ARCHIVE and CMAKE_CXX_CREATE_ARCHIVE CMake variables with 'CMAKE_AR %Bazel-link-flags% <OBJECTS>' call, where CMAKE_AR will take the path to libtool.
Related documentation: https://cmake.org/cmake/help/v3.15/variable/CMAKE_LANG_ARCHIVE_CREATE.html?highlight=cmake_%20lang%20_archive_create

- for configure_make, for the libevent example, we need to skip specifying the libtool from Bazel's toolchain as a linker, because libevent script uses it's own libtool and manages to pass the output file to it, but not to the libtool we are passing. Let it do so as it is a customized script.
Do it with specifying empty string for the $AR environment variable.
Other examples with configure_make work fine.

This fixes bazelbuild/bazel#9258
@irengrig irengrig requested review from jin and hlopko September 9, 2019 12:04
@irengrig
Copy link
Contributor Author

irengrig commented Sep 9, 2019

Hi guys, happy to find the solution for that, thank you Marcel for very good idea!
Please consider reviewing it today, as it is on Bazel 1.0 hotlist.

Thank you!!

@irengrig
Copy link
Contributor Author

irengrig commented Sep 9, 2019

Just added the commit to use the default Bazel version with the CI.
However, previous CI run demonstrated that rules_foreign_cc works with the Bazel 1.0 rc2.

Copy link
Contributor

@hlopko hlopko left a comment

Choose a reason for hiding this comment

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

Thanks! :)

@irengrig
Copy link
Contributor Author

irengrig commented Sep 9, 2019

Thank you for the review!
Submitting, as Jin is on vacation.

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.

rules_foreign_cc broken in downstream
3 participants