This is an archive of the discontinued LLVM Phabricator instance.

Undef _TIME_BITS along with _FILE_OFFSET_BITS in sanitizers
AcceptedPublic

Authored by raj.khem on Feb 21 2023, 12:52 PM.

Details

Reviewers
MaskRay
ro
Summary

On 32bit systems using 64bit time_t build fails because
_FILE_OFFSET_BITS is undefined here but _TIME_BITS is still set to 64

Fixes
In file included from compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp:17:
In file included from compiler-rt/lib/sanitizer_common/sanitizer_platform.h:25:
In file included from /usr/include/features.h:393:
/usr/include/features-time64.h:26:5: error: "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"

^

1 error generated.

Diff Detail

Event Timeline

raj.khem created this revision.Feb 21 2023, 12:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2023, 12:52 PM
raj.khem requested review of this revision.Feb 21 2023, 12:52 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptFeb 21 2023, 12:52 PM
MaskRay added a reviewer: ro.Feb 21 2023, 12:57 PM

Reasonable to me, but add @ro to check.

MaskRay accepted this revision.Feb 21 2023, 12:58 PM
This revision is now accepted and ready to land.Feb 21 2023, 12:58 PM
ro added a comment.Feb 21 2023, 1:17 PM

Please state what target the problem occurs on and how/where the patch was tested. _TIME_BITS doesn't exist on Solaris 11.4 and, AFAICS, neither on Illumos.

If the patch goes in, please add a comment why that #undef is needed.

That said, I wonder why sanitizer_platform_limits_posix.cpp doesn't have the same issue. It seems weird to me to work around a non-Solaris issue in a Solaris-specific file. ISTM that <features.h> is included in sanitizer_platform.h only to get a definition of __GLIBC__. I'd find it way more logical to handle the issue there, rather than in sanitizer_procmaps_solaris.cpp.

raj.khem updated this revision to Diff 499334.Feb 21 2023, 5:48 PM
In D144514#4142654, @ro wrote:

Please state what target the problem occurs on and how/where the patch was tested. _TIME_BITS doesn't exist on Solaris 11.4 and, AFAICS, neither on Illumos.

If the patch goes in, please add a comment why that #undef is needed.

That said, I wonder why sanitizer_platform_limits_posix.cpp doesn't have the same issue. It seems weird to me to work around a non-Solaris issue in a Solaris-specific file. ISTM that <features.h> is included in sanitizer_platform.h only to get a definition of __GLIBC__. I'd find it way more logical to handle the issue there, rather than in sanitizer_procmaps_solaris.cpp.

I have moved the undef to sanitizer_platform.h, sadly it has to be included before feature.h, let me know if you have any feedback on this new patch

ro added a comment.Feb 22 2023, 5:04 AM
  • You still haven't mentioned which target is affected.
  • There needs to be a comment explaining why _TIME_BITS is #undefed.
  • Please pass the patch through clang-format-diff.py: there's a TAB before !defined which should just be a blank.
raj.khem updated this revision to Diff 499563.Feb 22 2023, 9:54 AM
In D144514#4144195, @ro wrote:
  • You still haven't mentioned which target is affected.
  • There needs to be a comment explaining why _TIME_BITS is #undefed.
  • Please pass the patch through clang-format-diff.py: there's a TAB before !defined which should just be a blank.

Thanks for comments. I have updated the changeset to address this feedback

MaskRay added inline comments.Feb 22 2023, 10:08 AM
compiler-rt/lib/sanitizer_common/sanitizer_platform.h
30 ↗(On Diff #499563)
raj.khem updated this revision to Diff 499580.Feb 22 2023, 10:35 AM
raj.khem marked an inline comment as done.