Implement most of MCP510 by lqd · Pull Request #112910 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

lqd

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Jun 21, 2023

petrochenkov

@rustbot rustbot added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Jun 22, 2023

lqd

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jun 22, 2023

petrochenkov

@lqd

@lqd

linker flavors

@lqd

@lqd

@lqd

@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-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jun 30, 2023

@lqd lqd mentioned this pull request

Jul 1, 2023

@bors bors mentioned this pull request

Jul 2, 2023

@lqd lqd deleted the mcp510 branch

July 2, 2023 07:02

@lqd lqd mentioned this pull request

Jul 12, 2023

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jul 13, 2023

@matthiaskrgr

make MCP510 behavior opt-in to avoid conflicts between the CLI and target flavors

Fixes rust-lang#113597, which contains more details on how this happens through the code, and showcases an unexpected Gnu(Cc::Yes, Lld::Yes) flavor.

rust-lang#112910 added support to use lld when the flavor requests it, but didn't explicitly do so only when using -Clink-self-contained=+linker or one of the unstable -Clinker-flavors.

The problem: some targets have a lld linker and flavor, e.g. thumbv6m-none-eabi from that issue. Users can override the linker but there are no linker flavors precise enough to describe the linker opting out of lld: when using -Clinker=arm-none-eabi-gcc, we infer this is a Cc::Yes linker flavor, but the lld component is unknown and therefore defaulted to the target's linker flavor, Lld::Yes.

Walkthrough of how this happens

The linker flavor used is a mix between what can be inferred from the CLI (-C linker) and the target's default linker flavor:

This results in a Gnu(Cc::Yes, Lld::Yes) flavor on a non-lld linker, causing an additional unexpected -fuse-ld=lld argument to be passed.

I don't know if this target defaulting to rust-lld is expected, but until MCP510's new linker flavor are stable, when people will be able to describe their linker/flavor accurately, this PR keeps the stable behavior of not doing anything when the linker/flavor on the CLI unexpectedly conflict with the target's.

I've tested this on a no_std -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles --target thumbv6m-none-eabi example, trying to simulate one of cortex-m's test mentioned in issue rust-lang#113597 (I don't know how to build a local complete thumbv6m-none-eabi toolchain to run the exact test), and checked that -fuse-lld was indeed gone and the error disappeared.

r? @petrochenkov

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jul 13, 2023

@matthiaskrgr

make MCP510 behavior opt-in to avoid conflicts between the CLI and target flavors

Fixes rust-lang#113597, which contains more details on how this happens through the code, and showcases an unexpected Gnu(Cc::Yes, Lld::Yes) flavor.

rust-lang#112910 added support to use lld when the flavor requests it, but didn't explicitly do so only when using -Clink-self-contained=+linker or one of the unstable -Clinker-flavors.

The problem: some targets have a lld linker and flavor, e.g. thumbv6m-none-eabi from that issue. Users can override the linker but there are no linker flavors precise enough to describe the linker opting out of lld: when using -Clinker=arm-none-eabi-gcc, we infer this is a Cc::Yes linker flavor, but the lld component is unknown and therefore defaulted to the target's linker flavor, Lld::Yes.

Walkthrough of how this happens

The linker flavor used is a mix between what can be inferred from the CLI (-C linker) and the target's default linker flavor:

This results in a Gnu(Cc::Yes, Lld::Yes) flavor on a non-lld linker, causing an additional unexpected -fuse-ld=lld argument to be passed.

I don't know if this target defaulting to rust-lld is expected, but until MCP510's new linker flavor are stable, when people will be able to describe their linker/flavor accurately, this PR keeps the stable behavior of not doing anything when the linker/flavor on the CLI unexpectedly conflict with the target's.

I've tested this on a no_std -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles --target thumbv6m-none-eabi example, trying to simulate one of cortex-m's test mentioned in issue rust-lang#113597 (I don't know how to build a local complete thumbv6m-none-eabi toolchain to run the exact test), and checked that -fuse-lld was indeed gone and the error disappeared.

r? @petrochenkov

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jul 13, 2023

@matthiaskrgr

make MCP510 behavior opt-in to avoid conflicts between the CLI and target flavors

Fixes rust-lang#113597, which contains more details on how this happens through the code, and showcases an unexpected Gnu(Cc::Yes, Lld::Yes) flavor.

rust-lang#112910 added support to use lld when the flavor requests it, but didn't explicitly do so only when using -Clink-self-contained=+linker or one of the unstable -Clinker-flavors.

The problem: some targets have a lld linker and flavor, e.g. thumbv6m-none-eabi from that issue. Users can override the linker but there are no linker flavors precise enough to describe the linker opting out of lld: when using -Clinker=arm-none-eabi-gcc, we infer this is a Cc::Yes linker flavor, but the lld component is unknown and therefore defaulted to the target's linker flavor, Lld::Yes.

Walkthrough of how this happens

The linker flavor used is a mix between what can be inferred from the CLI (-C linker) and the target's default linker flavor:

This results in a Gnu(Cc::Yes, Lld::Yes) flavor on a non-lld linker, causing an additional unexpected -fuse-ld=lld argument to be passed.

I don't know if this target defaulting to rust-lld is expected, but until MCP510's new linker flavor are stable, when people will be able to describe their linker/flavor accurately, this PR keeps the stable behavior of not doing anything when the linker/flavor on the CLI unexpectedly conflict with the target's.

I've tested this on a no_std -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles --target thumbv6m-none-eabi example, trying to simulate one of cortex-m's test mentioned in issue rust-lang#113597 (I don't know how to build a local complete thumbv6m-none-eabi toolchain to run the exact test), and checked that -fuse-lld was indeed gone and the error disappeared.

r? @petrochenkov

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jul 13, 2023

@matthiaskrgr

make MCP510 behavior opt-in to avoid conflicts between the CLI and target flavors

Fixes rust-lang#113597, which contains more details on how this happens through the code, and showcases an unexpected Gnu(Cc::Yes, Lld::Yes) flavor.

rust-lang#112910 added support to use lld when the flavor requests it, but didn't explicitly do so only when using -Clink-self-contained=+linker or one of the unstable -Clinker-flavors.

The problem: some targets have a lld linker and flavor, e.g. thumbv6m-none-eabi from that issue. Users can override the linker but there are no linker flavors precise enough to describe the linker opting out of lld: when using -Clinker=arm-none-eabi-gcc, we infer this is a Cc::Yes linker flavor, but the lld component is unknown and therefore defaulted to the target's linker flavor, Lld::Yes.

Walkthrough of how this happens

The linker flavor used is a mix between what can be inferred from the CLI (-C linker) and the target's default linker flavor:

This results in a Gnu(Cc::Yes, Lld::Yes) flavor on a non-lld linker, causing an additional unexpected -fuse-ld=lld argument to be passed.

I don't know if this target defaulting to rust-lld is expected, but until MCP510's new linker flavor are stable, when people will be able to describe their linker/flavor accurately, this PR keeps the stable behavior of not doing anything when the linker/flavor on the CLI unexpectedly conflict with the target's.

I've tested this on a no_std -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles --target thumbv6m-none-eabi example, trying to simulate one of cortex-m's test mentioned in issue rust-lang#113597 (I don't know how to build a local complete thumbv6m-none-eabi toolchain to run the exact test), and checked that -fuse-lld was indeed gone and the error disappeared.

r? @petrochenkov

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jul 13, 2023

@matthiaskrgr

make MCP510 behavior opt-in to avoid conflicts between the CLI and target flavors

Fixes rust-lang#113597, which contains more details on how this happens through the code, and showcases an unexpected Gnu(Cc::Yes, Lld::Yes) flavor.

rust-lang#112910 added support to use lld when the flavor requests it, but didn't explicitly do so only when using -Clink-self-contained=+linker or one of the unstable -Clinker-flavors.

The problem: some targets have a lld linker and flavor, e.g. thumbv6m-none-eabi from that issue. Users can override the linker but there are no linker flavors precise enough to describe the linker opting out of lld: when using -Clinker=arm-none-eabi-gcc, we infer this is a Cc::Yes linker flavor, but the lld component is unknown and therefore defaulted to the target's linker flavor, Lld::Yes.

Walkthrough of how this happens

The linker flavor used is a mix between what can be inferred from the CLI (-C linker) and the target's default linker flavor:

This results in a Gnu(Cc::Yes, Lld::Yes) flavor on a non-lld linker, causing an additional unexpected -fuse-ld=lld argument to be passed.

I don't know if this target defaulting to rust-lld is expected, but until MCP510's new linker flavor are stable, when people will be able to describe their linker/flavor accurately, this PR keeps the stable behavior of not doing anything when the linker/flavor on the CLI unexpectedly conflict with the target's.

I've tested this on a no_std -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles --target thumbv6m-none-eabi example, trying to simulate one of cortex-m's test mentioned in issue rust-lang#113597 (I don't know how to build a local complete thumbv6m-none-eabi toolchain to run the exact test), and checked that -fuse-lld was indeed gone and the error disappeared.

r? @petrochenkov

@lqd lqd mentioned this pull request

Apr 30, 2025