Skip to content

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented May 2, 2020

This PR adds support for passing linker arguments for creating statically linked position-independent executables and "statically linked" shared libraries.

Therefore it incorporates the majority of #70740 except for the linker rerun hack and actually flipping the "static-pie is supported" switch for musl targets.

@rust-highfive
Copy link
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 2, 2020
@bors
Copy link
Collaborator

bors commented May 3, 2020

☔ The latest upstream changes (presumably #71807) made this pull request unmergeable. Please resolve the merge conflicts.

@petrochenkov
Copy link
Contributor Author

Blocked on #71769.

@petrochenkov petrochenkov added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 12, 2020
@npmccallum
Copy link
Contributor

@petrochenkov #71769 is now merged. Also, perhaps @cuviper wants to review after a rebase?

@petrochenkov
Copy link
Contributor Author

Rebased.
r? @cuviper

@rust-highfive rust-highfive assigned cuviper and unassigned eddyb May 20, 2020
@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels May 20, 2020
@Elinvynia Elinvynia added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 27, 2020
@cuviper
Copy link
Member

cuviper commented May 27, 2020

Looks good!

@bors r+

@bors
Copy link
Collaborator

bors commented May 27, 2020

📌 Commit 96a466c has been approved by cuviper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 27, 2020
@npmccallum
Copy link
Contributor

@petrochenkov Now that this is approved, what is left to enable it on musl?

@petrochenkov
Copy link
Contributor Author

@npmccallum
#72708 is the last pre-requisite.

RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
linker: Support `-static-pie` and `-static -shared`

This PR adds support for passing linker arguments for creating statically linked position-independent executables and "statically linked" shared libraries.

Therefore it incorporates the majority of rust-lang#70740 except for the linker rerun hack and actually flipping the "`static-pie` is supported" switch for musl targets.
RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
linker: Support `-static-pie` and `-static -shared`

This PR adds support for passing linker arguments for creating statically linked position-independent executables and "statically linked" shared libraries.

Therefore it incorporates the majority of rust-lang#70740 except for the linker rerun hack and actually flipping the "`static-pie` is supported" switch for musl targets.
RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
linker: Support `-static-pie` and `-static -shared`

This PR adds support for passing linker arguments for creating statically linked position-independent executables and "statically linked" shared libraries.

Therefore it incorporates the majority of rust-lang#70740 except for the linker rerun hack and actually flipping the "`static-pie` is supported" switch for musl targets.
RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
linker: Support `-static-pie` and `-static -shared`

This PR adds support for passing linker arguments for creating statically linked position-independent executables and "statically linked" shared libraries.

Therefore it incorporates the majority of rust-lang#70740 except for the linker rerun hack and actually flipping the "`static-pie` is supported" switch for musl targets.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 29, 2020
Rollup of 9 pull requests

Successful merges:

 - rust-lang#67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes)
 - rust-lang#71095 (impl From<[T; N]> for Box<[T]>)
 - rust-lang#71500 (Make pointer offset methods/intrinsics const)
 - rust-lang#71804 (linker: Support `-static-pie` and `-static -shared`)
 - rust-lang#71862 (Implement RFC 2585: unsafe blocks in unsafe fn)
 - rust-lang#72103 (borrowck `DefId` -> `LocalDefId`)
 - rust-lang#72407 (Various minor improvements to Ipv6Addr::Display)
 - rust-lang#72413 (impl Step for char (make Range*<char> iterable))
 - rust-lang#72439 (NVPTX support for new asm!)

Failed merges:

r? @ghost
@bors bors merged commit 7aef3a0 into rust-lang:master May 30, 2020
RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 6, 2020
linker: Add a linker rerun hack for gcc versions not supporting -static-pie

Which mirrors the existing `-no-pie` linker rerun hack, but the logic is a bit more elaborated in this case.

If the linker (gcc or clang) errors on `-static-pie` we rerun in with `-static` instead.
We must also replace CRT objects corresponding to `-static-pie` with ones corresponding to `-static` in this case.

(One sanity check for CRT objects in target specs is also added as a drive-by fix.)

To do in the future: refactor all linker rerun hacks into separate functions and share more code with `add_(pre,post)_link_objects`.

This PR accompanies rust-lang#71804 and unblocks rust-lang#70740.
RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 6, 2020
linker: Add a linker rerun hack for gcc versions not supporting -static-pie

Which mirrors the existing `-no-pie` linker rerun hack, but the logic is a bit more elaborated in this case.

If the linker (gcc or clang) errors on `-static-pie` we rerun in with `-static` instead.
We must also replace CRT objects corresponding to `-static-pie` with ones corresponding to `-static` in this case.

(One sanity check for CRT objects in target specs is also added as a drive-by fix.)

To do in the future: refactor all linker rerun hacks into separate functions and share more code with `add_(pre,post)_link_objects`.

This PR accompanies rust-lang#71804 and unblocks rust-lang#70740.
RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 6, 2020
linker: Add a linker rerun hack for gcc versions not supporting -static-pie

Which mirrors the existing `-no-pie` linker rerun hack, but the logic is a bit more elaborated in this case.

If the linker (gcc or clang) errors on `-static-pie` we rerun in with `-static` instead.
We must also replace CRT objects corresponding to `-static-pie` with ones corresponding to `-static` in this case.

(One sanity check for CRT objects in target specs is also added as a drive-by fix.)

To do in the future: refactor all linker rerun hacks into separate functions and share more code with `add_(pre,post)_link_objects`.

This PR accompanies rust-lang#71804 and unblocks rust-lang#70740.
RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 6, 2020
linker: Add a linker rerun hack for gcc versions not supporting -static-pie

Which mirrors the existing `-no-pie` linker rerun hack, but the logic is a bit more elaborated in this case.

If the linker (gcc or clang) errors on `-static-pie` we rerun in with `-static` instead.
We must also replace CRT objects corresponding to `-static-pie` with ones corresponding to `-static` in this case.

(One sanity check for CRT objects in target specs is also added as a drive-by fix.)

To do in the future: refactor all linker rerun hacks into separate functions and share more code with `add_(pre,post)_link_objects`.

This PR accompanies rust-lang#71804 and unblocks rust-lang#70740.
@petrochenkov petrochenkov deleted the static-pie branch February 22, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants