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.
Thanks, Richard
On 6/12/22 Richard Shaw wrote:
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
Please post a recipe to reproduce those complaints: the .spec file (or URL), other context for building, etc.
When I build according to README.md at https://github.com/emqx/nanomq "Building From Source", without Ninja:
git clone https://github.com/emqx/nanomq.git ; cd nanomq git submodule update --init --recursive mkdir build && cd build cmake .. make
then I see no complaints from /usr/bin/ld.
The software package itself is low quality. gcc complains dozens of serious errors such as: nng/src/nng.c:2269:1: warning: control reaches end of non-void function [-Wreturn-type] nng/src/sp/protocol/mqtt/nmq_mqtt.c:271:51: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] nng/src/supplemental/mqtt/mqtt_qos_db.c:620:13: warning: unused variable ‘rv’ [-Wunused-variable] 620 | int rv = sqlite3_exec(db, "COMMIT;", 0, 0, 0);
On Sun, Jun 12, 2022 at 9:23 PM John Reiser jreiser@bitwagon.com wrote:
On 6/12/22 Richard Shaw wrote:
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
Please post a recipe to reproduce those complaints: the .spec file (or URL), other context for building, etc.
Sorry, I was hoping it was obvious. I'm only building in locally right now so I have uploaded it here: https://hobbes1069.fedorapeople.org/emqx-nanomq.spec
When I build according to README.md at https://github.com/emqx/nanomq "Building From Source", without Ninja:
git clone https://github.com/emqx/nanomq.git ; cd nanomq git submodule update --init --recursive mkdir build && cd build cmake .. make
then I see no complaints from /usr/bin/ld.
Yes, it seems to be an issue when trying to enforce all of Fedora's build flags.
Full build log here: https://hobbes1069.fedorapeople.org/build.log
The software package itself is low quality. gcc complains dozens of serious errors such as: nng/src/nng.c:2269:1: warning: control reaches end of non-void function [-Wreturn-type] nng/src/sp/protocol/mqtt/nmq_mqtt.c:271:51: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] nng/src/supplemental/mqtt/mqtt_qos_db.c:620:13: warning: unused variable ‘rv’ [-Wunused-variable] 620 | int rv = sqlite3_exec(db, "COMMIT;", 0, 0, 0);
Thanks. I'll make sure that makes it upstream.
Richard
On 6/13/22 04:59, Richard Shaw wrote:
On Sun, Jun 12, 2022 at 9:23 PM John Reiser wrote:
Please post a recipe to reproduce those complaints: the .spec file (or URL), other context for building, etc.
Sorry, I was hoping it was obvious. I'm only building in locally right now so I have uploaded it here: https://hobbes1069.fedorapeople.org/emqx-nanomq.spec https://hobbes1069.fedorapeople.org/emqx-nanomq.spec
There still are missing pieces. From that .spec file:
# Deal with git submodules not in the archive # git clone --recurse-submodules https://github.com/emqx/nanomq.git # from extern project subdirs # git archive -o ../../../l8w8jwt.tar.gz HEAD Source1: l8w8jwt.tar.gz Source2: nng-fork.tar.gz
Patch0: nanomq.patch
Where is nanomq.patch ? And the path ../../../l8w8jwt.tar points to a directory which is outside of the build environment.
It would be much easier to help, if the _complete_ information was specified. Present the issue as a bug report, including the build environment (Fedora 36? Rawhide? ...)
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.
-- Petr
On Mon, Jun 13, 2022 at 3:45 AM Petr Pisar ppisar@redhat.com 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.
Thanks, Richard
On Mon, Jun 13, 2022 at 7:07 AM Richard Shaw hobbes1069@gmail.com wrote:
On Mon, Jun 13, 2022 at 3:45 AM Petr Pisar ppisar@redhat.com 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