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

Fixes issue with linking lib_unwind on OpenBSD #5282

Merged
merged 2 commits into from Dec 2, 2017

Conversation

wmoxam
Copy link
Contributor

@wmoxam wmoxam commented Nov 12, 2017

Fixes #5280

I'm not sure but I think the problem may be related to OpenBSD's change of default compiler to Clang, and the update of LLVM to v5 in ports.

@@ -1,3 +1,6 @@
{% if flag?(:openbsd) %}
@[Link("stdc++")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that libunwind doesn't exist as a seperate library to libstdc++?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@ysbaddaden
Copy link
Contributor

Yes, switching from GCC to clang by default is probably the reason it broke.

I guess if you switch to GCC it links libgcc or something approaching. I'm not sure we have to link libstdc++. Maybe rely on libunwind?

@ysbaddaden
Copy link
Contributor

Looking at a binary linked on OpenBSD 6.0, I notice it linked to libestdc++. I don't know how it relates to libstdc++ thought.

@valpackett
Copy link
Contributor

On FreeBSD 12 (LLVM 5.0 in base), Crystal links to libc++, no libunwind:

/usr/local/bin/crystal:
        librt.so.1 => /usr/lib/librt.so.1 (0x802d83000)
        libncurses.so.8 => /lib/libncurses.so.8 (0x802f88000)
        libthr.so.3 => /lib/libthr.so.3 (0x8031dd000)
        libz.so.6 => /lib/libz.so.6 (0x803404000)
        libm.so.5 => /lib/libm.so.5 (0x80361d000)
        libc++.so.1 => /usr/lib/libc++.so.1 (0x80384a000)
        libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x803b16000)
        libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x803d34000)
        libgc-threaded.so.1 => /usr/local/lib/libgc-threaded.so.1 (0x803fab000)
        libevent-2.1.so.6 => /usr/local/lib/libevent-2.1.so.6 (0x804203000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x804452000)
        libc.so.7 => /lib/libc.so.7 (0x804668000)
        libcrypto.so.8 => /lib/libcrypto.so.8 (0x804e00000)

Did OpenBSD keep libstdc++ as the default C++ lib when switching to LLVM/clang?

@wmoxam
Copy link
Contributor Author

wmoxam commented Nov 29, 2017

$ uname -sr 
OpenBSD 6.2
$ nm -D  /usr/lib/libc++.so.1.0 | grep Unwind
         U _Unwind_Resume
$ nm -D  /usr/lib/libstdc++.so.57.0  | grep Unwind                                                                                     
00080480 T _Unwind_Backtrace
0007eb10 T _Unwind_DeleteException
0007edc0 T _Unwind_FindEnclosingFunction
000824f0 T _Unwind_Find_FDE
00080920 T _Unwind_ForcedUnwind
0007eaa0 T _Unwind_GetCFA
0007eaf0 T _Unwind_GetDataRelBase
0007eb80 T _Unwind_GetGR
0007eab0 T _Unwind_GetIP
0007edf0 T _Unwind_GetIPInfo
0007ead0 T _Unwind_GetLanguageSpecificData
0007eae0 T _Unwind_GetRegionStart
0007eb00 T _Unwind_GetTextRelBase
00080a40 T _Unwind_RaiseException
00080820 T _Unwind_Resume
00080bd0 T _Unwind_Resume_or_Rethrow
0007eb30 T _Unwind_SetGR
0007eac0 T _Unwind_SetIP

@ysbaddaden
Copy link
Contributor

I booted an OpenBSD 6.2 box and found out that Unwind symbols are in libc++abi instead of libc++. See http://libcxxabi.llvm.org/spec.html

Maybe we can just link c++abi instead of the whole stdc++?

Copy link
Contributor

@RX14 RX14 left a comment

Choose a reason for hiding this comment

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

Presuming you've tested this, this is fine.

@wmoxam
Copy link
Contributor Author

wmoxam commented Dec 2, 2017

Yes, its been tested

@ysbaddaden ysbaddaden merged commit e482297 into crystal-lang:master Dec 2, 2017
@ysbaddaden
Copy link
Contributor

Thank you!

@RX14 RX14 added this to the Next milestone Dec 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants