bug-make
[Top][All Lists]
Advanced

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

[bug #63310] configure: unexpected CPPFLAGS effect on C compiler options


From: Pekka S
Subject: [bug #63310] configure: unexpected CPPFLAGS effect on C compiler options check
Date: Thu, 3 Nov 2022 09:47:48 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?63310>

                 Summary: configure: unexpected CPPFLAGS effect on C compiler
options check
                 Project: make
               Submitter: pexu
               Submitted: Thu 03 Nov 2022 01:47:46 PM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.4
        Operating System: Any
           Fixed Release: None
           Triage Status: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Thu 03 Nov 2022 01:47:46 PM UTC By: Pekka S <pexu>
Hi.

In order to determine the warning flags that the C compiler supports configure
for GNU make 4.4 (lines 7887...7966) currently preprocesses ($CC -E) a stub
program, then discards any lines that begin with `#' (grep -v) and finally
picks up all remaining words.

Here's an excerpt from the `conftest.c' that is fed to C preprocessor:

7937:      #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ +
(__clang_minor__ >= 9) > 3)
7938:      -Wno-float-conversion
7938:      #endif


The expected preprocessed source might then look like:

# 0 "<command-line>" 2
# 1 "conftest.c"
# 2 "conftest.c"
        -Wno-float-conversion


The issue here is that the user might pass in CPPFLAGS (or CFLAGS, for that
matter), say `-include header.h', that cause additional preprocessed output. 
In that case unfortunately all output from these unexpected sources
(statements and such) is added to GL_CFLAG_GNULIB_WARNINGS as well, likely
causing problems downstream.

The difficulty here is that there is no good way of detecting (as it stands
now) that `confest.c' is being preprocessed.  The least problematic might be
to check `#if __has_include(<confest.c>) /* ... */'.

One possibility to overcome this would be to use e.g. sed or awk.  Change the
interesting lines to e.g. ``#pragma MAKE GL_CFLAG_GNULIB_WARNINGS
"-Wno-float-conversion"'' and pick up the inresting part,
`-Wno-float-conversion', with a suitable regular expression pattern.  This way
the output should be also more inline with C standard (unless there's some
compiler that is really picky about unknown pragmas at early stages).

Of course, the super easy way is just to use `grep --
^[[:space:]]*-W[[:alpha:]][[:alpha:]-]*' instead of the current negative form.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63310>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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