Skip to content

Instantly share code, notes, and snippets.

@steeve
Created June 23, 2019 01:17
Show Gist options
  • Save steeve/4a68752d18581ad556be648c3c864193 to your computer and use it in GitHub Desktop.
Save steeve/4a68752d18581ad556be648c3c864193 to your computer and use it in GitHub Desktop.
root@dc8b20086470:/apple# cat main.swift
print("Hello, world!")
root@dc8b20086470:/apple# uname -a
Linux dc8b20086470 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
root@dc8b20086470:/apple# PATH=${DEVELOPER_DIR}/Toolchains/XcodeDefault.xctoolchain/usr/bin:${PATH} \
swiftc \
-Xlinker -rpath -Xlinker /usr/lib/swift \
-target x86_64-apple-darwin18.6.0 \
-sdk ${DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
-o from.linux \
main.swift
root@dc8b20086470:/apple# file from.linux
from.linux: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
~/apple (master)> uname -a
Darwin C02VK1C7HTDF 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
~/apple (master)> file from.linux
from.linux: Mach-O 64-bit executable x86_64
~/apple (master)> ./from.linux
dyld: Symbol not found: _$sSSN
Referenced from: /Users/steeve/go/src/github.com/znly/docker-apple-toolchain/./from.linux
Expected in: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
in /Users/steeve/go/src/github.com/znly/docker-apple-toolchain/./from.linux
fish: './from.linux' terminated by signal SIGABRT (Abort)
~/apple (master)> install_name_tool -delete_rpath '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx' from.linux
~/apple (master)> ./from.linux
Hello, world!
~/apple (master)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment