-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
tools: fix c++ code coverage on macOS #24004
Conversation
Recent libtool on macOS does not support the --coverage flag that was being passed through in the final linking stage. This change patches gyp-mac-tool to not pass the --coverage flag through to libtool. It is now possible to generate code coverage for src/ on macOS. Fixes: nodejs#19057
Can we not remove Lines 272 to 291 in c515e5c
|
@richardlau that broke coverage when I tried it |
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.
LGTM
@@ -949,6 +949,8 @@ def GetLibtoolflags(self, configname): | |||
libtoolflags = [] | |||
|
|||
for libtoolflag in self._Settings().get('OTHER_LDFLAGS', []): | |||
if libtoolflag == "--coverage": |
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.
NM
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.
Ok after some digging is seem like the native libtool
does not accept any flag that starts with --
Can I suggest this instead of the whole for expression (From L948 to L955)
self.configname = configname
libtoolflags = self._Settings().get('OTHER_LDFLAGS', [])
# Native macOS libtool does not except any flags with '--' prefix
libtoolflags = [f for f in libtoolflags if not f.startswith('--')]
# TODO(thakis): ARCHS?
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.
IMHO there should be a more direct way.
Hello @evanlucas I'm going to look into solving this by a more direct means. If I can't I'll dismiss my review. /CC @nodejs/python @nodejs/gyp |
@@ -949,6 +949,8 @@ def GetLibtoolflags(self, configname): | |||
libtoolflags = [] | |||
|
|||
for libtoolflag in self._Settings().get('OTHER_LDFLAGS', []): | |||
if libtoolflag == "--coverage": |
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.
Ok after some digging is seem like the native libtool
does not accept any flag that starts with --
Can I suggest this instead of the whole for expression (From L948 to L955)
self.configname = configname
libtoolflags = self._Settings().get('OTHER_LDFLAGS', [])
# Native macOS libtool does not except any flags with '--' prefix
libtoolflags = [f for f in libtoolflags if not f.startswith('--')]
# TODO(thakis): ARCHS?
I've tested my suggestion and it generate the same make scaffolding as the current PR. And allows building |
I've been thinking about this some more, and I think the settings in Lines 272 to 291 in c515e5c
are wrong. They should only be applied to the binary target, not to the libnode.lib indermidiary. I'll work on that tomorrow...
|
Thanks. I added your change and tried running
I'm on Mojave 0.14. I even tried cleaning up coverage and run several times, but ended up in the same issue above. Anything I'm missing? |
@antsmartian Do you mean @refack's change or @cjihrig's changes in this PR or something else? |
@Trott I have added the changes from this PR:
|
I assume this was supposed to be @evanlucas, but please let me know if I missed something. |
@antsmartian Maybe check what version of |
@nodejs/platform-macos @evanlucas @refack Any chance someone can get this unstuck? Seems like it's close.... |
Alternative PR: #24520 |
Since #24520 landed, I assume this can be closed. But if I'm wrong about that, please re-open! |
Recent libtool on macOS does not support the --coverage flag that was
being passed through in the final linking stage.
This change patches gyp-mac-tool to not pass the --coverage flag through
to libtool. It is now possible to generate code coverage for src/ on macOS.
Fixes: #19057
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes