Re: Still confused about PIE/PIC and default build flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 13, 2022 at 7:07 AM Richard Shaw <hobbes1069@xxxxxxxxx> wrote:
On Mon, Jun 13, 2022 at 3:45 AM Petr Pisar <ppisar@xxxxxxxxxx> wrote:
V Sun, Jun 12, 2022 at 06:07:01PM -0500, Richard Shaw napsal(a):
> So I run into this occasionally and it's still not clear to me. In this
> specific case I'm trying to build nanomq[1] and I get the following error:
>
> /usr/bin/ld: CMakeFiles/nano_test.dir/test.c.o: relocation R_X86_64_32
> against `.rodata' can not be used when making a PIE object; recompile with
> -fPIE
> /usr/bin/ld: CMakeFiles/nano_test.dir/test_hash.c.o: relocation R_X86_64_32
> against `.rodata' can not be used when making a PIE object; recompile with
> -fPIE
> [ 36%] Building C object
> nng/CMakeFiles/nng.dir/src/sp/protocol/reqrep0/rep.c.o
> /usr/bin/ld: CMakeFiles/nano_test.dir/test_dbtree.c.o: relocation
> R_X86_64_32 against symbol `topic0' can not be used when making a PIE
> object; recompile with -fPIE
>
> Any hints are appreciated.
>
It looks like you did not pass -fPIE or -fPIC to a compiler, yet you passed
-fPIE to a linker.

Look at CFLAGS and LDFLAGS envariables passed to cmake program.

Run the build in a verbose mode (make VERBOSE=1) to see the actual invocation
of the compiler when compiling rep.c.o and the linker when using that file to
link an executable.

If you try to package the software into Fedora's RPM package, then the PIE
and PIC options are set with GCC "argument script" using options
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 for the compiler and
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld for the linker. You need to
check that they are indeed presented from CMake configuration to invokation of
compiler and linker.

Ahh... I do usually skim the logs and it looked like the build flags were being applied, but not to those specific files. I swear I like CMake for the most part but they make it very easy to hide stuff like this in obscure locations.

I don't see anything in the appropriate CMakeLists.txt that would override the build flags, I think it's the whole '-S .' issue in Fedora that is causing some things not to be passed to sub-projects.  

Thanks,
Richard
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux