Refine CHERI macro and feature definitions#763
Conversation
00f9977 to
4f38f04
Compare
|
This should probably be split into two changes, the backwards compatible changes to |
|
I do wonder if we want to use __has_feature(cheri) ? Capabilities seems rather generic and may be difficult to upstream |
I agree on that. It's rather confusing for systems like seL4 that already have their own notion/definition/types for a capability. |
arichardson
left a comment
There was a problem hiding this comment.
Technically this is a major breaking change but I don't think there is much choice outside of cheribsd that uses it so LGTM if @jrtc27 is also happy with it
4f38f04 to
b374716
Compare
arichardson
left a comment
There was a problem hiding this comment.
Thanks for the new change, LGTM. Will wait for @jrtc27 for merging though
b374716 to
da8608d
Compare
__CHERI__ mean purecap|
I used to use This assumes all projects have some sort of a global shared header where this could be defined, but unfortunately this is not always the case. Existing projects such as muslc [1], newlib, CHERI-Linux also still use |
|
Note that this set of changes will actually make the GCC world happier as you can just use |
And that change can be made now even if they want to support the older compiler versions. |
libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
Outdated
Show resolved
Hide resolved
This is intended to replace __has_feature(capabilities) which is almost certainly too generic to upstream. We'll support them side by side for the long term in our tree, but projects should generally migrate to __has_feature(cheri) as their need for older compilers passes.
Migrate tests that aren't explicitly about __has_feature(capabilities) to __has_feature(cheri).
This is meant to replace expressions like:
__has_feature(capabilities) && !defined(__CHERI_PURE_CAPABILITY__)
or (currently(
__CHERI__ && !defined(__CHERI_PURE_CAPABILITY__)
WARNING: This is a breaking change for hybrid + standard C/C++ code.
Rationale: We strongly encourage all CHERI consumers to use a
pure-capability ABI whenever possible. Therefore it should be the
easiest thing to type and less preferred options should be longer. The
existing macros date to the earliest compiler support which barely
supported capability types. Before broad adoption of CHERI we should
make the macros be sensible. We're past Stuart Feldman's too many users
of make to change the tabs threshold (12), but few codebases will be
effected, the required changes are simple can be safely performed
without automatic review, and we shouldn't have to live with this aspect
of history forever.
Backwards compatible code transition:
For purecap + standard C/C++ code (no hybrid):
No change required.
For hybrid + standard C/C++ (with or without purecap):
defined(__CHERI__) -> __has_feature(capabilities)
or
defined(__CHERI__) -> defined(__CHERI__) || defined(__CHERI_HYBRID__)
Once the need for compatability with old compilers is passed, further
simplication is possible.
For purecap + standard C/C++ code:
__CHERI_PURE_CAPABILITY__ -> __CHERI__
For hybrid + standard C/C++ code:
__has_feature(capabilities) && !defined(__CHERI_PURE_CAPABILITY__) ->
defined(__CHERI_HYBRID__)
da8608d to
67500fa
Compare
This set of changes does three main things:
__CHERI_HYBRID__to indicate hybrid compilation__has_feature(cheri)to eventually replace the overly generic__has_feature(capabilities)__CHERI__a synonym for__CHERI_PURE_CAPABILITY__and adds an__CHERI_HYBRID__This is a breaking changeRationale: We strongly encourage all CHERI consumers to use a pure-capability ABI whenever possible. Therefore it should be the easiest thing to type and less preferred options should be longer. The existing macros date to the earliest compiler support which barely supported capability types. Before broad adoption of CHERI we should make the macros be sensible. We're past Stuart Feldman's too many users of
maketo change the tabs threshold (12), but few codebases will be effected and the required changes are simple and can be safely performed automatically. We shouldn't have to live with this aspect of history forever.