Enable Dwarf2 debug information in offline assembler for clang compiler
authormsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 May 2016 01:06:59 +0000 (01:06 +0000)
committermsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 May 2016 01:06:59 +0000 (01:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157364.

Reviewed by Mark Lam.

Added a new function shouldEnableDebugAnnotations() that determines if
we are using clang and a new enough version to support the debug annotations.

* offlineasm/config.rb:
(shouldEnableDebugAnnotations): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200447 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/offlineasm/config.rb

index ec4166c..46dcdb7 100644 (file)
@@ -1,3 +1,16 @@
+2016-05-04  Michael Saboff  <msaboff@apple.com>
+
+        Enable Dwarf2 debug information in offline assembler for clang compiler
+        https://bugs.webkit.org/show_bug.cgi?id=157364.
+
+        Reviewed by Mark Lam.
+
+        Added a new function shouldEnableDebugAnnotations() that determines if
+        we are using clang and a new enough version to support the debug annotations.
+
+        * offlineasm/config.rb:
+        (shouldEnableDebugAnnotations): Added.
+
 2016-05-04  Keith Miller  <keith_miller@apple.com>
 
         Unreviewed, fix test for new ArrayIteratorPrototype.next() error message.
index 468c5cd..cfbd3cb 100644 (file)
@@ -59,4 +59,25 @@ $enableInstrAnnotations = false
 # Turns on generation of DWARF2 debug annotions for file and line numbers.
 # Allows for source level debuging of the original .asm files in a debugger.
 #
-$enableDebugAnnotations = false
+def shouldEnableDebugAnnotations()
+    if ENV['GCC_VERSION'] =~ /\.clang\./ and ENV['TOOLCHAIN_DIR'] != ''
+        clangExecutable = ENV['TOOLCHAIN_DIR'] + '/usr/bin/clang'
+        if File.executable?(clangExecutable)
+            clangVersionOut = %x`#{clangExecutable} --version`
+            if ($? == 0)
+                # clang version 800.0.12 or higher is required for debug annotations
+                versionMatch = /clang-(\d+).(\d+).(\d+)/.match(clangVersionOut)
+                if versionMatch.length >= 4
+                    totalVersion = versionMatch[1].to_i * 1000000 + versionMatch[2].to_i * 1000 + versionMatch[3].to_i
+                    if totalVersion >= 800000012
+                        return true
+                    end
+                end
+            end
+        end
+    end
+
+    false
+end
+
+$enableDebugAnnotations = shouldEnableDebugAnnotations()