Bug 157364 - Enable Dwarf2 debug information in offline assembler for clang compiler
Summary: Enable Dwarf2 debug information in offline assembler for clang compiler
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-05-04 15:48 PDT by Michael Saboff
Modified: 2016-05-09 07:56 PDT (History)
8 users (show)

See Also:


Attachments
Patch (2.18 KB, patch)
2016-05-04 16:39 PDT, Michael Saboff
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2016-05-04 15:48:30 PDT
Change set r196541 added the output of Dwarf2 debugging directives to the offline assembler, but disabled the feature until the appropriate support was added to the C++ compiler.  That support was added to Clang version 800.0.12 and later.

We should detect that we're compiling with the appropriate clang compiler version and enable the output of the Dwarf2 directives.
Comment 1 Radar WebKit Bug Importer 2016-05-04 15:50:11 PDT
<rdar://problem/26100879>
Comment 2 Michael Saboff 2016-05-04 16:39:30 PDT
Created attachment 278143 [details]
Patch
Comment 3 Mark Lam 2016-05-04 16:42:11 PDT
Comment on attachment 278143 [details]
Patch

rs=me
Comment 4 WebKit Commit Bot 2016-05-04 18:06:21 PDT
Comment on attachment 278143 [details]
Patch

Clearing flags on attachment: 278143

Committed r200447: <http://trac.webkit.org/changeset/200447>
Comment 5 WebKit Commit Bot 2016-05-04 18:06:25 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 mitz 2016-05-04 20:15:08 PDT
Comment on attachment 278143 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278143&action=review

> Source/JavaScriptCore/offlineasm/config.rb:66
> +        clangExecutable = ENV['TOOLCHAIN_DIR'] + '/usr/bin/clang'
> +        if File.executable?(clangExecutable)
> +            clangVersionOut = %x`#{clangExecutable} --version`

The canonical way to find and invoke clang from a script running in Xcode would be simply `xcrun clang --version`
Comment 7 Csaba Osztrogonác 2016-05-05 03:54:27 PDT
(In reply to comment #4)
> Comment on attachment 278143 [details]
> Patch
> 
> Clearing flags on attachment: 278143
> 
> Committed r200447: <http://trac.webkit.org/changeset/200447>

It broke the Apple Mac Yosemite build:
(see build.webkit.org for details)

/Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/config.rb:64:in `shouldEnableDebugAnnotations': undefined method `+' for nil:NilClass (NoMethodError)
	from /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/config.rb:83:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/generate_offset_extractor.rb:28:in `<main>'
Command /bin/sh failed with exit code 1
Comment 8 Csaba Osztrogonác 2016-05-05 04:03:41 PDT
Comment on attachment 278143 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278143&action=review

> Source/JavaScriptCore/offlineasm/config.rb:74
> +                # 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

It is not platform independent at all, it is a Mac only code.
There is no GCC_VERSION, no TOOLCHAIN_DIR on non Mac platforms, 
no similar clang versions like this.

Some Linux examples for clang --version.

$ clang --version
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix

$ clang --version
Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
Comment 9 Csaba Osztrogonác 2016-05-05 07:51:18 PDT
(In reply to comment #7)
> (In reply to comment #4)
> > Comment on attachment 278143 [details]
> > Patch
> > 
> > Clearing flags on attachment: 278143
> > 
> > Committed r200447: <http://trac.webkit.org/changeset/200447>
> 
> It broke the Apple Mac Yosemite build:
> (see build.webkit.org for details)
> 
> /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/
> config.rb:64:in `shouldEnableDebugAnnotations': undefined method `+' for
> nil:NilClass (NoMethodError)
> 	from
> /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/
> config.rb:83:in `<top (required)>'
> 	from
> /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/
> rubygems/core_ext/kernel_require.rb:55:in `require'
> 	from
> /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/
> rubygems/core_ext/kernel_require.rb:55:in `require'
> 	from
> /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/
> generate_offset_extractor.rb:28:in `<main>'
> Command /bin/sh failed with exit code 1

After checking the Yosemite build logs, it seems 
there is no TOOLCHAIN_DIR env, only DT_TOOLCHAIN_DIR.
Comment 10 mitz 2016-05-05 08:21:35 PDT
(In reply to comment #9)
> (In reply to comment #7)
> > (In reply to comment #4)
> > > Comment on attachment 278143 [details]
> > > Patch
> > > 
> > > Clearing flags on attachment: 278143
> > > 
> > > Committed r200447: <http://trac.webkit.org/changeset/200447>
> > 
> > It broke the Apple Mac Yosemite build:
> > (see build.webkit.org for details)
> > 
> > /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/
> > config.rb:64:in `shouldEnableDebugAnnotations': undefined method `+' for
> > nil:NilClass (NoMethodError)
> > 	from
> > /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/
> > config.rb:83:in `<top (required)>'
> > 	from
> > /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/
> > rubygems/core_ext/kernel_require.rb:55:in `require'
> > 	from
> > /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/
> > rubygems/core_ext/kernel_require.rb:55:in `require'
> > 	from
> > /Volumes/Data/slave/yosemite-release/build/Source/JavaScriptCore/offlineasm/
> > generate_offset_extractor.rb:28:in `<main>'
> > Command /bin/sh failed with exit code 1
> 
> After checking the Yosemite build logs, it seems 
> there is no TOOLCHAIN_DIR env, only DT_TOOLCHAIN_DIR.

Relying on either variable, or on the path to clang relative to it, isn’t the right thing to do. As I’ve mentioned above, xcrun is the right way to invoke clang. If this script is shared with non-Xcode build systems, then it’s probably best for the script itself to use the CC environment variable, and for the Xcode script build phase that invokes it to set that variable (if not already set) to the output of "xcrun -find clang".
Comment 11 Michael Saboff 2016-05-05 09:35:59 PDT
Looking at the build breakage now.
Comment 12 Michael Saboff 2016-05-05 10:15:15 PDT
Landed build fix in change set r200458: <http://trac.webkit.org/changeset/200458>
Comment 13 Michael Saboff 2016-05-05 10:16:33 PDT
(In reply to comment #8)
> Comment on attachment 278143 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=278143&action=review
> 
> > Source/JavaScriptCore/offlineasm/config.rb:74
> > +                # 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
> 
> It is not platform independent at all, it is a Mac only code.
> There is no GCC_VERSION, no TOOLCHAIN_DIR on non Mac platforms, 
> no similar clang versions like this.
> 
> Some Linux examples for clang --version.
> 
> $ clang --version
> Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
> Target: x86_64-pc-linux-gnu
> Thread model: posix
> 
> $ clang --version
> Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
> Target: x86_64-pc-linux-gnu
> Thread model: posix

I intended the change to be Mac only.  I have no way of determining what Linux clang versions have the multiple .file directives fix.
Comment 14 Michael Saboff 2016-05-05 10:27:07 PDT
(In reply to comment #13)

> I intended the change to be Mac only.  I have no way of determining what
> Linux clang versions have the multiple .file directives fix.

Please add Linux clang specific check.  You'll need to figure out the first clang version that has the fix given at http://reviews.llvm.org/D16101.
Comment 15 Alexey Proskuryakov 2016-05-08 09:29:05 PDT
Can this be detected by a feature check, instead of a version check?

It's not clear from the bug what the failure mode was.
Comment 16 Michael Saboff 2016-05-09 07:56:24 PDT
(In reply to comment #15)
> Can this be detected by a feature check, instead of a version check?
> 
> It's not clear from the bug what the failure mode was.

Without the clang fix, clang will crash with the directives this change produces.  There isn't a feature check in clang for the change.