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

ARROW-9698: [C++] Remove -DNDEBUG flag leak in .pc file #7939

Closed
wants to merge 1 commit into from
Closed

ARROW-9698: [C++] Remove -DNDEBUG flag leak in .pc file #7939

wants to merge 1 commit into from

Conversation

bdunlay
Copy link

@bdunlay bdunlay commented Aug 12, 2020

This change eliminates the need to include the -DNDEBUG flag in arrow's .pc file, which leaks into downstream projects' builds unexpectedly. The CheckSize function definition is now included in both debug and release builds, though it will no-op in release builds (as expected). The flag is no longer required as a means to make the ABI consistent across build types for downstream projects, and so it is now removed.

@github-actions
Copy link

@pitrou
Copy link
Member

pitrou commented Aug 12, 2020

I disagree with these changes. There no is reason to rename NDEBUG to another symbol. We should simply ensure that the ABI is the same with and without NDEBUG.

@pitrou
Copy link
Member

pitrou commented Aug 12, 2020

It looks like the only place that would need fixing is in arrow/util/trie.h.

@pitrou
Copy link
Member

pitrou commented Aug 12, 2020

(also, you forgot to change the .pc file itself...)

@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

(also, you forgot to change the .pc file itself...)

Whoops, must have gotten lost when I revised my commit. Had it in the original.

@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

Actually, given the approach here, it wouldn't need to change -- my change would set a different flag rather than NDEBUG.

In any case, this change was one approach suggested in the jira issue, but I am happy to change it.

From the code you pointed out, the NDEBUG check could simply be removed (not sure why it is necessary, if NDEBUG would also disable the assert anyway?). Or, it could be moved inside of the function definition and break/do nothing.

Thoughts or preferences?

@pitrou
Copy link
Member

pitrou commented Aug 12, 2020

I don't know why @kou suggested the flag change. If I look at headers in /usr/include on Ubuntu 18.04, several of them use NDEBUG in places: it doesn't seem to be causing any issues in practice.

As for arrow/util/trie.h, the method should simply always be defined even if not used (though I'm not even sure that matters, since it's an inline method...).

@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

@pitrou Why are the asserts wrapped in NDEBUG? Isn't that redundant?

@pitrou
Copy link
Member

pitrou commented Aug 12, 2020

@bdunlay Where exactly? Do you have an example?

@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

For example the lines you pointed out to me: src/arrow/util/trie.h

If this is a debug build, the function is included in the header, and the assert is evaluated. If it's a release build, the function is omitted, and the assert is obviously never evaluated. But if you removed the macro completely, in a release build, the function exist but would no-op (assert disabled).

@pitrou
Copy link
Member

pitrou commented Aug 12, 2020

Ah, yes, you are right, in those cases the #ifdef is pointless.

This change eliminates the need to include the -DNDEBUG flag in arrow's
.pc file, which leaks into downstream projects' builds unexpectedly. The
CheckSize function definition is now included in both debug and release
builds, though it will no-op in release builds (as expected). The flag
is no longer required as a means to make the ABI consistent across
build types for downstream projects, and so it is now removed.
@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

Think the linter is mad at me for an extra newline in the cmake file. Will remove that w/ an update once CI completes.

@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

I will push a new change with that newline removed, but the linter is going to complain anyway because there are lots of linting issues that are not compliant with the linter in that cmake file that existed prior to my change.

@pitrou
Copy link
Member

pitrou commented Aug 12, 2020

If you installed archery, you can run archery lint --cmake-format. Otherwise we can do it for you.

@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

I'll submit this for review as is if that's okay with you.

@bdunlay
Copy link
Author

bdunlay commented Aug 12, 2020

Hey look at that, it's happy now 😄

@kou
Copy link
Member

kou commented Aug 12, 2020

I suggested the renaming approach because using release build libarrow.so without NDEBUG increases needless (empty) CheckXXX() function calls.
If it's acceptable, just removing NDEBUG is OK to me.

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

+1, thank you @bdunlay

@pitrou
Copy link
Member

pitrou commented Aug 13, 2020

@github-actions crossbow submit -g linux

@pitrou pitrou closed this in 69d7b2b Aug 13, 2020
GeorgeAp pushed a commit to sirensolutions/arrow that referenced this pull request Jun 7, 2021
This change eliminates the need to include the -DNDEBUG flag in arrow's .pc file, which leaks into downstream projects' builds unexpectedly. The CheckSize function definition is now included in both debug and release builds, though it will no-op in release builds (as expected). The flag is no longer required as a means to make the ABI consistent across build types for downstream projects, and so it is now removed.

Closes apache#7939 from bdunlay/master

Authored-by: Brian Dunlay <dunlaybd@amazon.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
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.

None yet

3 participants