This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Support glibc's non-standard I printf flag character
Needs ReviewPublic

Authored by sberg on Sep 9 2020, 6:03 AM.

Details

Reviewers
eugenis
samsonov
Summary

(see https://sourceware.org/git/?p=glibc.git;a=commit;h=4295702fe36902ad82587748b918d828ce62c446 "[...] stdio-common/vfprintf.c: Implement 'I' flag to print using locales' outdigits." for a source)

Diff Detail

Event Timeline

sberg created this revision.Sep 9 2020, 6:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2020, 6:03 AM
Herald added subscribers: Restricted Project, dberris. · View Herald Transcript
sberg requested review of this revision.Sep 9 2020, 6:03 AM
hubert.reinterpretcast added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_format.inc
410

Note that Clang favours the MSVCRT interpretation of printf("%I64d\n", 42LL);.

sberg added inline comments.Sep 18 2020, 8:39 AM
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_format.inc
410

But then again all of this code is guarded by

#if SANITIZER_INTERCEPT_PRINTF

and the only place to define SANITIZER_INTERCEPT_PRINTF appears to be

# define SANITIZER_INTERCEPT_PRINTF SI_POSIX

in compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h, so it looks like this code is only used for Posix environments, at least for now?

But maybe it would be better to only include I in the above string literal conditionally on SI_POSIX (or SANITIZER_POSIX, which appears to be the same thing, cf. llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h)?

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_format.inc
410

The more specific guarding here sounds like a good idea to me (but I have very little exposure to/experience in the sanitizer code). SI_POSIX would at least take out the Windows side of things in terms of considerations.

Would using __GLIBC_PREREQ make sense here? Or is that too specific?