{"id":28440326,"url":"https://github.com/tinygo-org/macos-minimal-sdk","last_synced_at":"2025-07-14T06:33:03.467Z","repository":{"id":142508694,"uuid":"426462794","full_name":"tinygo-org/macos-minimal-sdk","owner":"tinygo-org","description":"Minimal but open SDK for developing small command line tools.","archived":false,"fork":false,"pushed_at":"2025-03-25T09:59:13.000Z","size":622,"stargazers_count":17,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-02T11:01:15.767Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinygo-org.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-10T02:48:40.000Z","updated_at":"2025-03-25T09:59:16.000Z","dependencies_parsed_at":"2024-03-03T19:47:04.613Z","dependency_job_id":"faff14e6-83b3-408e-a292-a34622d707d2","html_url":"https://github.com/tinygo-org/macos-minimal-sdk","commit_stats":null,"previous_names":["tinygo-org/macos-minimal-sdk"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tinygo-org/macos-minimal-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fmacos-minimal-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fmacos-minimal-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fmacos-minimal-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fmacos-minimal-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinygo-org","download_url":"https://codeload.github.com/tinygo-org/macos-minimal-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fmacos-minimal-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265252458,"owners_count":23735081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-06T03:40:13.207Z","updated_at":"2025-07-14T06:33:03.458Z","avatar_url":"https://github.com/tinygo-org.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimal SDK for macOS\n\n[![CI results](https://github.com/aykevl/macos-minimal-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/aykevl/macos-minimal-sdk/actions/workflows/test.yml)\n\nThis repository provides the basis to build a cross compiler for macOS. With it, you can compile small command line tools from any operating system to macOS.\n\nFeatures:\n\n  * Cross compile from any OS to macOS using Clang/LLVM.\n  * Open license. All header files have been obtained from [opensource.apple.com](https://opensource.apple.com/) and are licensed under the [Apple Public Source License 2.0](https://opensource.apple.com/license/apsl/). Therefore, this SDK is also open source.\n\n## Example\n\nSay you have a hello world C file, named `hello.c`:\n\n```c\n#include \u003cstdio.h\u003e\n\nint main(void) {\n    printf(\"Hello world!\\n\");\n    return 0;\n}\n```\n\nYou can then build it on any host with Clang 13+ installed like this (using `clang-13` here as an example):\n\n```\n$ clang-13 --target=x86_64-apple-macos10.12 --sysroot=sysroot-macos-x86_64 -fuse-ld=lld -o hello hello.c\n$ file hello\nhello: Mach-O 64-bit x86_64 executable, flags:\u003cNOUNDEFS|DYLDLINK|TWOLEVEL|PIE\u003e\n```\n\nIt can also compile to ARM64 (aka \"Apple Silicon\"):\n\n```\n$ clang-13 --target=arm64-apple-macos11 --sysroot=sysroot-macos-arm64 -fuse-ld=lld -o hello hello.c\n$ file hello\nhello: Mach-O 64-bit arm64 executable, flags:\u003cNOUNDEFS|DYLDLINK|TWOLEVEL|PIE\u003e\n```\n\nNote that Clang 13 or higher is required, as older versions do not have a usable MachO linker.\n\n## Building\n\nSimply run:\n\n```\nmake\n```\n\nThis builds both the x86\\_64 and the arm64 sysroots and should therefore cover most Macs.\n\n## How it works\n\nA libc comes in two parts: a set of header files and a binary libc that the linker will link against. Normally, you'd use the header files and a binary libc from your operating system. That of course won't work here: we will need to cross compile. Cross compiling usually means that you have to copy the important files (the header files and the libc) into a directory that you can then point your compiler and linker to. This is called a sysroot.\n\nThis is unfortunately not easily possible on macOS: while the header files are open source, the binary libc (called `libSystem.B.dylib`) probably is not.\n\nThe way this minimal SDK works around this is by first creating the header files from the individual libc components (downloaded from [opensource.apple.com](https://opensource.apple.com/)) and then constructing a fake `libSystem.B.dylib` that only contains a list of function names without an implementation. You can't use this `libSystem.B.dylib` to run an actual binary, but you can use it to link binaries against.\n\n### Why would you do this?\n\nIt may be useful when you develop software on Linux or Windows but want to build it for MacOS. One example might be CI: Linux is currently still more widely available (and usually cheaper!) than MacOS VMs.\n\n## Updating\n\nTo update the header files to a newer version, follow these steps.\n\n  1. Update the version numbers in versions.inc.\n  2. Run `./update.sh`. This downloads the new headers. You may need to fix build breakage especially when moving to a newer macOS version.\n  3. Run `make` to build the new sysroots. This should be very quick.\n\nThis is only rarely needed: macOS binaries will usually run just fine on a newer version of the OS.\n\n## License\n\nThis project is licensed under APSL 2.0, a variety of BSD style licenses, and public domain code:\n\n  * `src/usr/include` is extracted from the Libc, xnu, cctools, libpthread, libdispatch, and Libm. The source files are under a mix of the APSL 2.0 and a variety of BSD-style licenses. There are a few files that just say \"all rights reserved\". All those files have been replaced with a public domain version so they are also in effect open source.\n  * `src/*/libSystem.s` is extracted from the above, but because it's only a list of function names I don't believe it is covered by copyright and therefore can be considered public domain. If it is covered by copyright (I'm not a lawyer), it is covered by the same copyright as `src/usr/include` above.\n  * Other files like the various update scripts are placed in the public domain.\n\nIn other words, as far as I can see, this means that the resulting code can be freely shared and linked against.\n\n## More information\n\n  * https://adrummond.net/posts/macho provides some insights into the MachO file format.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinygo-org%2Fmacos-minimal-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinygo-org%2Fmacos-minimal-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinygo-org%2Fmacos-minimal-sdk/lists"}