[PATCH] urngd: fixes compilation with glibc

Jonas Gorski jonas.gorski at gmail.com
Sat Sep 16 01:59:59 PDT 2023


Hi,

On Sat, 16 Sept 2023 at 05:57, Chukun Pan <amadeus at 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 at 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



More information about the openwrt-devel mailing list