Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install dSYM debug information for macOS #4310

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dylanahsmith
Copy link
Contributor

@dylanahsmith dylanahsmith commented Mar 22, 2021

Problem

On macOS, ruby reads the debug information from a *.dSYM directory corresponding to get a C source file and line number on a backtrace. Although ruby.dSYM was getting generated in the build directory, it wasn't getting installed along with the ruby binary. Also, native extensions neither had the *.dSYM directories generated or installed.

For example, try using this from an installed version of ruby on macOS

ruby -r bigdecimal -e 'BigDecimal.save_exception_mode { Process.kill("SEGV", Process.pid) }' 2>&1 | grep -A1 BigDecimal_save_exception_mode
/Users/dylants/.rubies/ruby-master/lib/ruby/3.1.0/x86_64-darwin20/bigdecimal.bundle(BigDecimal_save_exception_mode+0x6b) [0x11200323b]
/Users/dylants/.rubies/ruby-master/bin/ruby(vm_call_cfunc_with_frame+0x14f) [0x10e73d0af]

Gems installed through gem install or bundle install had the same problem.

Solution

I used the feature detection configure.ac does to detect if the dsymutil program is present on the darwin platform to conditionally generate this debug information (as part of POSTLINK) and install the generated *.dSYM directories.

I tested on macOS and linux for installing ruby and a gem with a native extension through both gem install and bundle install and testing cleaning make clean and gem uninstall. It seems to work as expected with these changes.

For example, I get the following output now from the above SEGV test within BigDecimal.save_exception_mode

/Users/dylants/.rubies/ruby-dev/lib/ruby/3.1.0/x86_64-darwin20/bigdecimal.bundle(BigDecimal_save_exception_mode+0x6b) [0x107b7323b] ../../../ext/bigdecimal/bigdecimal.c:3239
/Users/dylants/.rubies/ruby-dev/lib/ruby/3.1.0/x86_64-darwin20/bigdecimal.bundle(BigDecimal_save_exception_mode) (null):0
/Users/dylants/src/ruby/build-dev/./ruby(vm_call_cfunc_with_frame+0x14f) [0x1042b50af] ../vm_insnhelper.c:2924

@dylanahsmith dylanahsmith force-pushed the dsym-install branch 2 times, most recently from 1aef360 to deb5b93 Compare March 25, 2021 18:57
@@ -1422,11 +1422,6 @@ def test_find_lib_file_after_install
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
require "mkmf"

CONFIG['CC'] = '$(TOUCH) $@ ||'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to remove these compiler stubs, since it would otherwise try to use dsymutil on the empty files created from touch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubygems might not assume the compiler, why not remove CONFIG['dsymutil'] instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failures seem coming from codesign, and this file won't need changes after 8a89dd2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubygems might not assume the compiler, why not remove CONFIG['dsymutil'] instead?

Handling CC not referencing a C compiler when compiling a C compiler seems overly contrived. There should be no need to remove CONFIG['dsymutil'], since the configure script should leave it blank on platforms where it isn't available. Besides, the CI tests are passing on all platforms as it is now.

The failures seem coming from codesign, and this file won't need changes after 8a89dd2.

By failures I guess you mean from you running the tests locally with the RUBY_CODESIGN environment variable set. Thanks for catching that, I didn't realize that would cause the test to fail.

@@ -1435,7 +1430,6 @@ def test_find_lib_file_after_install

write_file File.join(@tempdir, "a.c") do |io|
io.write <<-C
#include <ruby.h>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed and was causing problems without ruby installed, since it wasn't able to find the ruby/config.h header, since it wasn't finding it where it gets installed. So I removed it to avoid breaking this test.

tool/rbinstall.rb Outdated Show resolved Hide resolved
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
@ruby ruby deleted a comment Mar 27, 2021
@ruby ruby deleted a comment Mar 27, 2021
@ruby ruby deleted a comment Mar 27, 2021
@ruby ruby deleted a comment Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants