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

builder: add support for cross compiling to Darwin #2586

Merged
merged 2 commits into from
Feb 12, 2022

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Jan 25, 2022

This means that it will be possible to generate a Darwin binary on any platform (Windows, Linux, and MacOS of course), including CGo. Of course, the resulting binaries can only run on MacOS itself.

The binary links against libSystem.dylib, which is a shared library. The macos-minimal-sdk repository (created by me) contains open source header files and generated symbol stubs so we can generate a stub libSystem.dylib without copying any closed source code.

@aykevl aykevl marked this pull request as draft January 25, 2022 22:38
@aykevl aykevl force-pushed the darwin-cross-compile branch 6 times, most recently from 8153a0d to 3518212 Compare February 1, 2022 21:45
@aykevl aykevl marked this pull request as ready for review February 1, 2022 21:46
@aykevl
Copy link
Member Author

aykevl commented Feb 1, 2022

In theory this should work now, let's see whether theory matches with reality...

It should only be added at the point that it is needed, for example when
using libclang or using the built-in Clang. It isn't needed when running
an external tool.
This means that it will be possible to generate a Darwin binary on any
platform (Windows, Linux, and MacOS of course), including CGo. Of
course, the resulting binaries can only run on MacOS itself.

The binary links against libSystem.dylib, which is a shared library. The
macos-minimal-sdk repository contains open source header files and
generated symbol stubs so we can generate a stub libSystem.dylib without
copying any closed source code.
@aykevl
Copy link
Member Author

aykevl commented Feb 3, 2022

Of course it didn't, but now it does! This is ready for review now.

@dkegel-fastly
Copy link
Contributor

My app builds and passes tests on mac with this, fwiw.

@aykevl
Copy link
Member Author

aykevl commented Feb 3, 2022

You need to run git submodule update --init if you run this locally.

@aykevl aykevl requested a review from dgryski February 4, 2022 17:18
@aykevl
Copy link
Member Author

aykevl commented Feb 4, 2022

Can someone (@dgryski?) run the test corpus with this PR on MacOS? Just to make sure nothing broke.

@dkegel-fastly
Copy link
Contributor

Running...

@dkegel-fastly
Copy link
Contributor

Failed here after a while.

See slack, https://gophers.slack.com/archives/CN4R2DQV7/p1643995729086929?thread_ts=1643995716.634529&cid=CN4R2DQV7

Log excerpt:

=== CONT  TestCorpus/gonum.org/v1/gonum(noasm-appengine)/spatial/r3
panic: unexpected typecode name: 

goroutine 4725 [running]:
github.com/tinygo-org/tinygo/transform.getClassAndValueFromTypeCode(0x1c925ea10, 0x300000002, 0xc0205e2d80, 0xc06c934b30, 0x40718e8)
	/Users/dkegel/src/tinygo/transform/reflect.go:375 +0x18d
github.com/tinygo-org/tinygo/transform.(*typeCodeAssignmentState).getTypeCodeNum(0xc06c935990, 0x1c925ea10, 0x1)

@dkegel-fastly
Copy link
Contributor

That fails for me on dev, too, so it's not this pull request's fault.

@aykevl
Copy link
Member Author

aykevl commented Feb 8, 2022

I have a patch for a cross compiled TinyGo ready (X86 to ARM Linux), but this PR should be merged first to avoid conflicts.

@deadprogram
Copy link
Member

This is some incredible work here @aykevl so exciting to see https://github.com/aykevl/macos-minimal-sdk is working!

Now merging, this is a great place to start from for further iteration.

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.

3 participants