From: Ramsay Jones Date: Sun, 21 Sep 2025 01:14:02 GMT Subject: Re: [PATCH v2 02/18] make: add -fPIE flag Message-ID: <0104ae22-e5cb-41c9-af8c-4d9b0035c219@ramsayjones.plus.com> In-Reply-To: On 20/09/2025 17:44, Junio C Hamano wrote: > Collin Funk writes: > >> Junio C Hamano writes: >> >>> Ezekiel Newren writes: [snip] >> 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. Yes, meson defaults the compiler flags to -fPIC (see e.g. near the end of the original cover letter of say [1]). You can change the compiler flags that meson uses (can't remember off-hand how you do that, but it is documented), you can even set -fPIE, or remove -fPIC etc,. ;) So, I don't know why rust (seems to) require -fPIC/-fPIE to be able to link to libgit.a; maybe we need to add some flags to rustc to _not_ use the equivalent of -fPIC/-fPIE. (I haven't looked, but I will note that the GNU nm program complains about the rust built library!) [1] https://lore.kernel.org/git/20250416231835.2492562-1-ramsay@ramsayjones.plus.com/ ATB, Ramsay Jones