termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.33k stars 3.07k forks source link

llvm-libunwind and lldb v3.9 packages #639

Closed am11 closed 5 years ago

am11 commented 7 years ago

LLVM has handful of projects listed at https://llvm.org/svn/llvm-project/, out of which this subset is quite instesting: https://github.com/llvm-mirror?tab=repositories

libunwind (llvm's flavor developed by Apple) and lldb are used as dependencies for some language runtimes, in particular, .NET CoreCLR and Julia.

Building llvm tools and projects are usually straightforward and can be tried out with resembling steps:

git clone -b release_39 --single-branch https://github.com/llvm-mirror/llvm
git clone -b release_39 --single-branch https://github.com/llvm-mirror/clang llvm/tools/clang
git clone -b release_39 --single-branch https://github.com/llvm-mirror/lldb llvm/tools/lldb
git clone -b release_39 --single-branch https://github.com/llvm-mirror/libunwind llvm/projects/libunwind

# create build dir (as sibling of llvm dir for this example; it can be at llvm/build)
mkdir build && cd $_

# build
cmake ../llvm
cmake . --build

The package for non-gnu libunwind (one of the popular fork of the original HP libunwind) is disabled at the moment, due to elf_prstatus and elf types conflicting by adding linux/elfcore.h header. It can probably be fixed by including <elf.h> header (which has proper macro redefinitions guards).


If all worked out well, Termux will be providing lldb and both kinds of libunwind libs. 👍

vishalbiswas commented 7 years ago

Right now, termux doesn't provide a separate llvm library package. Its all churned up into the clang package. Rust requires llvm, too. The clang package's buildscript is incomprehensible in its current state. Needs a lot of work. It would help a lot if the libs were separated.

am11 commented 7 years ago

Thanks @vishalbiswas, hope we can achieve this separation in llvm tools & projects packages (clang being one of them, instead the composite package).

For reference, see pkgsrc packaging of these projects: https://github.com/NetBSD/pkgsrc-wip/tree/master/llvm-git https://github.com/NetBSD/pkgsrc-wip/tree/master/clang-git https://github.com/NetBSD/pkgsrc-wip/tree/master/lldb-git https://github.com/NetBSD/pkgsrc-wip/tree/master/libunwind-git (this is llvm-libunwind)

Separately, in the previous post, clang sources are required by lldb, when building everything from source. However, we can override that requirement by setting some environment variable knob (as what pkgsrc is doing).

CoreCLR (cmake) introspection support both llvm flavors, HP unwind is preferred one. However, to support macOS and NetBSD etc., we only have llvm flavor which doesn't support unw_get_save_loc. See https://github.com/dotnet/coreclr/issues/872 and https://github.com/dotnet/coreclr/issues/862 for context.

Also, AFAICT, Julia and Rust autoconfigs also support llvm flavored libunwind (to get unwinding work on macOS in particular).

The ask is to preferably support lldb and both kinds of libunwind libs if possible, otherwise llvm-libunwind (which is bit inferior but works cross-platform including macOS/NetBSD). Then the vendor can decide which one they want to compile against for certain {OS.arch}. :)

cc @cydhaselton for visibility

cydhaselton commented 7 years ago

@am11 Assuming this is in regards to libunwind for hacking on the CoreCLR build, I've uploaded the modified sources for the on-device build I used for the feature-android branch: https://github.com/cydhaselton/libunwind-android.git

It's a bit hacky but should build in Termux.