This is an archive of the discontinued LLVM Phabricator instance.

[CMake] `install-distribution` for LLDB on Darwin
ClosedPublic

Authored by sgraenitz on Jul 9 2019, 5:58 AM.

Details

Summary

There's a number of requirements for installing LLDB on macOS that are untypical for LLVM projects: use special install-prefix for LLDB.framework, ship headers and tools as framework resources, patch RPATHs, externalize debug-info to dSYM's and strip binaries with -ST. For some of it we could use llvm_externalize_debuginfo() in the past and just add special cases. However, this complicates the code for all projects and comes with the major drawback, that it adds all these actions at build-time, i.e. dSYM creation and stripping take a lot of time and don't make sense at build-time.

LLVM's distribution mechanism (https://llvm.org/docs/BuildingADistribution.html) appears to be the natural candidate to install LLDB. Based on D64399 (enable in standalone builds), this patch integrates framework installation with the distribution mechanism and adds custom stripping flags and dSYM creation at install-time. Unlike the abandoned D61952, it leaves build-tree binaries untouched, so there's no side-effects on testing. Potential install-order issues must be handled externally.

Please let me know what you think, while I run a few more tests and add remarks+documentation.

Diff Detail

Repository
rL LLVM

Event Timeline

sgraenitz created this revision.Jul 9 2019, 5:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2019, 5:58 AM
sgraenitz edited the summary of this revision. (Show Details)Jul 9 2019, 6:02 AM

Usage example that should work in conjunction with D64397 and D64399:

$ cd path/to/lldb-deps-relwithdebinfo
$ cmake -GNinja -C/path/to/llvm-project/lldb/cmake/caches/Apple-lldb-base.cmake \
                -DLLVM_ENABLE_PROJECTS="clang;libcxx" \
                /path/to/llvm-project/llvm
$ cmake --build .

$ cd lldb-relwithdebinfo
$ cmake -GNinja -C/path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake \
                -DLLVM_DIR=/path/to/lldb-deps-relwithdebinfo/lib/cmake/llvm \
                -DClang_DIR=/path/to/lldb-deps-relwithdebinfo/lib/cmake/clang \
                /path/to/llvm-project/lldb
$ cmake --build . --target distribution
$ DESTDIR=/path/to/install/location cmake --build . --target install-distribution

$ tree /path/to/install/location | grep -v -E "(h|py)$"
/path/to/install/location
├── Applications
│   └── Xcode.app
│       └── Contents
│           ├── Developer
│           │   └── usr
│           │       └── bin
│           │           └── lldb
│           └── SharedFrameworks
│               └── LLDB.framework
│                   ├── Headers -> Versions/Current/Headers
│                   ├── LLDB -> Versions/Current/LLDB
│                   ├── Resources -> Versions/Current/Resources
│                   └── Versions
│                       ├── A
│                       │   ├── Headers
│                       │   ├── LLDB
│                       │   └── Resources
│                       │       ├── Info.plist
│                       │       ├── Python
│                       │       │   ├── lldb
│                       │       │   │   ├── _lldb.so -> ../../../LLDB
│                       │       │   │   ├── diagnose
│                       │       │   │   ├── formatters
│                       │       │   │   │   ├── cpp
│                       │       │   │   ├── macosx
│                       │       │   │   │   ├── heap
│                       │       │   │   │   │   ├── Makefile
│                       │       │   │   │   │   └── heap_find.cpp
│                       │       │   │   ├── runtime
│                       │       │   │   └── utils
│                       │       ├── darwin-debug
│                       │       ├── debugserver
│                       │       └── lldb-argdumper
│                       └── Current -> A
└── debuginfo
    ├── LLDB.framework.dSYM
    │   └── Contents
    │       ├── Info.plist
    │       └── Resources
    │           └── DWARF
    │               └── LLDB
    ├── darwin-debug.dSYM
    │   └── Contents
    │       ├── Info.plist
    │       └── Resources
    │           └── DWARF
    │               └── darwin-debug
    ├── debugserver.dSYM
    │   └── Contents
    │       ├── Info.plist
    │       └── Resources
    │           └── DWARF
    │               └── debugserver
    └── lldb-argdumper.dSYM
        └── Contents
            ├── Info.plist
            └── Resources
                └── DWARF
                    └── lldb-argdumper

41 directories, 114 files
labath added a comment.Jul 9 2019, 8:04 AM

I'm not very familiar with the details here, but this approach seems reasonable to me...

xiaobai accepted this revision.Jul 9 2019, 10:51 AM

I like the idea a lot and the implementation looks alright. LGTM

This revision is now accepted and ready to land.Jul 9 2019, 10:51 AM
JDevlieghere accepted this revision.Jul 9 2019, 11:38 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2019, 4:10 AM