about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-09-27 15:19:42 +0200
committerMara Bos <m-ou.se@m-ou.se>2020-09-27 16:04:25 +0200
commit07fd17f7014de6dc209c7dc4de159a2a5acea173 (patch)
tree711bf0b292f07d2678bdec22bdd5f986ba8cae5b /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentb8363295d555494bbaa119eba8b16a3057e6728c (diff)
downloadrust-07fd17f7014de6dc209c7dc4de159a2a5acea173.tar.gz
rust-07fd17f7014de6dc209c7dc4de159a2a5acea173.zip
Only use LOCAL_{STDOUT,STDERR} when set_{print/panic} is used.
The thread local LOCAL_STDOUT and LOCAL_STDERR are only used by the test
crate to capture output from tests when running them in the same process
in differen threads. However, every program will check these variables
on every print, even outside of testing.

This involves allocating a thread local key, and registering a thread
local destructor. This can be somewhat expensive.

This change keeps a global flag (LOCAL_STREAMS) which will be set to
true when either of these local streams is used. (So, effectively only
in test and benchmark runs.) When this flag is off, these thread locals
are not even looked at and therefore will not be initialized on the
first output on every thread, which also means no thread local
destructors will be registered.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions