<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/library/std/src/sys/thread_local, branch beta</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=beta</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=beta'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-08-16T12:28:31+00:00</updated>
<entry>
<title>library: Migrate from `cfg_if` to `cfg_select`</title>
<updated>2025-08-16T12:28:31+00:00</updated>
<author>
<name>Josh Triplett</name>
<email>josh@joshtriplett.org</email>
</author>
<published>2025-08-10T21:25:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1ae4a0cc3487f28b29f36afe8056535afad21e7b'/>
<id>urn:sha1:1ae4a0cc3487f28b29f36afe8056535afad21e7b</id>
<content type='text'>
Migrate the standard library from using the external `cfg_if` crate to
using the now-built-in `cfg_select` macro.

This does not yet eliminate the dependency from
`library/std/Cargo.toml`, because while the standard library itself no
longer uses `cfg_if`, it also incorporates the `backtrace` crate, which
does.

Migration assisted by the following vim command (after selecting the
full `cfg_if!` invocation):

```
'&lt;,'&gt;s/\(cfg_if::\)\?cfg_if/cfg_select/ | '&lt;,'&gt;s/^\( *\)} else {/\1}\r\1_ =&gt; {/c | '&lt;,'&gt;s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 =&gt; /e | '&lt;,'&gt;s/if #\[cfg(\(.*\))\] {/\1 =&gt; {/e
```

This is imperfect, but substantially accelerated the process. This
prompts for confirmation on the `} else {` since that can also appear
inside one of the arms. This also requires manual intervention to handle
any multi-line conditions.
</content>
</entry>
<entry>
<title>Fix broken TLS destructors on 32-bit win7</title>
<updated>2025-07-21T11:11:47+00:00</updated>
<author>
<name>roblabla</name>
<email>unfiltered@roblab.la</email>
</author>
<published>2025-07-20T23:32:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=58537fb869a8e08d5146e8feab982f17b3fd990a'/>
<id>urn:sha1:58537fb869a8e08d5146e8feab982f17b3fd990a</id>
<content type='text'>
On the 32-bit win7 target, we use OS TLS instead of native TLS, due to
issues with how the OS handles alignment. Unfortunately, this caused
issues due to the TLS destructors not running, causing memory leaks
among other problems.

On Windows, to support OS TLS, the TlsAlloc family of function is used
by Rust. This function does not support TLS destructors at all. However,
rust has some code to emulate those destructors, by leveraging the TLS
support functionality found in the MSVC CRT (specifically, in tlssup.c
of the CRT). Specifically, the CRT provides the ability to register
callbacks that are called (among other things) on thread destruction. By
registering our own callback, we can run through a list of registered
destructors functions to execute.

To use this functionality, the user must do two things:

1. They must put the address to their callback in a section between
   `.CRT$XLB` and `.CRT$XLY`.
2. They must add a reference to `_tls_used` (or `__tls_used` on x86) to
   make sure the TLS support code in tlssup.c isn't garbage collected by
   the linker.

Prior to this commit, this second bit wasn't being done properly by the
Rust TLS support code. Instead of adding a reference to _tls_used, it
instead had a reference to its own callback to prevent it from getting
GC'd by the linker. While this is _also_ necessary, not having a
reference on _tls_used made the entire support non-functional.

This commit reworks the code to:

1. Add an unconditional `#[used]` attribute on the CALLBACK, which
   should be enough to prevent it from getting GC'd by the linker.
2. Add a reference to `_tls_used`, which should pull the TLS support
   code into the Rust programs and not let it be GC'd by the linker.
</content>
</entry>
<entry>
<title>Rollup merge of #141455 - joboet:tls_exhaustion_abort, r=tgross35</title>
<updated>2025-06-03T19:53:36+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>476013+matthiaskrgr@users.noreply.github.com</email>
</author>
<published>2025-06-03T19:53:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d096ebf8d93e78b429c5c5866ecc60b3a5d9ed18'/>
<id>urn:sha1:d096ebf8d93e78b429c5c5866ecc60b3a5d9ed18</id>
<content type='text'>
std: abort the process on failure to allocate a TLS key

The panic machinery uses TLS, so panicking if no TLS keys are left can lead to infinite recursion (see https://github.com/rust-lang/rust/issues/140798#issuecomment-2872307377). Rather than having separate logic for the panic count and the thread name, just always abort the process if a TLS key allocation fails. This also has the benefit of aligning the key-based TLS implementation with the documentation, which does not mention that a panic could also occur because of resource exhaustion.
</content>
</entry>
<entry>
<title>Address review comments.</title>
<updated>2025-05-30T10:14:27+00:00</updated>
<author>
<name>Orson Peters</name>
<email>orsonpeters@gmail.com</email>
</author>
<published>2025-05-30T10:13:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b374adc9dbeec2cc969723dbfcb5c8ee990953bd'/>
<id>urn:sha1:b374adc9dbeec2cc969723dbfcb5c8ee990953bd</id>
<content type='text'>
</content>
</entry>
<entry>
<title>When replacing an old value we may not drop it in place</title>
<updated>2025-05-28T15:53:14+00:00</updated>
<author>
<name>Orson Peters</name>
<email>orsonpeters@gmail.com</email>
</author>
<published>2025-05-28T15:52:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9ffbc62cb60f2151a38b6c5e18c016e406d10a62'/>
<id>urn:sha1:9ffbc62cb60f2151a38b6c5e18c016e406d10a62</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add same unsafe bound on get_or_init_slow</title>
<updated>2025-05-28T15:10:50+00:00</updated>
<author>
<name>Orson Peters</name>
<email>orsonpeters@gmail.com</email>
</author>
<published>2025-05-28T15:09:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8785f7b122bbb83d308035565f243ceb95ce4736'/>
<id>urn:sha1:8785f7b122bbb83d308035565f243ceb95ce4736</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Do not panic, maintain old behavior</title>
<updated>2025-05-28T14:56:26+00:00</updated>
<author>
<name>Orson Peters</name>
<email>orsonpeters@gmail.com</email>
</author>
<published>2025-05-28T14:56:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=13bce27e378267203f681470f947208b3e267558'/>
<id>urn:sha1:13bce27e378267203f681470f947208b3e267558</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Improve safety comment, double-drop is not relevant here</title>
<updated>2025-05-28T12:51:52+00:00</updated>
<author>
<name>Orson Peters</name>
<email>orsonpeters@gmail.com</email>
</author>
<published>2025-05-28T12:51:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f70cf59fc19b7717397e9701b4783f744983275f'/>
<id>urn:sha1:f70cf59fc19b7717397e9701b4783f744983275f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Do not move thread-locals before dropping</title>
<updated>2025-05-28T12:39:51+00:00</updated>
<author>
<name>Orson Peters</name>
<email>orsonpeters@gmail.com</email>
</author>
<published>2025-05-28T12:39:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b0f6b69b813aae1b7525d222ca1d2ba9c1fa25f1'/>
<id>urn:sha1:b0f6b69b813aae1b7525d222ca1d2ba9c1fa25f1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>std: abort the process on failure to allocate a TLS key</title>
<updated>2025-05-23T16:00:09+00:00</updated>
<author>
<name>joboet</name>
<email>jonasboettiger@icloud.com</email>
</author>
<published>2025-05-23T16:00:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8bf515330fb68ba10a54e9087a2b5629a968e766'/>
<id>urn:sha1:8bf515330fb68ba10a54e9087a2b5629a968e766</id>
<content type='text'>
The panic machinery uses TLS, so panicking if no TLS keys are left can lead to infinite recursion (see https://github.com/rust-lang/rust/issues/140798#issuecomment-2872307377). Rather than having separate logic for the panic count and the thread name, just always abort the process if a TLS key allocation fails. This also has the benefit of aligning the key-based TLS implementation with the documentation, which does not mention that a panic could also occur because of resource exhaustion.
</content>
</entry>
</feed>
