-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Run libtool without symlinking if possible #11958
Conversation
@trybka could you take a look? Thanks! |
@trybka is there a way that libtool is currently tested? i didn't see any test rules in that dir |
@keith @kastiglione @trybka responded, curious about toolchain setup as per keith's comment and test practices |
re: testing I think your best bet would be to check out the rules_apple repo and run their integration tests: They are quite robust, and would likely identify any issues in both toolchain setup / libtool usage. re: toolchain setup I suspect you will have to do something like we do for wrapped_clang.cc (see the link @keith mentioned). |
@keith that line is added now for the crosstool. how can libtool.sh get the path to the executable for the c++? (currently it just uses dirname of the script itself and appends the executable name for testing purposes) |
If something like that works that is ok, other scripts rely on something similar |
it does not work afaict :P it just helped me test, but if there's no standard way to do this i can dig a bit |
@keith it seems like it would work if it was a script, like the python script, but not since it's c++. i see the wrapped_clang test uses |
got it now, seems to work. @trybka i tried the rules_apple tests, but i get 52 of 289 tests failed on master as well as with this pr. they fail with |
@allevato have you seen that failure-mode before? |
The only other instance I can find of it is here, but it's not clear what resolved it: bazelbuild/tulsi#106 If they fail on master as well as this PR, then there might be an unrelated problem on the Buildkite CI; @philwo may be able to assist or pull in someone who can. |
OK, all the tests are passing for me locally, I'll patch your commit in and try to test it as well. |
Awesome, thank you! I'll make an issue for this local test issue |
err... once I figure out how to patch your changes in. >_> I think this is a problem for tomorrow @trybka |
tools/objc/libtool_check_unique.cc
Outdated
int main(int argc, const char * argv[]) { | ||
unordered_set<string> basenames; | ||
const regex libRegex = regex(".*\\.a$"); | ||
const regex noArgFlags = regex("-static|-s|-a|-c|-L|-T|-no_warning_for_no_symbols"); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Glad you got the tests running!
tools/cpp/osx_cc_configure.bzl
Outdated
paths["@bazel_tools//tools/objc:libtool_check_unique.cc"], | ||
)) | ||
xcrun_result = repository_ctx.execute([ | ||
"env", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull these into a common copts list or something so they can be shared with wrapped_clang?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@trybka updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any benchmarks or data on the speed improvement for some of your projects?
tools/objc/libtool.sh
Outdated
# Ensure 0 timestamping for hermetic results. | ||
export ZERO_AR_DATE=1 | ||
|
||
if $(/usr/bin/dirname "$0")/libtool_check_unique "$@"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this before--is it possible to refer to this relative to $MY_LOCATION?
Given that this script may be invoked in multiple contexts (according to the logic above), it might be prudent to refer to this in a canonical way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
for a 700-file swift_library target, libtool_check_unique takes about 1ms. the overall time seems to be about the same between calling /usr/bin/libtool directly and doing this |
@trybka responded |
Cool. How much slower was it before? (with the always hash-symlinking?) |
Nevermind, it's in the linked issue. |
OK, just some minutiae: and could you add the license boilerplate to the .cc file? I couldn't find a pointer to it in the docs, but our presubmit nags about it.
FWIW, we filed bazelbuild/bazel-website#267 to address the doc issue about this requirement. |
@trybka updated with the boilerplate. And I signed the CLA earlier, does that apply here? bazelbuild/rules_swift#439 (comment) |
Yeah, I think that should be good. Re-running the import script now. |
If there are no duplicate .o basenames, then libtool can be invoked directly without symlinking. From bazelbuild#11846 Closes bazelbuild#11958. PiperOrigin-RevId: 328185225
If there are no duplicate .o basenames, then libtool can be invoked directly without symlinking. From bazelbuild#11846 Closes bazelbuild#11958. PiperOrigin-RevId: 328185225
…ctor With the bazel version update from 3.1.0 to 3.7.2, the object file hash values are no longer added when their names are unique within an objc_library. See: * bazelbuild/bazel#11846 * bazelbuild/bazel#11958 However, object name collision can still happen when there is a source code with the same basename in a transitive dependency tree. Normally there is no problem with this, but this had an unfortunate interaction with the symbol hiding script we use for building the iOS static framework. That is, when an archive file (.a) contains more than one object file with the same name, the 'ar -x' command executed as part of the symbol hiding script would overwrite the conflicting object file, causing the overwritten object file to be not included in the final static framework. This was causing a link error at CocoaPods lint step, as it had some missing function definitions. This is now fixed by using a custom extraction script written in Python, which gracefully handles the object file name collision. This also fixes a previously existed race condition when the symbol hiding script is run in parallel for multiple static framework targets, by using separate temporary directories while extracting the object files. Verified that this fix works with CocoaPods lint. PiperOrigin-RevId: 351118550 Change-Id: Iec26e4720c21f271822785032d5fb6f4717eebca
If there are no duplicate .o basenames, then libtool can be invoked directly without symlinking. From #11846