<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">For the mail (so it's easier to find than in a bug tracking system) the fix is to specify the clang include headers either with an -I on the swift invocation command line, or via the variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH<div class=""><br class=""></div><div class=""><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; background-color: rgb(245, 245, 245);" class="">setting the&nbsp;</span><tt style="background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 1px 3px; color: rgb(51, 51, 51); font-size: 14px;" class="">C_INCLUDE_PATH</tt><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; background-color: rgb(245, 245, 245);" class="">&nbsp;and&nbsp;</span><tt style="background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 1px 3px; color: rgb(51, 51, 51); font-size: 14px;" class="">CPLUS_INCLUDE_PATH</tt><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; background-color: rgb(245, 245, 245);" class="">&nbsp;environment variables to the Clang header include path did indeed work</span><br class=""><div><br class=""></div><div><pre class="code-java" style="margin-top: 0px; margin-bottom: 0px; padding: 0px; max-height: 30em; overflow: auto; white-space: pre-wrap; word-wrap: normal; color: rgb(51, 51, 51); font-size: 12px;">$ export C_INCLUDE_PATH=/swift/usr/lib/swift/clang/include/
$ export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH
$
$ swift
Welcome to Swift version 4.0-dev (LLVM a15decabe3, Clang 14ff3d9712, Swift d574ed67d6). Type :help <span class="code-keyword" style="color: rgb(0, 0, 145);">for</span> assistance.
  1&gt; <span class="code-keyword" style="color: rgb(0, 0, 145);">import</span> Foundation
  2&gt; let status = <span class="code-quote" style="color: rgb(0, 145, 0);">"woohoo! '<span class="code-keyword">import</span> Foundation' works on Linux"</span>
status: <span class="code-object" style="color: rgb(145, 0, 145);">String</span> = <span class="code-quote" style="color: rgb(0, 145, 0);">"woohoo! \'<span class="code-keyword">import</span> Foundation\' works on Linux"</span>
</pre><div class=""><span class="code-quote" style="color: rgb(0, 145, 0);"><br class=""></span></div></div><div>It really shouldn't be necessary to have to specify additional flags or variables to have Swift's REPL work out of the box on Linux, like it used to with Swift 3.0.</div><div><br class=""></div><div>Alex</div><div><br class=""><blockquote type="cite" class=""><div class="">On 26 Jul 2017, at 05:17, Mason Mark via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Just to update the record, Matthias M. Schneider posted a workaround on<span class="Apple-converted-space">&nbsp;</span></span><a href="http://bugs.swift.org/" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">bugs.swift.org</a><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">.</span><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">By setting the C_INCLUDE_PATH and CPLUS_INCLUDE_PATH environment variables to point to the Clang headers directory, it is possible to both import Foundation in the REPL (without using -I to pass the header include path) and also to debug a built executable with lldb.</span><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Example is on the bug tracker:</span><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://bugs.swift.org/browse/SR-3648?focusedCommentId=27131&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-27131" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://bugs.swift.org/browse/SR-3648?focusedCommentId=27131&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-27131</a><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Cheers,</span><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">— Mason</span><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">On Jul 12, 2017, at 13:16, Mason Mark via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">I'm reviving this somewhat-old thread because it's still the most prominent search result when googling this issue to debug it (other than the below-referenced SR-3648).<br class=""><br class="">The workaround of using -I to pass an include path to swift was working for me, because as noted by Will Stanton below, the issue was only coming up when trying to use the REPL on Linux (builds aren't affected).<br class=""><br class="">However, the same issue comes up when debugging a swift executable on Linux using lldb, which I now need to do. So I'd love to know if anybody has found a workaround.<br class=""><br class="">When you try to "po foo" in lldb, assuming foo is some object that uses Foundation, lldb errors out with a cascade of #include errors, ultimately ending with the same "error: 'stddef.h' file not found" (just like the REPL does).<br class=""><br class="">I posted a comment to the official bug thread[1] which includes the full lldb output.<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">My reason for posting to the list here is mainly to see if somebody has figured out a workaround, e.g.:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">- Does installing swift and all its stuff in /usr/lib help?<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">- Is there some way to get lldb to do the equivalent of `swift -I ~/a-swift/usr/lib/swift/clang/include/`?<br class=""><br class="">- Are there any versions of Linux where this issue does not occur? (Occurs for me with both Swift 3 and 4-dev, on Ubuntu 16.04.)<br class=""><br class="">- etc.<br class=""><br class="">Thanks for any pointers or tips. Unlike with the REPL case and its workaround, for trying to debug Swift executables on Linux this seems to be a show-stopper for me.<br class=""><br class="">— Mason<br class=""><br class=""><br class="">[1]: <a href="https://bugs.swift.org/browse/SR-3648" class="">https://bugs.swift.org/browse/SR-3648</a><br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On Apr 5, 2017, at 11:53, Will Stanton via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">From <a href="https://bugs.swift.org/browse/SR-3648" class="">https://bugs.swift.org/browse/SR-3648</a>, the work-around seems to be passing -I /path/to/extracted/usr/lib/swift/clang/include when invoking swift (credit Lukas and others, SR-3794 is more active)<br class="">So, ex. `swift -I ~/a-swift/usr/lib/swift/clang/include/`<br class=""><br class="">Fortunately, the issue has only come up for me in the REPL. `swift build` works fine: I can build packages without an awkward -Xswiftc…<br class=""><br class="">I wonder if the issue has anything to do with the clang-builtin-headers install component? (Maybe swiftc/something gets hardcoded with a path somewhere?)<br class=""><br class="">Would be interested in learning more about install options, toolchains, and the build! I’ve been wanting to track down for a while now, how does --install-prefix affect the build? I’ve been relying on install_destdir to get a swift...<br class=""><br class="">Regards,<br class="">Will Stanton<br class=""><br class=""><blockquote type="cite" class="">On Apr 4, 2017, at 9:17 PM, Rick Mann via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">The installation instructions for Swift on Linux imply that the tarball can be extracted anywhere, and the PATH set, and all should be well. But unfortunately, while that's partly true, when I try to import packages, it fails (Ubuntu 16.04 on Parallels on macOS 10.12.3):<br class=""><br class="">$ swift<br class="">Welcome to Swift version 3.1 (swift-3.1-RELEASE). Type :help for assistance.<br class="">1&gt; 1+1<br class="">$R0: Int = 2<br class="">2&gt; import Glibc<br class="">&lt;module-includes&gt;:3:10: note: in file included from &lt;module-includes&gt;:3:<br class="">#include "///usr/include/utmp.h"<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^<br class=""><br class="">///usr/include/utmp.h:23:10: note: in file included from ///usr/include/utmp.h:23:<br class="">#include &lt;sys/types.h&gt;<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^<br class=""><br class="">error: /usr/include/x86_64-linux-gnu/sys/types.h:146:10: error: 'stddef.h' file not found<br class="">#include &lt;stddef.h&gt;<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^<br class=""><br class="">error: could not build Objective-C module 'SwiftGlibc'<br class=""><br class="">2&gt;<br class=""><br class="">I'm guessing it really wants Swift to live inside /usr?<br class=""></blockquote><br class="">_______________________________________________<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=""></blockquote><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></blockquote><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-users mailing list</span><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-users@swift.org" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-users@swift.org</a><br style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-users</a></div></blockquote></div><br class=""></div></body></html>