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

Build for iphoneos aarch64? #36

Closed
arinc9 opened this issue Feb 13, 2020 · 51 comments
Closed

Build for iphoneos aarch64? #36

arinc9 opened this issue Feb 13, 2020 · 51 comments

Comments

@arinc9
Copy link

arinc9 commented Feb 13, 2020

It’d be really nice for jailbroken iOS users to connect from wireguard over websocket to bypass restricted networks without taking much of a performance hit.

I can provide you SSH access to a jailbroken iPhone if you’d like to run test builds on.

There’s also this project but I don’t think it uses websocket.

@erebe
Copy link
Owner

erebe commented Feb 13, 2020

Hello,
Sorry but i don't have any hardware with ios, so i don't plan to create à build for it.
If you manage to build wstunnel on ios, let me know i can add your build in the release.

P. S: i am in vacation for 3 weeks

@arinc9
Copy link
Author

arinc9 commented Feb 13, 2020

I’ll try around and see if I can manage to do it. My offer for SSH access of a jailbroken iOS device is still there though.

@arinc9
Copy link
Author

arinc9 commented Feb 13, 2020

Not trying to give you a hard time on your vacation but I’m kind of new to all this so I’m trying to figure out things. Your project uses Haskell Stack which uses GHC to compile apps. I’m thinking I need to make GHC compile for iphoneos with iOS SDK - which looks like there’s a way for it

Only after that I can take a look at wstunnel to see if anything in the source code needs to be updated to support iOS.

@erebe
Copy link
Owner

erebe commented Feb 15, 2020

You can just install haskell stack as described in the readme and do a stack setup; stack install
If it does not work out of the box, just give up, i will take a look after I get back from vacation if you can still provide me with an ssh access to an iOS env.

@arinc9
Copy link
Author

arinc9 commented Feb 15, 2020

Sure, drop me your SSH key of your system whenever you're available and I'll set it up for ya.

Edit: Turns out I could get SSH keys over GitHub already. Tell me when you're ready to go and I'll drop the public IP of the server.

@erebe
Copy link
Owner

erebe commented Mar 4, 2020

Hello,
If you can authorize the ssh key below, I will be able to try it out this week-end

https://api.github.com/users/erebe/keys

the one that terminate with YsjT

@arinc9
Copy link
Author

arinc9 commented Mar 4, 2020

Done! You can reach it at 194.31.59.155 port 2222 or 2221. I've set up different port forwarding for Cellular and Wi-Fi connection so use one of the ports that work at the moment.

@erebe
Copy link
Owner

erebe commented Mar 4, 2020

image

Working, will take a look at it this weekend :)

@arinc9
Copy link
Author

arinc9 commented Mar 4, 2020

Fingers crossed!

@arinc9
Copy link
Author

arinc9 commented Mar 7, 2020

Quick update: I've changed the server and made a solution for multiple ports. You can reach it at 160.20.145.120 port 2222.

Edit: Currently getting issues with the current configuration. I'm working on it.

@arinc9
Copy link
Author

arinc9 commented Mar 7, 2020

Sorry for the trouble. My solution messed up connection from server to phone. I've reverted it to current configuration. Access it at 160.20.145.120 port 2222 or 2221.

@arinc9
Copy link
Author

arinc9 commented Mar 8, 2020 via email

@erebe
Copy link
Owner

erebe commented Mar 8, 2020

Sadly can't even manage to have the compiler working :x
So I guess it will not be possible ;(

Thanks for providing me the iphone through

@arinc9
Copy link
Author

arinc9 commented Mar 8, 2020 via email

@erebe
Copy link
Owner

erebe commented Mar 8, 2020

There is no cross-compilation in haskell, but let me try the macos binary. Maybe it is going to work

@arinc9
Copy link
Author

arinc9 commented Mar 8, 2020 via email

@arinc9
Copy link
Author

arinc9 commented Mar 8, 2020

Scripts for cross compilation for example:
https://github.com/ghc-ios/ghc-ios-scripts

MobileHaskellFun
https://codetalk.io/posts/2018-02-07-Mobile-Haskell.html

@erebe
Copy link
Owner

erebe commented Mar 8, 2020

Tried all the binaries I got, not working.

For https://github.com/ghc-ios/ghc-ios-scripts it does not work for recent version of ghc, which the project need ghc-ios/ghc-ios-scripts#23

Going to try https://codetalk.io/posts/2018-02-07-Mobile-Haskell.html

@erebe
Copy link
Owner

erebe commented Mar 8, 2020

nop, Mobile haskell depends on stack, which does work on this arch :(

@arinc9
Copy link
Author

arinc9 commented Mar 8, 2020 via email

@erebe
Copy link
Owner

erebe commented Mar 10, 2020

Any luck on your side ?

@arinc9
Copy link
Author

arinc9 commented Mar 10, 2020 via email

@arinc9
Copy link
Author

arinc9 commented Mar 10, 2020

I've been working on setting up the tools for Mobile Haskell. I've made it work, but I'm not sure how can I build wstunnel with aarch64-apple-ios-cabal. You can teamviewer/anydesk my macOS build to see for yourself. Or I can give you ssh access of it.

@erebe
Copy link
Owner

erebe commented Mar 11, 2020

I can take a look on your macOS with ssh, (I don't have teamviewer or anydesk)

@arinc9
Copy link
Author

arinc9 commented Mar 11, 2020

MacOS Catalina's SSH server is listening on the same IP with your SSH key, port 2220, I've already compiled and installed libraries/binaries from MobileHaskellFun with the script. The directory of the repo and wstunnel is at ~/Desktop/MobileHaskellFun and ~/Desktop/wstunnel

@erebe
Copy link
Owner

erebe commented Mar 12, 2020

Didn't had much free time yesterday.
I am going to give it a shot today

@erebe
Copy link
Owner

erebe commented Mar 12, 2020

can't connect

❯ ssh root@194.31.59.155 -p 2220 -i ~/.ssh/erebe_rsa.pub -v
OpenSSH_8.2p1, OpenSSL 1.1.1d 10 Sep 2019
debug1: Reading configuration data /home/erebe/.ssh/config
debug1: /home/erebe/.ssh/config line 5: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 194.31.59.155 [194.31.59.155] port 2220.
debug1: connect to address 194.31.59.155 port 2220: Connection refused
ssh: connect to host 194.31.59.155 port 2220: Connection refused

@arinc9
Copy link
Author

arinc9 commented Mar 12, 2020 via email

@erebe
Copy link
Owner

erebe commented Mar 12, 2020

ssh: connect to host 160.20.145.120 port 2220: No route to host

@arinc9
Copy link
Author

arinc9 commented Mar 12, 2020

Looks like a slight issue with the server. It's fixed, give it a try.
P.S. You can also login as arinc9 for non-root processes.

@erebe
Copy link
Owner

erebe commented Mar 12, 2020

For now, I always fail with a
x86_64-apple-ios-ghc: could not execute: opt
opt is a binary part of the llvm package. At the time of the article it was using llvm5, but it is not available into brew.
So I tried to downgrade from llvm9 to llvm6 but sadly with the same result.

I am trying to understand why it cannot execute opt,

@arinc9
Copy link
Author

arinc9 commented Mar 12, 2020 via email

@erebe
Copy link
Owner

erebe commented Mar 12, 2020

Already tried it, and also modified the ./call script to add it
More likely to me that the call to opt fail for some reason

@arinc9
Copy link
Author

arinc9 commented Mar 12, 2020 via email

@arinc9
Copy link
Author

arinc9 commented Mar 12, 2020

Just compiled and installed LLVM 9.0.1 to the system. I've sucessfully compiled the mobilehaskell build for iOS. It's all yours.

@erebe
Copy link
Owner

erebe commented Mar 13, 2020

Going to re-take a look at it.
That's kind of the first time that I use a mac, but is this expected that compiling stuff from source works better than with brew ?

@arinc9
Copy link
Author

arinc9 commented Mar 13, 2020 via email

@erebe
Copy link
Owner

erebe commented Mar 13, 2020

I got a ssh: connect to host 160.20.145.120 port 2220: No route to host again.
My office is closing due to the coronavirus, I need to move myself back home, so I will look at it this evening/end afternoon (in 6/8 hours).

@arinc9
Copy link
Author

arinc9 commented Mar 13, 2020 via email

@arinc9
Copy link
Author

arinc9 commented Mar 13, 2020

In the meantime I got a question for you.
Can I forward both wireguard (51820) and wstunnel socks (8080) over wss (443) connection to the server?
I technically should be able to, with setting up --restrictTo on server and -L on the client but wouldn’t that make double websocket connection for socks, adding overhead to it?

EDIT: Running two instances of wstunnel listening locally on two different ports and using Nginx as a reverse proxy solved this issue.

EDIT2: I realized I can run only one server instance and configure client anyway I like.

@arinc9
Copy link
Author

arinc9 commented Mar 19, 2020

Hey, hope you’re well. You can reach my machine to do a test build anytime, just let me know when you do, so I can get the system ready.

@erebe
Copy link
Owner

erebe commented Mar 21, 2020

Hello,

Going well yes :) I hope it is the same for you !
Sadly I don't think I will have some spare time to work on it in the incoming days.
I got an increase of work due to some colleagues being sicks and in addition due to the quarantine I have to take care of my relatives, so I don't have that much spare time to spend on it.

Let's resume this after the end of the world 🤣

@arinc9
Copy link
Author

arinc9 commented Mar 21, 2020 via email

@arinc9
Copy link
Author

arinc9 commented Oct 19, 2020

Hey @erebe, what a crazy year it has been! I'm back at it, researching for cross compiling Haskell projects. This repository in particular caught my attention. Can you give it a look and make sense of it?
https://github.com/nicknovitski/stack-haskell-docker-cross-compile

@arinc9
Copy link
Author

arinc9 commented Dec 6, 2020

@erebe u/angerman on Reddit is working on cross-compilation for iOS. After he figures that out I'll be paying him to explain to you how he cross compiles Haskell projects for armv7 / aarch64-apple-ios, etc.

@arinc9 arinc9 closed this as completed Dec 6, 2020
@D4rkTT
Copy link

D4rkTT commented Apr 28, 2021

any luck? i tried a lot with https://codetalk.io/posts/2018-02-07-Mobile-Haskell.html but no luck it always fails while building libraries like transformers-combat and memory libraries.
working on macOS big sur on VM, i tried everything, i can compile simple haskell apps but wstunnel always fails

@arinc9
Copy link
Author

arinc9 commented Apr 28, 2021

@D4rkTT paging @angerman

@D4rkTT
Copy link

D4rkTT commented Apr 28, 2021

@D4rkTT paging @angerman

???????

@arinc9
Copy link
Author

arinc9 commented Apr 29, 2021 via email

@angerman
Copy link

Ok. So long story short, we'll soon have proper GHC releases that can use the LLVM backend, and do not blow up on FFI calls.

On an aarch64-darwin mac you can build executables (and libraries) that you can use on the iPhone, however there is one catch, and that is you need to disable large-address-spaces when building your GHC, as that will work on macOS but not on iOS.

The 8.10.5 release is fairly imminent.

@houmie
Copy link

houmie commented Oct 25, 2021

Hi @angerman

I would be very interested in this project to see if wstunnel could be compiled for Swift on iOS. I couldn't find your cross-compilation project for iOS. Do you mind sharing it here please?

Many Thanks

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

No branches or pull requests

5 participants