libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Build failure with Link-Time Optimization


From: Evgeny Grin
Subject: Re: [libmicrohttpd] Build failure with Link-Time Optimization
Date: Wed, 27 Dec 2023 17:21:12 +0300
User-agent: Mozilla Thunderbird

I've re-checked again.
Tried on Mingw64/Msys2 and Debian SID.
Basic step:
./bootstrap

Then I tried:
./configure 'CFLAGS=-O3 -flto'

On Debian I also tried:
./configure 'CFLAGS=-O3 -flto' CC=gcc-12
./configure 'CFLAGS=-O3 -flto' CC=gcc-13
./configure 'CFLAGS=-O3 -flto' CC=clang-17

Tested with:
make -j8 check

Everything built just fine. No single warning.
Probably your toolchain/compiler/environment has too strict flags that create false positive warning, which is converted to error. I may also suggest to try with -Wno-error or -Wno-error=maybe-uninitialized flags.

What is the OS / distribution used?

--
Evgeny


On 27/12/2023 13:38, Sergey Sudnitsyn wrote:
Thank you.
I don't know what's so special about my setup - I am getting the same error with GCC 12 & 13 - compiling for both x86_64 & aarch64. Compiler flags - nothing unusual - -O3 -flto  - but maybe warnings are a bit overzealous (-Wuninitialized -Wstack-protector). I'll try producing a sample that reproduces this - and will use suggested workaround in the meantime.

On Tue, 26 Dec 2023 at 17:21, Evgeny Grin <k2k@yandex.ru <mailto:k2k@yandex.ru>> wrote:

    Hi Sergey,

    Are you using some special compiler or linker parameters? Some special
    compiler or linker versions?

    I regularly test MHD with LTO. I've retested the current git master
    with
    LTO and cannot reproduce.
    No errors, nor even warnings.

    If you check the code you will find that both mentioned variables are
    not used before initialisation. (Please provide the code path if I'm
    wrong).

    Unless variables are really used as uninitialised (which should be a
    bug
    and needs to be fixed), I'd avoid unneeded initialisation to save the
    code size (and negligible performance).

    If your compiler/linker complaint is false positive, you probably may
    workaround it with '-ftrivial-auto-var-init' parameter.

    Let me know the details, please.

-- Evgeny

    On 26/12/2023 16:14, Sergey Sudnitsyn wrote:
     > When LTO is enabled, linking fails complaining about potentially
     > uninitialized variables;
     > It's hard to provide a small sample reproducing this, but I hope the
     > patch can be applied even without it since it's innocent enough
    (diff
     > against commit 8bb481f ):
     >
     > diff --git a/src/microhttpd/connection.c
    b/src/microhttpd/connection.c
     > index f9892a55..e5dd1a45 100644
     > --- a/src/microhttpd/connection.c
     > +++ b/src/microhttpd/connection.c
     > @@ -653,7 +653,7 @@ MHD_connection_alloc_memory_ (struct
    MHD_Connection
     > *connection,
     >   {
     >     struct MHD_Connection *const c = connection; /* a short alias */
     >     struct MemoryPool *const pool = c->pool; /* a short alias */
     > - size_t need_to_be_freed; /**< The required amount of additional
    free
     > memory */
     > + size_t need_to_be_freed = 0; /**< The required amount of
    additional
     > free memory */
     >     void *res;
     >
     >     res = MHD_pool_try_alloc (pool, size, &need_to_be_freed);
     > @@ -4468,7 +4468,7 @@ process_request_body (struct MHD_Connection
     > *connection)
     >         { /* Need the parse the chunk size line */
     >           /** The number of found digits in the chunk size number */
     >           size_t num_dig;
     > - uint64_t chunk_size;
     > + uint64_t chunk_size = 0;
     >           bool broken;
     >           bool overflow;
     >

Attachment: OpenPGP_0x460A317C3326D2AE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]