[libcxx-commits] [PATCH] D122941: [libc++] Make the Debug mode a configuration-time only option

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 3 07:43:59 PDT 2022


ldionne marked 2 inline comments as done.
ldionne added a subscriber: danlark.
ldionne added a comment.

In D122941#3425095 <https://reviews.llvm.org/D122941#3425095>, @philnik wrote:

> Another thought: Should we change the ABI namespace to force link time errors if someone tries to link against the wrong library? - This should probably be done in the same patch where we enable some ABI flags.

We are very much on the same page, it seems :-). Quoting from my in-progress design document:

- The sanitized version of the library would have a different name, for example `libc++-sanitized.dylib`. A different `__config_site` file would also be provided to be used when compiling code against the sanitized library. Vendors could ship both the sanitized and the non-sanitized library side-by-side.
- The sanitized version of the library would use a different inline namespace to make sure that code can’t accidentally link against the wrong version of the library (which would result in runtime errors due to ABI incompatibilities).
- When `-fsanitize=library` is passed to the compiler, the compiler would automatically switch to using the sanitized version of the library. It would use the sanitized shared library as well as the sanitized version of the `__config_site` header, so that code in the headers would be built with sanitization enabled too.

I will also treat the topic of ABI compatibility between sanitized and non-sanitized versions, and also ABI stability between sanitized versions. Stay tuned, I should post it to Discourse in a couple of days.

@danlark 
This patch will break users of the randomized unspecified behavior you added since you are most likely not shipping a debug-mode version of the library today. Has it been in used internally at Google?



================
Comment at: libcxx/docs/DesignDocs/DebugMode.rst:23
 
-Also note that while the debug mode has no effect on libc++'s ABI, it does have broad ODR
-implications. Users should compile their whole program at the same debugging level.
+Furthermore, users should not rely on a stable ABI being provided when the debug mode is
+enabled -- we reserve the right to change the ABI at any time. If you need a stable ABI
----------------
philnik wrote:
> Mordante wrote:
> > Does this mean we want to use the unstable ABI in this mode?
> I don't think so. I think we should still guarantee ABI stability between GCC and clang, which excludes the `[[clang::trivial_abi]]` optimizations. I also wouldn't expect the size of `tuple` to change between debug and non-debug library, but that one is more debatable I think.
I think we should use the unstable ABI in debug mode. ABI compatibility between GCC and Clang should not be an issue, because we would expect the debug mode to only be used through Clang's `-fsanitize=library` flag.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122941/new/

https://reviews.llvm.org/D122941



More information about the libcxx-commits mailing list