Set relocation_model to Pic on emscripten target#98149
Conversation
|
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
|
|
@hoodmane: 🔑 Insufficient privileges: Not in reviewers |
|
r? rust-lang/compiler |
|
wasm_base.rs has some comments relevant to this - https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/wasm_base.rs#L111-L118 So considering
it looks like that the tradeoffs from this change are more or less:
|
|
I guess the main alternative here is to build standard library specifically (libcore/libstd/etc) as PIC (in Then the tradeoffs will be:
|
|
I have no idea what alternative is preferable here. |
I think what @sbc100 said was that the final product should be about the same, but the object files will be larger and the compilation will be slower. This is a lot better than the final program being larger and slower. |
Indeed, to the best of my knowledge, all of the PIC overhead can be removing by |
|
I just built a library with so the static version come in 224 bytes smaller, which is a 0.008% difference. Kind of surprisingly similar size. Execution time is also the same within my large error margin. This isn't a very scientific test but I would believe that it makes no difference. |
Thanks for running the numbers! If you have time/interest would you mind running both of those binaries through |
|
After running |
|
Okay, seems fine to use pic by default then. |
|
@rustbot label -S-waiting-on-author +S-waiting-on-review |
|
@bors r+ rollup |
|
📌 Commit ada2acc has been approved by |
…nkov Set relocation_model to Pic on emscripten target So we can support dynamically linking libraries with Emscripten (otherwise we need to use nightly and `-Zbuild-std` to rebuild std with relocations). `@sbc100`
…nkov Set relocation_model to Pic on emscripten target So we can support dynamically linking libraries with Emscripten (otherwise we need to use nightly and `-Zbuild-std` to rebuild std with relocations). ``@sbc100``
…nkov Set relocation_model to Pic on emscripten target So we can support dynamically linking libraries with Emscripten (otherwise we need to use nightly and `-Zbuild-std` to rebuild std with relocations). ```@sbc100```
…nkov Set relocation_model to Pic on emscripten target So we can support dynamically linking libraries with Emscripten (otherwise we need to use nightly and `-Zbuild-std` to rebuild std with relocations). ````@sbc100````
…askrgr Rollup of 9 pull requests Successful merges: - rust-lang#96412 (Windows: Iterative `remove_dir_all`) - rust-lang#98126 (Mitigate MMIO stale data vulnerability) - rust-lang#98149 (Set relocation_model to Pic on emscripten target) - rust-lang#98194 (Leak pthread_{mutex,rwlock}_t if it's dropped while locked.) - rust-lang#98298 (Point to type parameter definition when not finding variant, method and associated item) - rust-lang#98311 (Reverse folder hierarchy) - rust-lang#98401 (Add tracking issues to `--extern` option docs.) - rust-lang#98429 (Use correct substs in enum discriminant cast) - rust-lang#98431 (Suggest defining variable as mutable on `&mut _` type mismatch in pats) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Yesterday's nightly includes rust-lang/rust#98149 which allows us to remove the PIC setting. This also means we won't ever have to put -Zbuild-std back in.
…chenkov Implement set_output_kind for Emscripten linker This is on top of rust-lang#98149. See also the earlier discussion on rust-lang#98303. With this PR, a crate that specifies that it is a cdylib will compile to a working Emscripten dynamic library without adding any extra cargo, rustc, or linker flags and without fiddling with environment variables. `@sbc100` r? `@petrochenkov`
…chenkov Implement set_output_kind for Emscripten linker This is on top of rust-lang#98149. See also the earlier discussion on rust-lang#98303. With this PR, a crate that specifies that it is a cdylib will compile to a working Emscripten dynamic library without adding any extra cargo, rustc, or linker flags and without fiddling with environment variables. `@sbc100` r? `@petrochenkov`
So we can support dynamically linking libraries with Emscripten (otherwise we need to use nightly and
-Zbuild-stdto rebuild std with relocations).@sbc100