[libcxx-commits] [PATCH] D116498: [libcxx] Use Fuchsia-native CPRNG for std::random_device
Petr Hosek via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 4 10:27:31 PST 2022
phosek added a comment.
LGTM
================
Comment at: libcxx/src/random.cpp:188
+ // statically linking libc++.
+# pragma comment(lib, "zircon")
+
----------------
ldionne wrote:
> mcgrathr wrote:
> > ldionne wrote:
> > > This pragma is magic. It leaves a breadcrumb in the `.o` and the linker will pick it up automatically?
> > >
> > > On what platforms does this work?
> > Correct. The pragma syntax comes from MSVC and works there and in Clang on PE-COFF and ELF formats. The ELF linker magic it uses is only supported by lld last I checked (it emits an extra non-allocated section that other linkers would just ignore). For Fuchsia, we are fine assuming that current Clang and LLD are the only tools used.
> >
> This is pretty awesome, we could use that for mach-o as well.
We already use it elsewhere in libc++, for example https://github.com/llvm/llvm-project/blob/3064dd8ccffc561e0f01cfa930b9a481d90e7f4f/libcxx/src/chrono.cpp#L52, https://github.com/llvm/llvm-project/blob/3064dd8ccffc561e0f01cfa930b9a481d90e7f4f/libcxx/src/thread.cpp#L31 or https://github.com/llvm/llvm-project/blob/3064dd8ccffc561e0f01cfa930b9a481d90e7f4f/libcxx/include/__config#L1375.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116498/new/
https://reviews.llvm.org/D116498
More information about the libcxx-commits
mailing list