This is an archive of the discontinued LLVM Phabricator instance.

[mips] Set default relocation model to static for NaCl
Needs ReviewPublic

Authored by petarj on Sep 22 2014, 10:29 AM.

Details

Reviewers
mseaborn
Summary

Default model for NaCl has been static for all architectures incl. MIPS.

Diff Detail

Event Timeline

petarj updated this revision to Diff 13941.Sep 22 2014, 10:29 AM
petarj retitled this revision from to [mips] Set default relocation model to static for NaCl.
petarj updated this object.
petarj edited the test plan for this revision. (Show Details)
petarj added a reviewer: mseaborn.
petarj set the repository for this revision to rL LLVM.
petarj added a subscriber: Unknown Object (MLST).
mseaborn added inline comments.Sep 22 2014, 10:56 AM
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
98

Could possibly you add a comment to explain why the default is PIC, and why you don't make Reloc::Static the default for non-NaCl targets as well as for NaCl?

This has come up several times, but I'm still not clear on why LLVM defaults to PIC for MIPS.

e.g. Sasa Sankovic wrote: "MIPS traditionally used PIC relocation model, to be able to use shared libraries. PLT support (which enables non-PIC code to use shared libraries) was added to MIPS only recently, in 2008. I suppose at that time GCC switched to using non-PIC as default. I don't know why LLVM still uses PIC." (see http://reviews.llvm.org/D3928)

Even if the comment is speculative, it would be useful. The comment could just state that the reasons are unknown, and that Reloc::Static is being left as the default in case changing it breaks anything.

petarj added inline comments.Sep 23 2014, 9:58 AM
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
98

I would rather avoid putting comments and being explicit about MIPS default relocation model, primarily because I am not sure I can have a complete answer to your question. PIC has been generally used for Linux shared libraries and majority of applications. PIC code can be easily relocated, and in some instances, such as N64, is actually more efficient that static. You will find out that we are generating PIC code for N64 even if you pass relocation-model=static to llc.