diff --git a/SConstruct b/SConstruct
index fd1a7e3eb6c35e126fdd3361a175bd0dc6ee97a0..7979b3393d58e2fef09992d8626d3ba2960f6839 100644
--- a/SConstruct
+++ b/SConstruct
@@ -73,6 +73,12 @@ AddOption('--coverage',
           action='store_true',
           help='Build with coverage instrumentation')
 
+AddOption('--force-debug',
+          dest='force_debug',
+          default=False,
+          action='store_true',
+          help='Build with debug symbols, even in the opt variant')
+
 AddOption('--gprof',
           dest='gprof',
           default=False,
@@ -135,6 +141,12 @@ if GetOption('coverage'):
     else:
         env.ParseConfig('llvm-config --ldflags')
 
+if GetOption('force_debug'):
+    if env['CC'] == 'cl':
+        env.Append(CCFLAGS=['/Z7'])
+    else:
+        env.Append(CCFLAGS=['-g'])
+
 if GetOption('gprof'):
     if env['CC'] == 'gcc' and env['CXX'] == 'g++':
         env.Append(CCFLAGS=['-pg'],