Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Jeffrey Walton <noloader@gmail.com>
To: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: [wireguard-apple] [iOS] Running WireGuard on a simulator
Date: Wed, 1 Sep 2021 22:10:12 -0400	[thread overview]
Message-ID: <CAH8yC8nHSHg=rNaXRxjX_LdbGZEFBb+gB6TJkMVkw-cRO-nf-g@mail.gmail.com> (raw)
In-Reply-To: <-_8oxop6VI5mP0UY_0vydSMUBInbj0hR4IUPDWshTaRG0-6O9ybfu6kzIAk68XdY9N-LHiVgaiWhNQw6-iYG1cR14pfODj2o5JMStY-75ns=@protonmail.ch>

On Wed, Sep 1, 2021 at 9:00 PM Neutron <dotneutron@protonmail.ch> wrote:
> ...
>
> The Go version is "go1.16 darwin/arm64". The build process fails at
> # runtime/cgo
> Undefined symbols for architecture arm64:
>   "_darwin_arm_init_mach_exception_handler", referenced from:
>       _x_cgo_init in _x004.o
>   "_darwin_arm_init_thread_exception_port", referenced from:
>       _threadentry in _x004.o
>       _x_cgo_init in _x004.o
> ld: symbol(s) not found for architecture arm64
>
> This issue was reported a few times in Go's issues section, e.g.,
> https://github.com/golang/go/issues/45772#issuecomment-874616905
>
> Further head banging lead me to the discovery that
>
> xcodebuild -target WireGuardiOS -sdk iphoneos14.5
>
> actually builds successfully. I looked through the Makefile and applied some
> monkey see, monkey do. It turns out I could get it to link by adding
> GOOS_iphonesimulator := ios.

This looks a little odd to me. You should not need ios there because
the M1 is its own first class platform. About all you should need is,
ensure '-arch arm64' is used. But I probably do not understand how Go
does things.

Apple uses simulators, which means your high level C code is compiled
to the host's native instruction set. The host is where the simulator
runs. On an M1, that means code is compiled to the host's arm64
instruction set, hence the reason for '-arch arm64'. You still need to
be aware of a target SDK, but that is a particular detail. The broad
stroke is '-arch arm64' for the M1.

Android uses emulators, which means the high level C code is compiled
to the target ISA, like x86_64, arm, aarch64 or mips. Then, the ISA
instructions are interpreted on the host machine. The high level C
code is not compiled to the emulator's native instruction set.

Jeff

  parent reply	other threads:[~2021-09-02  2:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02  0:57 Neutron
2021-09-02  1:20 ` Jeffrey Walton
2021-09-02  2:10 ` Jeffrey Walton [this message]
2021-09-02  6:48   ` Neutron
2021-09-02  7:02     ` Jeffrey Walton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH8yC8nHSHg=rNaXRxjX_LdbGZEFBb+gB6TJkMVkw-cRO-nf-g@mail.gmail.com' \
    --to=noloader@gmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).