Re: [OE-core] [PATCH 2/2] rust: Upgrade 1.78.0->1.79.0

Alexander Kanavin
2024-08-28T13:11:44Z

On Tue, 27 Aug 2024 at 23:02, Khem Raj <raj.khem@gmail.com> wrote:
> OE/Poky compiler is built with --enable-default-pie and that will pass
> -pie option implicitly whenever it is invoked. Perhaps
> default system compiler on alma9 is not.
> zlib crate seems to perhaps ignore the option or maybe its missing a
> place to add -pie to its build options, whereas the
> consumer of it is trying to build PIE executables. If we use
> buildtools compiler then it will surely get that consistent but it
> will also hide the issue at hand.

I got to the bottom of this. zlib crate is using libz.a from its
native sysroot, which is coming from zlib-native build, which was
performed using the alma9 host compiler that does not default to pie.

If zlib recipe is adjusted thusly:
-CFLAGS += "-D_REENTRANT"
+CFLAGS += "-D_REENTRANT -fPIE"

then cargo-native builds fine.

I do wonder if that's just a whack-a-mole fix, the problem may return
elsewhere, and we should actually enable pie flags native-wide, for
consistency of native builds between various distros and our
buildtools? How about enabling the entire set of security flags?

I did a quick check, and there's no consensus among distros. Our
buildtools, and Debian (and I guess Ubuntu?) default to pie.
Fedora/Alma does not.

Alex