This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Make sure <string.h> is included with original __THROW defined.
ClosedPublic

Authored by tra on Sep 29 2021, 3:11 PM.

Details

Summary

Otherwise we may end up with an inconsistent redeclarations of the standard
library functions if _FORTIFY_SOURCE is in effect.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47869

Diff Detail

Event Timeline

tra created this revision.Sep 29 2021, 3:11 PM
tra requested review of this revision.Sep 29 2021, 3:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2021, 3:11 PM
tra added a comment.Oct 5 2021, 11:27 AM

@jdoerfert: Ping. I think you're the best match for reviewing the code related to interaction between CUDA and the system include files, even if this particular header does not have much to do with OpenMP.

I first had to read up on pop_macro -.-. Still unsure if it is OK to push it once and pop it twice, that works fine?
Can't we move the string include earlier, grouped with stdlib and cmath? then we don't need to play with THROW twice.
Other than that it seems sensible to let string have a
THROW, even though none of this mismatch is really sensible at the end of the day...

While we are here, we should be able to have a test, no? Something in string.h that depends on __THROW being present should suffice I guess.

tra updated this revision to Diff 377573.Oct 6 2021, 9:38 AM
tra edited the summary of this revision. (Show Details)

Added a missing push_macro

tra updated this revision to Diff 377587.Oct 6 2021, 10:06 AM

re-set __THROW to an empty value. It's still needed for CUDA-7.5

tra updated this revision to Diff 377593.Oct 6 2021, 10:14 AM

Moved string.h inclusion to the top of the file.

tra added a comment.Oct 6 2021, 10:24 AM

I first had to read up on pop_macro -.-. Still unsure if it is OK to push it once and pop it twice, that works fine?

Good catch.

Can't we move the string include earlier, grouped with stdlib and cmath? then we don't need to play with __THROW twice.

Indeed, that's a better fix. I've updated the patch.

Other than that it seems sensible to let string have a __THROW, even though none of this mismatch is really sensible at the end of the day...

While we are here, we should be able to have a test, no? Something in string.h that depends on __THROW being present should suffice I guess.

Tests for this header are hard to do in-tree as the header is intended to interact with the specific CUDA SDK headers.
All this is tested on CUDA buildbots running test-suite and compiles the tests with multiple CUDA versions.
If we get __THROW wrong where it matters, we'll end up with compiler complaining about the mismatch, like it did in the bug report that prompted this patch.

jdoerfert accepted this revision.Oct 6 2021, 4:25 PM

LG. Always including string (probably) won't hurt given the stuff we do here already.

This revision is now accepted and ready to land.Oct 6 2021, 4:25 PM
This revision was landed with ongoing or failed builds.Oct 7 2021, 11:44 AM
This revision was automatically updated to reflect the committed changes.