This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizer] Update macOS version checking
ClosedPublic

Authored by yln on Jun 30 2020, 3:21 PM.

Details

Summary

Support macOS 11 in our runtime version checking code and update
GetMacosAlignedVersionInternal() accordingly. This follows the
implementation of Triple::getMacOSXVersion() in the Clang driver.

Diff Detail

Event Timeline

yln created this revision.Jun 30 2020, 3:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2020, 3:21 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
yln updated this revision to Diff 276236.Jul 7 2020, 3:30 PM

Align implementation with the corresponding change int the
Clang driver (https://reviews.llvm.org/D82337).
We follow the same approach as Triple::getMacOSXVersion().

yln added a reviewer: arphaman.Jul 7 2020, 3:39 PM

Other than minor nit LGTM.

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
612–624

Nit: Could we keep const u16 version_offset = 4 and use?

yln marked 2 inline comments as done.Jul 8 2020, 10:51 AM
yln added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
612–624

I decided to revert this back to int literals for 2 reasons:

  • Make it more similar to Triple::getMacOSXVersion(), so it will be easier to follow any changes made there.
  • We now have 2 version offsets: pre and post macOS 11; and I couldn't come up with names that weren't too unwieldy (version_offset_pre_macos_11 = 4) while retaining symmetry (having a named constant for both offsets).
delcypher requested changes to this revision.Jul 9 2020, 4:44 PM
delcypher added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
612–624

Make it more similar to Triple::getMacOSXVersion(), so it will be easier to follow any changes made there.

Is this actually a goal? If it is then a commit message and a comment should explicitly call this out, right now the relationship isn't obvious. However, I'm not convinced trying to stylistically mimic Clang's code is the right thing to do.

We now have 2 version offsets: pre and post macOS 11; and I couldn't come up with names that weren't too unwieldy (version_offset_pre_macos_11 = 4) while retaining symmetry (having a named constant for both offsets).

I see. I don't think version_offset_pre_macos_11 is that unwieldy but it's your call.

If you want to land this as is then I'd like you to add a comment to the source and in the commit message explaining the relationship between Triple::getMacOSXVersion() and this code.

This revision now requires changes to proceed.Jul 9 2020, 4:44 PM
yln updated this revision to Diff 276878.Jul 9 2020, 5:12 PM
yln marked an inline comment as done.

Add explaining comments.

yln edited the summary of this revision. (Show Details)Jul 9 2020, 5:12 PM
yln marked an inline comment as done.
This revision is now accepted and ready to land.Jul 9 2020, 5:15 PM
This revision was automatically updated to reflect the committed changes.