Skip to content

Support for iphoneos-arm64#687

Closed
elihwyma wants to merge 7 commits into
theos:masterfrom
elihwyma:rootless
Closed

Support for iphoneos-arm64#687
elihwyma wants to merge 7 commits into
theos:masterfrom
elihwyma:rootless

Conversation

@elihwyma
Copy link
Copy Markdown
Contributor

@elihwyma elihwyma commented Jan 6, 2023

What does this implement/fix? Explain your changes.

This pull request adds the support for compiling with support for iphoneos-arm64 respecting the /var/jb prefix. By appending the make argument ROOTLESS=1 the build system will move everything in stage to /var/jb, or THEOS_ROOTLESS_PREFIX. By using sed it will also change the architecture in the control file in the staging folder, so the original file is not modified. This pull request should be used alongside theos/lib#16 to ensure that frameworks will continue to resolve.

Does this close any currently open issues?

Rootless support for Theos

Where has this been tested?

Operating System: macOS Ventura 13.2

Platform: macOS

Target Platform: iOS

@elihwyma
Copy link
Copy Markdown
Contributor Author

elihwyma commented Jan 6, 2023

This will not resolve the issue of batch hooking and will continue to use the substrate API, however @Evelyneee plans to continue maintaining the substrate API in ElleKit, which is the injection library currently used on rootless jailbreaks.

@elihwyma
Copy link
Copy Markdown
Contributor Author

elihwyma commented Jan 7, 2023

Fixed some teething issues with formatting as well as added support for bundles. I also updated vendor/lib to add rpath to more dependencies.

@iCrazeiOS
Copy link
Copy Markdown

👍

@elihwyma
Copy link
Copy Markdown
Contributor Author

Currently this pull request will cause tweaks to not work on Xina jailbreak because of poorly written patches by him. Attempts have been made to reach out to resolve this issue by myself but all messages have been left on delivered. The specific issue is his use of manually patching the path instead of changing the relative path.

@tealbathingsuit
Copy link
Copy Markdown

Hiiiiii can we get this merged?

@ghost
Copy link
Copy Markdown

ghost commented Mar 20, 2023

There's something missing here, libraries (including Cydia Substrate and tweak_LIBRARIES) are not actually being linked with @rpath so -rpath doesn't achieve the desired effect.

@elihwyma
Copy link
Copy Markdown
Contributor Author

There's something missing here, libraries (including Cydia Substrate and tweak_LIBRARIES) are not actually being linked with @rpath so -rpath doesn't achieve the desired effect.

There is a matching pull request here to do this.

@ghost
Copy link
Copy Markdown

ghost commented Mar 20, 2023

Hmm, thanks, and what about libSandy? It doesn't seem to have a .tbd but is still being linked without @rpath.

@elihwyma
Copy link
Copy Markdown
Contributor Author

I included everything relevant in that PR, do you know where I could find the linker file for libSandy?

@ghost
Copy link
Copy Markdown

ghost commented Mar 20, 2023

I got it, seems like changing libsandy_INSTALL_PATH to @rpath in the Makefile and then re-running ./install_to_theos.sh fixes it.

@ghost
Copy link
Copy Markdown

ghost commented Mar 20, 2023

Actually, that works for install_to_theos but then the library doesn't get included in the resulting .deb file.

This fixes it properly:

diff --git a/makefiles/instance/framework.mk b/makefiles/instance/framework.mk
index ca0492b..8ab7e72 100644
--- a/makefiles/instance/framework.mk
+++ b/makefiles/instance/framework.mk
@@ -18,7 +18,7 @@ _LOCAL_APP_EXTENSION_SAFE := $(_THEOS_TRUE)
 include $(THEOS_MAKE_PATH)/instance/shared/bundle.mk
 # End Bundle Setup

-_THEOS_INTERNAL_LDFLAGS += -dynamiclib -install_name "$(LOCAL_INSTALL_PATH)/$(_LOCAL_INSTANCE_TARGET)"
+_THEOS_INTERNAL_LDFLAGS += -dynamiclib -install_name "@rpath/$(_LOCAL_INSTANCE_TARGET)"

 ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no)
 internal-framework-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET)
diff --git a/makefiles/targets/_common/darwin_head.mk b/makefiles/targets/_common/darwin_head.mk
index f09bbd2..69e8039 100644
--- a/makefiles/targets/_common/darwin_head.mk
+++ b/makefiles/targets/_common/darwin_head.mk
@@ -3,7 +3,7 @@ TARGET_EXE_EXT :=
 TARGET_LIB_EXT := .dylib
 TARGET_AR_EXT := .a

-TARGET_LDFLAGS_DYNAMICLIB = -dynamiclib -install_name "$(LOCAL_INSTALL_PATH)/$(1)"
+TARGET_LDFLAGS_DYNAMICLIB = -dynamiclib -install_name "@rpath/$(1)"
 TARGET_CFLAGS_DYNAMICLIB =

 _THEOS_TARGET_SUPPORTS_BUNDLES := 1

Something like this should probably be included in this PR, though this this has the potential to break if someone is using a custom install path that's not in rpath.

@Teutates
Copy link
Copy Markdown

Actually, that works for install_to_theos but then the library doesn't get included in the resulting .deb file.

This fixes it properly:

diff --git a/makefiles/instance/framework.mk b/makefiles/instance/framework.mk
index ca0492b..8ab7e72 100644
--- a/makefiles/instance/framework.mk
+++ b/makefiles/instance/framework.mk
@@ -18,7 +18,7 @@ _LOCAL_APP_EXTENSION_SAFE := $(_THEOS_TRUE)
 include $(THEOS_MAKE_PATH)/instance/shared/bundle.mk
 # End Bundle Setup

-_THEOS_INTERNAL_LDFLAGS += -dynamiclib -install_name "$(LOCAL_INSTALL_PATH)/$(_LOCAL_INSTANCE_TARGET)"
+_THEOS_INTERNAL_LDFLAGS += -dynamiclib -install_name "@rpath/$(_LOCAL_INSTANCE_TARGET)"

 ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no)
 internal-framework-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET)
diff --git a/makefiles/targets/_common/darwin_head.mk b/makefiles/targets/_common/darwin_head.mk
index f09bbd2..69e8039 100644
--- a/makefiles/targets/_common/darwin_head.mk
+++ b/makefiles/targets/_common/darwin_head.mk
@@ -3,7 +3,7 @@ TARGET_EXE_EXT :=
 TARGET_LIB_EXT := .dylib
 TARGET_AR_EXT := .a

-TARGET_LDFLAGS_DYNAMICLIB = -dynamiclib -install_name "$(LOCAL_INSTALL_PATH)/$(1)"
+TARGET_LDFLAGS_DYNAMICLIB = -dynamiclib -install_name "@rpath/$(1)"
 TARGET_CFLAGS_DYNAMICLIB =

 _THEOS_TARGET_SUPPORTS_BUNDLES := 1

Something like this should probably be included in this PR, though this this has the potential to break if someone is using a custom install path that's not in rpath.

the potential to break can be mitigated through adding the LOCAL_INSTALL_PATH to the lib search paths on link

@kirb
Copy link
Copy Markdown
Member

kirb commented Mar 26, 2023

Merged in 87dca79

Please note: a breaking change from this PR

To make the logic more generic and able to support more packaging layout schemes in future, ROOTLESS=1 was changed to THEOS_PACKAGE_SCHEME=rootless. Additionally, you can use $(THEOS_PACKAGE_INSTALL_PREFIX) in your makefiles to get the prefix (/var/jb for rootless, or an empty string for rootful).

There are still some cases that we need to sort out, such as changing the install name of libraries/frameworks to use @rpath as discussed above, but this does most of what is needed to get devs starting to make rootless builds.

@kirb kirb closed this Mar 26, 2023
@ghost
Copy link
Copy Markdown

ghost commented Mar 26, 2023

Why does it have both THEOS_PACKAGE_SCHEME and THEOS_PACKAGING_SCHEME?

@kirb
Copy link
Copy Markdown
Member

kirb commented Mar 26, 2023

Shoot, good catch. Thanks, fixed in b1932c8.

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.

5 participants