[PATCH] configure.ac: allow expressing dwarf version in CFLAGS and CROSSCFLAGS

Eric Pouech eric.pouech at gmail.com
Tue Nov 2 03:45:29 CDT 2021


usage:
     configure CFLAGS="-gdwarf-4 -O2"
   will enable dwarf4 compilation for ELF parts
   (and CROSSCFLAGS="-gdwarf-4 -O2" for PE parts)

evolution from current behavior:
- when CFLAGS contains "-gdwarf-X", -gdwarf-X option is not tested with
  WINE_TRY_CFLAGS (the option remains anyway in CFLAGS -so WINE_TRY is
  useless- and is not copied in EXTRACFLAGS) (ditto for CROSSCFLAGS)
- using CROSSCFLAGS=-gdwarf is no longer converted to Wine's default
  format, but is kepts as is, hence will boil down to compiler's
  preferred dwarf version
- CROSSDEBUG=split used to pick up compiler's default format
  (while CROSSDEBUG=split-dwarf picked up wine's default format).
  They both now pick up the format derived from or specified in
  CROSSCLAGS (if any)

what remains undone (and could be improved):
- no test that the final configuration is suitable for Wine (ie
  if WINE_TRY_CFLAGS fails on -gdwarf-2, compilation is done with
  compilers's default format => dwarf5 on Linux)

Changes from previous version:
- fixed handling of "-g -gcodeview" in CROSSCFLAGS
- fixed CROSSDEBUG=split* (mixup between split-dwarf and dwarf-split)

open question:
- I kept the original behavior, when providing as configure args (and
    not providing CROSSCFLAGS in configure args):
    CROSSDEBUG=pdb
  to add -gcodeview to EXTRACROSSCFLAGS
  It could be simplified with no longer supporting CROSSDEBUG from
  command line, but:
  + set CROSSDEBUG=pdb in configure when -gcodeview
    option is present is CROSSCFLAGS
  + set CROSSDEBUG=split in configure when -gsplit-dwarf
    option is present is CROSSCFLAGS

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 configure.ac |   40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7c1e446814b..99347813a13 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1008,21 +1008,24 @@ then
 
         dnl Determine debug info format
         AC_SUBST(CROSSDEBUG)
-        if test -z "$CROSSDEBUG"
+        ac_debug_format_seen=
+        for ac_flag in $CROSSCFLAGS; do
+          case $ac_flag in
+            -gdwarf*)    ac_debug_format_seen=yes ;;
+            -g)          ac_debug_format_seen=${ac_debug_format_seen:-default} ;;
+            -gcodeview)  ac_debug_format_seen=yes ;;
+          esac
+        done
+        if test "x$ac_debug_format_seen" = "xdefault" -a "x$CROSSDEBUG" = "xpdb"
         then
-          for ac_flag in $CROSSCFLAGS; do
-            case $ac_flag in
-             -gdwarf*)    CROSSDEBUG=dwarf ;;
-             -gcodeview)  CROSSDEBUG=pdb ;;
-             -g)          CROSSDEBUG=${CROSSDEBUG:-dwarf} ;;
-            esac
-          done
+          WINE_TRY_CROSSCFLAGS([-gcodeview])
+          ac_debug_format_seen=yes
+        fi
+        if test "x$ac_debug_format_seen" = "xdefault"
+        then
+          WINE_TRY_CROSSCFLAGS([-gdwarf-2])
+          WINE_TRY_CROSSCFLAGS([-gstrict-dwarf])
         fi
-        case $CROSSDEBUG in
-          *dwarf)  WINE_TRY_CROSSCFLAGS([-gdwarf-2])
-                   WINE_TRY_CROSSCFLAGS([-gstrict-dwarf]) ;;
-          pdb)     WINE_TRY_CROSSCFLAGS([-gcodeview]) ;;
-        esac
 
         WINE_TRY_CROSSCFLAGS([-fexcess-precision=standard],[AC_SUBST(EXCESS_PRECISION_CFLAGS,"-fexcess-precision=standard")])
 
@@ -1822,13 +1825,18 @@ char*f(const char *h,char n) {return strchr(h,n);}]])],[ac_cv_c_logicalop_noisy=
       *) EXTRACFLAGS="$EXTRACFLAGS $wine_cv_64bit_compare_swap" ;;
   esac
 
-  dnl Default to dwarf-2 debug info
+  dnl Determine debug info format
+  ac_debug_format_seen=
   for ac_flag in $CFLAGS; do
     case $ac_flag in
-      -g) WINE_TRY_CFLAGS([-gdwarf-2])
-          WINE_TRY_CFLAGS([-gstrict-dwarf]) ;;
+      -gdwarf*)    ac_debug_format_seen=yes ;;
+      -g)          ac_debug_format_seen=${ac_debug_format_seen:-default} ;;
     esac
   done
+  if test "x$ac_debug_format_seen" = "xdefault"; then
+    WINE_TRY_CFLAGS([-gdwarf-2])
+    WINE_TRY_CFLAGS([-gstrict-dwarf])
+  fi
 
   dnl Disable gcc builtins except for Mingw
   AC_SUBST(MSVCRTFLAGS,"")




More information about the wine-devel mailing list