configure/Makefile: add option to generate pdb symbols
authorSitsofe Wheeler <sitsofe@yahoo.com>
Fri, 21 Aug 2020 19:35:03 +0000 (20:35 +0100)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Sat, 12 Sep 2020 10:54:18 +0000 (11:54 +0100)
Recent versions of Windows clang and LLVM's lld have the ability to
build Windows PDB symbols for debugging so add an explicit option to
test for support and use it so.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Makefile
configure
os/windows/dobuild.cmd
os/windows/install.wxs

index b00daca2581ce273cde82924f0c4e3124d5c20b9..cc5727c3c204cd4943e2099b8614a9c8e36d9cb0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,12 @@ ifdef CONFIG_BUILD_NATIVE
   CFLAGS := -march=native $(CFLAGS)
 endif
 
+ifdef CONFIG_PDB
+  LINK_PDBFILE ?= -Wl,-pdb,$(dir $@)/$(basename $(@F)).pdb
+  CFLAGS := -gcodeview $(CFLAGS)
+  LDFLAGS += -fuse-ld=lld $(LINK_PDBFILE)
+endif
+
 ifdef CONFIG_GFIO
   PROGS += gfio
 endif
index 434336573d97012b6ea67efb263de543ed87bf44..355b69582714675c3421567406ea07da71376e77 100755 (executable)
--- a/configure
+++ b/configure
@@ -193,6 +193,8 @@ for opt do
   ;;
   --target-win-ver=*) target_win_ver="$optarg"
   ;;
+  --enable-pdb) pdb="yes"
+  ;;
   --build-static) build_static="yes"
   ;;
   --enable-gfio) gfio_check="yes"
@@ -256,6 +258,7 @@ if test "$show_help" = "yes" ; then
   echo "--extra-cflags=         Specify extra CFLAGS to pass to compiler"
   echo "--build-32bit-win       Enable 32-bit build on Windows"
   echo "--target-win-ver=       Minimum version of Windows to target (XP or 7)"
+  echo "--enable-pdb            Enable Windows PDB symbols generation (needs clang/lld)"
   echo "--build-static          Build a static fio"
   echo "--esx                   Configure build options for esx"
   echo "--enable-gfio           Enable building of gtk gfio"
@@ -2702,6 +2705,27 @@ if compile_prog "" "" "statx_syscall"; then
 fi
 print_config "statx(2)/syscall" "$statx_syscall"
 
+##########################################
+# check for Windows PDB generation support
+if test "pdb" != "no" ; then
+  cat > $TMPC <<EOF
+int main(void)
+{
+  return 0;
+}
+EOF
+  if compile_prog "-g -gcodeview" "-fuse-ld=lld -Wl,-pdb,$TMPO" "pdb"; then
+    pdb=yes
+  else
+    if test "$pdb" = "yes"; then
+      feature_not_found "PDB" "clang and lld"
+    fi
+    pdb=no
+  fi
+else
+  pdb=no
+fi
+print_config "Windows PDB generation" "$pdb"
 #############################################################################
 
 if test "$wordsize" = "64" ; then
@@ -3024,6 +3048,10 @@ fi
 if test "$dynamic_engines" = "yes" ; then
   output_sym "CONFIG_DYNAMIC_ENGINES"
 fi
+if test "$pdb" = yes; then
+  output_sym "CONFIG_PDB"
+fi
+
 print_config "Lib-based ioengines dynamic" "$dynamic_engines"
 cat > $TMPC << EOF
 int main(int argc, char **argv)
index d06a2afab5d8607e36b8f75fa32d01c87d388389..08df3e876da6d3f761ba5ca5d335428bbbd2be71 100644 (file)
@@ -34,7 +34,13 @@ if defined SIGN_FIO (
   signtool sign /as /n "%SIGNING_CN%" /tr http://timestamp.digicert.com /td sha256 /fd sha256 ..\..\t\*.exe\r
 )\r
 \r
-"%WIX%bin\candle" -nologo -arch %FIO_ARCH% -dFioVersionNumbers="%FIO_VERSION_NUMBERS%" install.wxs\r
+if exist ..\..\fio.pdb (\r
+  set FIO_PDB=true\r
+) else (\r
+  set FIO_PDB=false\r
+)\r
+\r
+"%WIX%bin\candle" -nologo -arch %FIO_ARCH% -dFioVersionNumbers="%FIO_VERSION_NUMBERS%" -dFioPDB="%FIO_PDB%" install.wxs\r
 @if ERRORLEVEL 1 goto end\r
 "%WIX%bin\candle" -nologo -arch %FIO_ARCH% examples.wxs\r
 @if ERRORLEVEL 1 goto end\r
@@ -43,4 +49,4 @@ if defined SIGN_FIO (
 \r
 if defined SIGN_FIO (\r
   signtool sign /n "%SIGNING_CN%" /tr http://timestamp.digicert.com /td sha256 /fd sha256 %FIO_VERSION%-%FIO_ARCH%.msi\r
-)
\ No newline at end of file
+)\r
index dcb8c92c4a3bcef5240036a5c565d8a742c27819..f73ec5e2517487f3623dfbbccf37aa5567d0792e 100755 (executable)
                                                        <File Source="..\..\fio.exe"/>
                                                        <Environment Action="set" Part="last" Id="PATH" Name="PATH" Value="[INSTALLDIR]fio\" System="yes"/>
                                                </Component>
+                                               <?if $(var.FioPDB) = true?>
+                                               <Component>
+                                                       <File Id="fio.pdb" Name="fio.pdb" Source="..\..\fio.pdb"/>
+                                               </Component>
+                                               <?endif?>
                                                <Component>
                                                        <File Id="README" Name="README.txt" Source="..\..\README"/>
                                                </Component>
@@ -76,6 +81,9 @@
 
        <Feature Id="AlwaysInstall" Absent="disallow" ConfigurableDirectory="INSTALLDIR" Display="hidden" Level="1" Title="Flexible I/O Tester">
                <ComponentRef Id="fio.exe"/>
+               <?if $(var.FioPDB) = true?>
+               <ComponentRef Id="fio.pdb"/>
+               <?endif?>
                <ComponentRef Id="HOWTO"/>
                <ComponentRef Id="README"/>
                <ComponentRef Id="REPORTING_BUGS"/>