Add --profile waf option so frame pointer isn't omitted in optimized builds
authorTim Mayberry <mojofunk@gmail.com>
Tue, 27 Oct 2015 11:26:12 +0000 (21:26 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Tue, 17 Nov 2015 23:38:18 +0000 (09:38 +1000)
wscript

diff --git a/wscript b/wscript
index b864d95464f42e3e36175d6985f0d632d48bc806..9ef5ab7e36d23dacf0b683666ec1fba810e33767 100644 (file)
--- a/wscript
+++ b/wscript
@@ -40,8 +40,10 @@ compiler_flags_dictionaries= {
         'linker-debuggable' : '',
         # Flags required when building a non-debug optimized build
         'nondebuggable' : '-DNDEBUG',
-        # Flags required to enable profiling at runtime
-        'profile' : '-pg',
+        # Flags required to enable profiling at runtime with optimized builds
+        'profile' : [ '-fno-omit-frame-pointer' ],
+        # Flags required to enable gprofile profiling
+        'gprofile' : '-pg',
         # Flags required to disable warnings about unused arguments to function calls
         'silence-unused-arguments' : '',
         # Flags required to use SSE unit for general math
@@ -89,7 +91,7 @@ compiler_flags_dictionaries= {
         'debuggable' : ['/DDEBUG', '/Od', '/Zi', '/MDd', '/Gd', '/EHsc'],
         'linker-debuggable' : ['/DEBUG', '/INCREMENTAL' ],
         'nondebuggable' : ['/DNDEBUG', '/Ob1', '/MD', '/Gd', '/EHsc'],
-        'profile' : '',
+        'profile' : '/Oy-',
         'sse' : '/arch:SSE',
         'silence-unused-arguments' : '',
         'sse' : '',
@@ -332,7 +334,7 @@ int main() { return 0; }''',
         linker_flags.append('-fsanitize=address')
 
     if opt.gprofile:
-        debug_flags = [ flags_dict['profile'] ]
+        debug_flags = [ flags_dict['gprofile'] ]
 
     # OSX
     if platform == 'darwin':
@@ -545,6 +547,9 @@ int main() { return 0; }''',
     if opt.debug_symbols:
         optimization_flags += flags_dict['debuggable']
 
+    if opt.profile:
+        optimization_flags += flags_dict['profile']
+
     if opt.stl_debug:
         cxx_flags.append("-D_GLIBCXX_DEBUG")
 
@@ -646,6 +651,8 @@ def options(opt):
                     help='Build MIME type and .desktop files as per freedesktop.org standards (will be placed in build/gtk2_ardour)')
     opt.add_option('--freebie', action='store_true', default=False, dest='freebie',
                     help='Build a version suitable for distribution as a zero-cost binary')
+    opt.add_option('--profile', action='store_true', default=False, dest='profile',
+                    help='Compile for use with profiling tools requiring a frame pointer')
     opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
                     help='Compile for use with gprofile')
     opt.add_option('--libjack', type='string', default="auto", dest='libjack_link',