This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [MinGW] Don't pass -dynamicbase:no by default for arm/arm64
ClosedPublic

Authored by mstorsjo on Dec 9 2017, 1:52 PM.

Details

Summary

The linker refuses (since D41051) using -dynamicbase:no on these architectures.

Stop passing -dynamicbase (which just reinforces the lld-link default) for simplicity.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Dec 9 2017, 1:52 PM
ruiu added inline comments.Dec 11 2017, 9:18 AM
MinGW/Driver.cpp
162–164 ↗(On Diff #126282)

If a user passes -dynamicbase to the MinGW driver, we should just pass it through to the COFF driver, no? Ignoring -dynamicbase if arm/arm64 seems odd to me.

mstorsjo added inline comments.Dec 11 2017, 10:07 AM
MinGW/Driver.cpp
162–164 ↗(On Diff #126282)

I guess we can pass it through as well -
will update.

mstorsjo updated this revision to Diff 126418.Dec 11 2017, 12:36 PM

Updated to pass the flag through on these architectures.

ruiu added inline comments.Dec 11 2017, 12:51 PM
MinGW/Driver.cpp
162–165 ↗(On Diff #126418)

My understanding is passing -dynamicbase:no on arm/arm64 doesn't make sense and should be considered error. Don't you want to remove this special condition and handle all targets equally (so that the error would be reported if you pass -dynamicbase:no on arm/arm64)?

mstorsjo added inline comments.Dec 11 2017, 1:04 PM
MinGW/Driver.cpp
162–165 ↗(On Diff #126418)

In the MinGW/GNU frontend, there is no -dynamicbase:no case. We have different behaviours in the COFF and MinGW frontends; in the COFF one we default to dynamicbase being enabled and it can be disabled with the link.exe option -dynamicbase:no.

In the MinGW frontend on the other hand, the default is off and it can be enabled with --dynamicbase. There is no option for disabling it (which in GNU options style would be --no-dynamicbase) AFAIK. Thus in the MinGW frontend, we pass -dynamicbase:no by default to the COFF linker, to match the behaviour of GNU ld. But for arm/arm64 (which GNU ld doesn't support at all for COFF), we obviously want to do things differently. Thus in this form, we either rely on the COFF linker default (on) implicitly if no flag is provided, or explicitly request it if the flag is set.

Ping @ruiu - any followup to this one?

ruiu added inline comments.Dec 11 2017, 10:15 PM
MinGW/Driver.cpp
162–165 ↗(On Diff #126418)

Thank you for the explanation. So overall it sounds like it would suffice if we pass -dynamicbase:no if !arm && !Args.hasArg(OPT_dynamicbase). We don't need to pass -dynamicbase because it is default. Is this correct?

mstorsjo added inline comments.Dec 11 2017, 10:58 PM
MinGW/Driver.cpp
162–165 ↗(On Diff #126418)

Correct - that would suffice as well. That adds a minimal dependency on the lld default value, but I don't see that changing towards false by default anyway.

mstorsjo updated this revision to Diff 126504.Dec 11 2017, 11:06 PM
mstorsjo edited the summary of this revision. (Show Details)
ruiu accepted this revision.Dec 12 2017, 11:08 AM

LGTM

This revision is now accepted and ready to land.Dec 12 2017, 11:08 AM
This revision was automatically updated to reflect the committed changes.