@@ -271,35 +271,39 @@ binary link:
271
271
272
272
Passing ` rlib ` s directly into your foreign linker is currently unsupported.
273
273
274
- ### Prohibited linkage and foreign unwinding
275
-
276
- r[ link.foreign-code.prohibited]
277
-
278
- Undfined behavior may be caused by foreign code unwinding into a Rust crate
279
- with these characteristics:
280
-
281
- * The foreign unwind enters Rust via a function or function pointer declared
282
- with an ABI that permits unwinding, that is, ` "Rust" ` (the default ABI) or
283
- any ` -unwind ` ABI
284
- * The Rust crate containing the ` -unwind ` ABI declaration was compiled with
285
- ` panic=unwind `
286
- * The final binary is linked with [ the ` panic=abort ` runtime] [ panic-runtime ]
287
-
288
- > ** Note** : To protect against this undefined behavior, ` rustc ` does not permit
289
- > linking the ` panic=abort ` runtime against any crate that was compiled with
290
- > ` panic=unwind ` if that crate also contains a call to a foreign function or
291
- > function pointer declared with an ` -unwind ` ABI. Note that this prohibition
292
- > applies even when linking a static or dynamic library that only includes Rust
293
- > code, since the resulting library may be subsequently linked against another
294
- > library that may unwind. However, use of the ` Rust ` (default) ABI does not
295
- > cause a link-error, since that ABI is not expected to be used as an
296
- > entrypoint into a static or shared library.
297
-
298
- > ** Note** : the restriction can only be violated when mixing code with different
299
- > ` -C panic ` flags. This is not possible in normal use of cargo, so most users
300
- > need not be concerned about this.
301
-
302
- r[ link.foreign-code.prohibited.lint.ffi_unwind_calls]
274
+ > [ !NOTE]
275
+ > Rust code compiled or linked with a different instance of the Rust runtime counts as a
276
+ > "foreign code" for the purpose of this section.
277
+
278
+ ### Prohibited linkage and unwinding
279
+
280
+ r[ link.unwinding]
281
+ If you are * not* using ` rustc ` to link Rust files, you must take care to ensure that unwinding is
282
+ handled consistently across the entire binary. This includes using ` dlopen ` or similar facilities
283
+ where linking is done by the system runtime without ` rustc ` being involved.
284
+
285
+ r[ link.unwinding.potential]
286
+ A Rust binary or ` staticlib ` is called * potentially unwinding* if any of the following conditions
287
+ is met:
288
+ - The binary or ` staticlib ` is linked with [ the ` panic=unwind ` runtime] [ panic-runtime ] .
289
+ - The binary or ` staticlib ` contains a crate built with ` -Cpanic=unwind ` that makes a call
290
+ to a function using a ` -unwind ` ABI.
291
+ - The binary or ` staticlib ` makes a ` "Rust" ` ABI call to code running in a separately built
292
+ ` staticlib ` (i.e., a separate instance of the Rust runtime), and that other ` staticlib ` is
293
+ potentially unwinding.
294
+
295
+ > [ !NOTE]
296
+ > This definition captures whether a ` "Rust" ` ABI call inside a Rust binary or ` staticlib ` can ever
297
+ > unwind.
298
+
299
+ r[ link.unwinding.prohibited]
300
+ If a Rust binary or ` staticlib ` is potentially unwinding, then all its crates must be built with ` -Cpanic=unwind ` .
301
+
302
+ > [ !NOTE]
303
+ > This restriction can only be violated when mixing code with different ` -C panic ` flags
304
+ > while also using a non-` rustc ` linker. Most users to not have to be concerned about this.
305
+
306
+ r[ link.unwinding.prohibited.lint.ffi_unwind_calls]
303
307
To guarantee that a library will be sound (and linkable with ` rustc ` )
304
308
regardless of the panic mode used at link-time, the [ ` ffi_unwind_calls ` lint]
305
309
may be used. The lint flags any calls to ` -unwind ` foreign functions or
0 commit comments