[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 16 14:56:07 PDT 2020


ldionne added a comment.

In D31413#2277630 <https://reviews.llvm.org/D31413#2277630>, @smeenai wrote:

> What was the conclusion for the comments about the priority level (100 vs. 101)?

My understanding is that values below `101` are literally not allowed:

  <...>/llvm/libcxx/src/iostream.cpp:80:66: error: 'init_priority' attribute requires integer constant between 101 and 65535 inclusive
  _LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(100)));
                                                                   ^             ~~~
  1 error generated.

If there's a way around that, and if values below 101 are reserved for the implementation, then I agree `100` is what we should use. @aaron.ballman where did you read that values below 101 were reserved for the implementation? The GCC docs at https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html don't imply that -- they say the attribute starts at 101. I agree it's a fairly logical thing to think values before that would be reserved, but it doesn't say explicitly.

Is it possible that GCC reserves values before 101 for the implementation, but Clang implemented the attribute "naively" and just errors out?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413



More information about the cfe-commits mailing list