Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default values for TargetOption violate the target consistency check #133459

Open
RalfJung opened this issue Nov 25, 2024 · 6 comments
Open
Labels
A-target-specs Area: Compile-target specifications A-targets Area: Concerning the implications of different compiler targets C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

TargetOption defaults to relocation_model: Pic and dynamic_linking: false and position_independent_executables: false. However, our consistency check that this is an invalid combination of options.

So it seems we should either fix our defaults, or the consistency check is a bit overzealous?

This check was added in #100537, Cc @petrochenkov @oli-obk

@RalfJung RalfJung added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 25, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 25, 2024
@jieyouxu jieyouxu added A-target-specs Area: Compile-target specifications A-targets Area: Concerning the implications of different compiler targets C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 25, 2024
@petrochenkov
Copy link
Contributor

The consistency check is reasonable, you don't typically need PIC if you don't have dynamic linking (or PIEs)
From the built-in targets only UEFI is the exception, as you can see.

The defaults are also reasonable, all of them use safe choices.
But if you really want the default target to pass the consistency check, then some of them can be changed.
I don't think it's an issue really.

@RalfJung
Copy link
Member Author

RalfJung commented Nov 25, 2024

I think JSON-defined targets should pass the consistency check (see #133409). And, unsurprisingly, most JSON-defined targets leave those values at their default. But also, changing them would change the behavior of those JSON targets, wouldn't it?

@kpreid
Copy link
Contributor

kpreid commented Nov 26, 2024

The consistency check is reasonable, you don't typically need...

This sounds like a case where a "warning" vs. "error" distinction would be sufficient to solve the problem? That is, it would be reasonable for all-defaults to be a configuration which is accepted with a warning.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2024

I think keeping an error and forcing folk to make a concious choice to pick sth is good. Changing the defaults could cause a lot of problems, many unnoticeable at build time (link time or runtime would show issues).

If we want to change the default, we should make sure that anyone relying on the defaults gets informed somehow, which I think is only possible by renaming all fields in a consistency set

@RalfJung
Copy link
Member Author

RalfJung commented Nov 26, 2024 via email

@workingjubilee
Copy link
Member

I'm confused, why would we default to PIC but not PIE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-target-specs Area: Compile-target specifications A-targets Area: Concerning the implications of different compiler targets C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants