<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 21 Sep 2016, at 19:14, Rafael Costa via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello fellow Swift users,<div class=""><br class=""></div><div class="">I’m encountering some problems and I wish to know if anyone here has ever come across something similar.</div><div class=""><br class=""></div><div class="">In essence, I want to cross-compile a Swift Project on macOS to run it on Linux. I’m using the following command to (try) to do so:</div><div class=""><br class=""></div><div class=""><font color="#ff2600" class="">swift build -c release --build-path ./.build/linux -Xswiftc -static-stdlib -Xswiftc -target -Xswiftc x86_64-unknown-linux-gnu </font></div><div class=""><font color="#ff2600" class=""><br class=""></font></div><div class="">The “target” parameter is passing to the “swiftc” program just fine. The problem is that it is overwritten by a “target” parameter added automatically by swift-build (that sets the target as the same arch/OS as the host machine)</div><div class=""><br class=""></div><div class="">How can I prevent that? Is it possible to cross-compile for Linux on macOS?</div><div class=""><br class=""></div><div class="">Thanks in advance,</div><div class=""><div class=""><div class="">Rafael Costa</div><div class=""><a href="mailto:rafael@rafaelcosta.me" class="">rafael@rafaelcosta.me</a></div><div class=""><br class=""></div><br class="Apple-interchange-newline">
</div>
<br class=""></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""><div class="">It is possible, but I don’t know if swift-build supports it. We don’t really have much comprehensive support for cross-compiling right now.</div><div class=""><br class=""></div><div class="">To cross-compile, you need to set the target, sysroot and tools-directory (the latter only required if compiling an executable, not for swiftmodules). You might also need to set the resource-dir to the lib/swift folder where the target’s standard library is.</div></body></html>