Skip to content

Commit 2461061

Browse files
committed
Upstream macCatalyst support in debugserver and the macOS dynamic loader
plugin. Unfortunately the test is currently XFAILed because of missing changes to the clang driver. Differential Revision: https://reviews.llvm.org/D67124 llvm-svn: 370931
1 parent 40fe351 commit 2461061

File tree

21 files changed

+259
-48
lines changed

21 files changed

+259
-48
lines changed

lldb/include/lldb/Core/Module.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,9 @@ class Module : public std::enable_shared_from_this<Module>,
895895
bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const;
896896
bool RemapSourceFile(const char *, std::string &) const = delete;
897897

898+
/// Update the ArchSpec to a more specific variant.
899+
bool MergeArchitecture(const ArchSpec &arch_spec);
900+
898901
/// \class LookupInfo Module.h "lldb/Core/Module.h"
899902
/// A class that encapsulates name lookup information.
900903
///

lldb/include/lldb/Host/macosx/HostInfoMacOSX.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class HostInfoMacOSX : public HostInfoPosix {
2727

2828
public:
2929
static llvm::VersionTuple GetOSVersion();
30+
static llvm::VersionTuple GetMacCatalystVersion();
3031
static bool GetOSBuildString(std::string &s);
3132
static bool GetOSKernelDescription(std::string &s);
3233
static FileSpec GetProgramFileSpec();

lldb/include/lldb/Target/Process.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,9 @@ class Process : public std::enable_shared_from_this<Process>,
11961196
/// VersionTuple is returner.
11971197
virtual llvm::VersionTuple GetHostOSVersion() { return llvm::VersionTuple(); }
11981198

1199+
/// \return the macCatalyst version of the host OS.
1200+
virtual llvm::VersionTuple GetHostMacCatalystVersion() { return {}; }
1201+
11991202
/// Get the target object pointer for this module.
12001203
///
12011204
/// \return
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
LEVEL = ../../make
2+
3+
C_SOURCES := main.c
4+
LD_EXTRAS := -L. -lfoo
5+
6+
TRIPLE := x86_64-apple-ios13.0-macabi
7+
CFLAGS_EXTRAS := -target $(TRIPLE)
8+
9+
all: libfoo.dylib a.out
10+
11+
lib%.dylib: %.c
12+
$(MAKE) MAKE_DSYM=YES CC=$(CC) \
13+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
14+
BASENAME=$(shell basename $< .c) \
15+
TRIPLE=x86_64-apple-macosx10.15 SDKROOT=$(SDKROOT) \
16+
VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk all
17+
18+
include $(LEVEL)/Makefile.rules
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# TestMacABImacOSFramework.py
2+
import lldb
3+
from lldbsuite.test.lldbtest import *
4+
from lldbsuite.test.decorators import *
5+
import lldbsuite.test.lldbutil as lldbutil
6+
import os
7+
import unittest2
8+
9+
10+
class TestMacABImacOSFramework(TestBase):
11+
12+
mydir = TestBase.compute_mydir(__file__)
13+
14+
@skipIf(macos_version=["<", "10.15"])
15+
@skipUnlessDarwin
16+
@skipIfDarwinEmbedded
17+
# There is a Clang driver change missing on llvm.org.
18+
@expectedFailureAll(bugnumber="rdar://problem/54986190>")
19+
def test_macabi(self):
20+
"""Test the x86_64-apple-ios-macabi target linked against a macos dylib"""
21+
self.build()
22+
lldbutil.run_to_source_breakpoint(self, "break here",
23+
lldb.SBFileSpec('main.c'))
24+
self.expect("image list -t -b",
25+
patterns=["x86_64.*-apple-ios.*-macabi a\.out",
26+
"x86_64.*-apple-macosx.* libfoo.dylib[^(]"])
27+
self.expect("fr v s", "Hello MacABI")
28+
self.expect("p s", "Hello MacABI")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
LEVEL = ../../make
2+
DYLIB_ONLY := YES
3+
DYLIB_NAME := $(BASENAME)
4+
DYLIB_C_SOURCES := $(DYLIB_NAME).c
5+
6+
include $(LEVEL)/Makefile.rules
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "foo.h"
2+
3+
void stop() {}
4+
5+
int foo() {
6+
stop();
7+
return 0;
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "foo.h"
2+
int main() {
3+
const char *s = "Hello MacABI!";
4+
return foo(); // break here
5+
}

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ ifneq "$(TRIPLE)" ""
8888
triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed 's/\([a-z]*\)\(.*\)/\1 \2/')
8989
TRIPLE_OS =$(word 1, $(triple_os_and_version))
9090
TRIPLE_VERSION =$(word 2, $(triple_os_and_version))
91+
TRIPLE_ENV =$(word 4, $(triple_space))
9192
ifeq "$(TRIPLE_VENDOR)" "apple"
9293
ifeq "$(TRIPLE_OS)" "ios"
9394
CODESIGN := codesign
@@ -100,11 +101,19 @@ ifneq "$(TRIPLE)" ""
100101
endif
101102
ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
102103
else
103-
SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path)
104+
ifeq "$(TRIPLE_ENV)" "macabi"
105+
SDKROOT = $(shell xcrun --sdk macosx --show-sdk-path)
106+
else
107+
SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path)
108+
endif
104109
ifeq "$(TRIPLE_VERSION)" ""
105110
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
106111
endif
107-
ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
112+
ifeq "$(TRIPLE_ENV)" "macabi"
113+
ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
114+
else
115+
ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
116+
endif
108117
endif
109118
endif
110119
endif

0 commit comments

Comments
 (0)