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

Strip cross built shared library files while linking #165

Merged
merged 1 commit into from Dec 27, 2019

Conversation

larskanis
Copy link
Member

The .so files of extensions are often manually stripped after compilation per task in a Rakefile. This is done to reduce gem size and because debug information in release binaries isn't particular useful.

This manual step can be avoided, if the cross ruby version is built with stripping enabled. Compatibility is ensured, since stripping files a second time doesn't make a difference.

The .so files of extensions are often manually stripped after compilation per task in a Rakefile.
This is done to reduce gem size and because debug information in release binaries isn't particular useful.
This manual step can be avoided, if the cross ruby version is built with stripping enabled.
Compatibility is ensured, since stripping files a second time doesn't make a difference.
@kou kou merged commit 2079532 into rake-compiler:master Dec 27, 2019
@kou
Copy link
Member

kou commented Dec 27, 2019

Merged but I have one concern.

Stripping libruby.so for cross compile is no problem. Because it's not used in production.
But stripping .so of gems may not be good. If we always strip .so of gems, stack trace on SEGV will not show symbols of .so of gems. It may be difficult to debug by gem developers.

@larskanis
Copy link
Member Author

Sure, that's the downside, however all extensions compiled with recent RubyInstallers are stripped equally anyway (since oneclick/rubyinstaller2#130 ). The stacktrace on Windows still shows the related DLL and the called function like so:

C:\Users\Administrator\tmp>ruby segfault.rb
segfault.rb:6: [BUG] Segmentation fault
ruby 2.6.4p104 (2019-08-28 revision 67798) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:0003 p:---- s:0013 e:000012 CFUNC  :call
c:0002 p:0068 s:0008 E:001470 EVAL   segfault.rb:6 [FINISH]
c:0001 p:0000 s:0003 E:000b70 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
segfault.rb:6:in `<main>'
segfault.rb:6:in `call'

-- C level backtrace information -------------------------------------------
C:\Windows\SYSTEM32\ntdll.dll(ZwWaitForSingleObject+0x14) [0x00007ff9e6715b84]
C:\Windows\System32\KERNELBASE.dll(WaitForSingleObjectEx+0x8f) [0x00007ff9e39d3eef]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_vm_bugreport+0x2eb) [0x000000006a680abb]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_bug_context+0x70) [0x000000006a4ce9b0]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_check_safe_obj+0x4d0) [0x000000006a5e44b0]
 [0x00000000004022d2]
C:\Windows\SYSTEM32\ntdll.dll(_C_specific_handler+0x96) [0x00007ff9e6706606]
C:\Windows\SYSTEM32\ntdll.dll(_chkstk+0x11d) [0x00007ff9e671a57d]
C:\Windows\SYSTEM32\ntdll.dll(RtlImageNtHeaderEx+0x483) [0x00007ff9e66afd23]
C:\Windows\SYSTEM32\ntdll.dll(KiUserExceptionDispatcher+0x3a) [0x00007ff9e67196ea]
C:\Windows\System32\msvcrt.dll(ungetwc+0x222) [0x00007ff9e3e7f3c2]
C:\Windows\System32\msvcrt.dll(printf+0x82) [0x00007ff9e3e789d2]
C:\Ruby26-x64\bin\ruby_builtin_dlls\libffi-6.dll(ffi_call_win64+0x97) [0x000000006b744797]
C:\Ruby26-x64\bin\ruby_builtin_dlls\libffi-6.dll(ffi_call+0x47) [0x000000006b7443a7]
C:\Ruby26-x64\lib\ruby\2.6.0\x64-mingw32\fiddle.so(Init_fiddle+0xb28) [0x0000000063d82d98]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_thread_call_without_gvl+0x58) [0x000000006a62d8b8]
C:\Ruby26-x64\lib\ruby\2.6.0\x64-mingw32\fiddle.so(Init_fiddle+0xe3f) [0x0000000063d830af]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_error_arity+0x131) [0x000000006a65ddc1]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_vm_invoke_bmethod+0xd01) [0x000000006a668461]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_check_funcall+0xa02) [0x000000006a672f72]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_vm_exec+0x21f) [0x000000006a666aff]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_call_end_proc+0x15c) [0x000000006a4d28dc]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(ruby_run_node+0x59) [0x000000006a4d7139]
 [0x0000000000402b77]
 [0x000000000040138c]
 [0x00000000004014bb]
C:\Windows\System32\KERNEL32.DLL(BaseThreadInitThunk+0x14) [0x00007ff9e5e284d4]

@kou
Copy link
Member

kou commented Dec 28, 2019

Wow. It's interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants