Re: [PATCH v2 02/18] make: add -fPIE flag
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 20, 2025, 16:44 UTC
- Message-ID
- <xmqq1po1ysxk.fsf@gitster.g>
- In-Reply-To
- <87plbmyox4.fsf@gmail.com>
Collin Funk <collin.funk1@gmail.com> writes:
Show 27 quoted lines
> Junio C Hamano <gitster@pobox.com> writes: > >> Ezekiel Newren <ezekielnewren@gmail.com> writes: >> >>> I don't know, but I have another question to add to yours. Why does >>> Make need -fPIE in order for the Rust compiler to link against >>> libgit.a created by Make, when Meson doesn't seem to specify PIE >>> anywhere and yet the Rust compiler can work with Meson's libgit.a >>> output? >> >> I do not know what the build procedure using meson exactly does to >> create a library archive. On the Make side, we do not compile for >> position independence, and don't do anything other than bog standard >> "ar rcs". Patrick, any hint? > > Not too familiar with Rust, but looks like the answer is here [1]. > Specificially, this part: > > pic - fully relocatable position independent code, machine > instructions need to use relative addressing modes. Equivalent to > the "uppercase" -fPIC or -fPIE options in other compilers, depending > on the produced crate types. This is the default model for majority > of supported targets. > > Collin > > [1] https://doc.rust-lang.org/rustc/codegen-options/index.html#relocation-model
Well, thanks for joining the conversation, but that much I think is already shared by those who are involved in this thread.
The background was that Ezekiel did not have to do anything special as far as he knows to get things compiled in a relocatable way with meson based build, and with make based build, (which I know has never used nor required any PIE-ness) he of course needs to add it in a way that is portable across platforms and compilers we care about if we wanted to have PIE objects.
And the question was what, if anything, does meson do specially to do so in a portable way to enable PIE. We'd want to see if it meets our needs (it could be that Ezekiel is getting lucky and meson based build covered the platform+compiler combinations that he happened to be working with) and if so mimick that on the Makefile side.