Message ID | 20230916035536.354586-1-amadeus@jmu.edu.cn |
---|---|
State | Superseded |
Delegated to: | Hauke Mehrtens |
Headers | show |
Series | urngd: fixes compilation with glibc | expand |
On 16/09/2023 05:55, Chukun Pan wrote: > When compiling with glibc it will result in error: > 1. #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > Fix this by compiling with optimization (-O2) by default. > > 2. jitterentropy-base.c:(.text+0x39f8): undefined reference to `pthread_join' > Fix this by always linking pthread. > > Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn> > --- > CMakeLists.txt | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/CMakeLists.txt b/CMakeLists.txt > index a1ee0c1..20f4774 100644 > --- a/CMakeLists.txt > +++ b/CMakeLists.txt > @@ -23,7 +23,8 @@ ADD_EXECUTABLE(urngd > TARGET_LINK_LIBRARIES(urngd ${ubox}) > > # jitter RNG must not be compiled with optimizations See that comment, there was a reason for -O0, I don't know which, but if that's still required setting PKG_FORTIFY_SOURCE:=0 in the package's Makefile would be more appropriate? > -SET_SOURCE_FILES_PROPERTIES(${JTEN_DIR}/jitterentropy-base.c PROPERTIES COMPILE_FLAGS -O0) > +SET_SOURCE_FILES_PROPERTIES(${JTEN_DIR}/jitterentropy-base.c PROPERTIES COMPILE_FLAGS -O2) > +TARGET_LINK_LIBRARIES(urngd pthread) > > INSTALL(TARGETS urngd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) >
Hi, On Sat, 16 Sept 2023 at 05:57, Chukun Pan <amadeus@jmu.edu.cn> wrote: > > When compiling with glibc it will result in error: > 1. #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > Fix this by compiling with optimization (-O2) by default. > > 2. jitterentropy-base.c:(.text+0x39f8): undefined reference to `pthread_join' > Fix this by always linking pthread. > > Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn> > --- > CMakeLists.txt | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/CMakeLists.txt b/CMakeLists.txt > index a1ee0c1..20f4774 100644 > --- a/CMakeLists.txt > +++ b/CMakeLists.txt > @@ -23,7 +23,8 @@ ADD_EXECUTABLE(urngd > TARGET_LINK_LIBRARIES(urngd ${ubox}) > > # jitter RNG must not be compiled with optimizations > -SET_SOURCE_FILES_PROPERTIES(${JTEN_DIR}/jitterentropy-base.c PROPERTIES COMPILE_FLAGS -O0) > +SET_SOURCE_FILES_PROPERTIES(${JTEN_DIR}/jitterentropy-base.c PROPERTIES COMPILE_FLAGS -O2) As mentioned by Andre, -O0 is intentional. Instead, try adding -U_FORTIFY_SOURCE which disables it for this unit only. For both glibc and musl, optimizatios need to be enabled for fortify source to do anything, but only glibc warns about it, so disabling it for this unit shouldn't change the generated code at all, just silence the warning for glibc. Regards, Jonas
On 16.09.2023 05:55, Chukun Pan wrote: > When compiling with glibc it will result in error: > 1. #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > Fix this by compiling with optimization (-O2) by default. > > 2. jitterentropy-base.c:(.text+0x39f8): undefined reference to `pthread_join' > Fix this by always linking pthread. Others already said we can't switch to -O2, I'll just add some references. At some point jitterentropy-library switched from -O0 to -O2: 3130cd99d7fa ("replace LSFR with SHA-3 256") https://github.com/smuellerDD/jitterentropy-library/commit/3130cd99d7fa308c00cc2c4be6c5aa20c002be56 That was however explicitly changed back later with the: 20184e97af8f ("Compile Jitter RNG without optimizations") https://github.com/smuellerDD/jitterentropy-library/commit/20184e97af8f227cc0787c4155ff4f3b2b7f1fe3 Also jitterentropy-rngd uses -O0: f1bc39ae713a ("use -O0") https://github.com/smuellerDD/jitterentropy-rngd/commit/f1bc39ae713a253077b0c47b4a1ad53f32bbfce0
diff --git a/CMakeLists.txt b/CMakeLists.txt index a1ee0c1..20f4774 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,8 @@ ADD_EXECUTABLE(urngd TARGET_LINK_LIBRARIES(urngd ${ubox}) # jitter RNG must not be compiled with optimizations -SET_SOURCE_FILES_PROPERTIES(${JTEN_DIR}/jitterentropy-base.c PROPERTIES COMPILE_FLAGS -O0) +SET_SOURCE_FILES_PROPERTIES(${JTEN_DIR}/jitterentropy-base.c PROPERTIES COMPILE_FLAGS -O2) +TARGET_LINK_LIBRARIES(urngd pthread) INSTALL(TARGETS urngd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
When compiling with glibc it will result in error: 1. #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] Fix this by compiling with optimization (-O2) by default. 2. jitterentropy-base.c:(.text+0x39f8): undefined reference to `pthread_join' Fix this by always linking pthread. Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn> --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)