The question of why LLVM defaults to PIC for MIPS, when GCC doesn't, keeps coming up.
It seems like it would be useful to add an explanatory comment, even if it's only a partial explanation.
This is based on:
- What Sasa Sankovic wrote in http://reviews.llvm.org/D3928: "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."
- This thread from 2008, "RFC: Adding non-PIC executable support to MIPS": https://sourceware.org/ml/binutils/2008-06/msg00280.html
- Part of http://www.linux-mips.org/wiki/PIC_code, which is presumably out of date (from 2008 or earlier), which says: "All userspace code in Linux is PIC code. It is currently not possible to mix non-PIC object files and PIC object files when linking. Therefore the customer needs to generate PIC objects."
Please feel free to suggest a different wording for the comment!
As I mentioned in D5442, PIC code is generally more efficient in N64, so this part of the comment is not completely valid. In those cases, setting RM to Reloc::Static will actually have no effect, since PIC code will be generated.
It is true that the reasons for PIC in MIPS Linux are historical en générale, though in LLVM case this might have been caused by different defaults at the time.