<div dir="ltr">Anyone?</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-08 14:39 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi.<div class="gmail_extra"><br><div class="gmail_quote">2014-07-08 14:02 GMT+06:00 Alp Toker <span dir="ltr"><<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>></span>:<div class="">
<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><br>
On 08/07/2014 09:40, Anton Smirnov wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I was said that `stat` is not supported on iOS:<br>
<a href="https://devforums.apple.com/message/1000186#1000186" target="_blank">https://devforums.apple.com/<u></u>message/1000186#1000186</a><br>
<br>
Any suggestion for replacement/walk-around?<br>
</blockquote>
<br></div>
OK, that was my initial assumption. clang-interpreter is still the best sample to get working..<br></blockquote><div><br></div></div><div>I will definitely try clang-interpreter a bit later (for my second task - interpreting code), after i get syntax highlighting via Clang API at least.</div>
<div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
I've run a dtrace and unfortunately there are lots of stats, with most looking redundant or even silly ("<stdin>"). Each needs to be investigated individually (making stat() a no-op doesn't help) so this is some work -- best you can do is file a PR. </blockquote>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
If you really want to get it working locally I think the best you can do is set a breakpoint and try to hack away the callers.</blockquote><div><br></div></div><div>Sure, i will start from modifying Path.inc to make it working on iOS. Unfortunately i'm not good at c/objective-c at this time so any<br>

</div><div>help is appreciated.</div><div class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
But for upstream we're going to need to fix this properly and it's not really on the roadmap right now.<br>
</blockquote><div><br></div></div><div>Totally agree with you.</div><div><br></div><div>One more general question - Is there any way to check if all required system calls are present in ios libs?</div><div><div class="h5">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
Alp.<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<br>
2014-07-07 15:28 GMT+06:00 Anton Smirnov <<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a> <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><u></u>>:<div>

<br>
<br>
    Hey.<br>
<br>
    2014-07-07 14:39 GMT+06:00 Alp Toker <<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a><br></div>
    <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>>>:<div><br>
<br>
<br>
        On 07/07/2014 11:14, Anton Smirnov wrote:<br>
<br>
            Hi, Alp.<br>
<br>
            2014-07-07 12:52 GMT+06:00 Alp Toker <<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a><br></div>
            <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>> <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a><div><div><br>
            <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>>>>:<br>
<br>
<br>
<br>
                On 07/07/2014 09:24, Anton Smirnov wrote:<br>
<br>
                    I've started to edit Mutex.cpp and RWMutex.cpp and<br>
            found it's<br>
                    not used at all if "LLVM_ENABLE_THREADS" was off<br>
            during config.<br>
                    So it seems that my issues was solved with it.<br>
<br>
<br>
                Great<br>
<br>
<br>
            Thanks for pointing me right direction ;)<br>
<br>
<br>
                    Anyway i'm having another issue:<br>
<br>
                    *2014-07-07 12:19:54.090<br>
            LibClangUsage7Demo[64275:60b] started*<br>
<br>
<br>
                    *Detected an attempt to call a symbol in system<br>
            libraries that<br>
                    is not present on the iPhone:*<br>
<br>
                    *stat$INODE64 called from function<br>
                               _ZN4llvm3sys2fs6statusERKNS_<u></u>5TwineERNS1_11file_statusE in<br>
                    image LibClangUsage7Demo.*<br>
<br>
<br>
                    Is stat missing in ios simulator? It seems that i<br>
            will have to<br>
                    fix such issues one-by-one..<br>
<br>
                    Is there any ios-friendly version of llvm/clang?<br>
            Is it ios<br>
                    simulator limitations (systems calls to absent<br>
            systems methods)?<br>
<br>
<br>
                The LLVM/clang codebase is meant to be portable..<br>
<br>
                So, the OS filesystem symbols are available but not<br>
            implemented on<br>
                your platform:<br>
<br>
<br>
            What does it mean "available but not implemented"? I'm not<br>
            sure i understand it as i have no compile/link errors,<br>
            runtime errors only.<br>
            Does it mean it has required functions declarations in<br>
            headers while compiling, symbols while linking but absent<br>
            for some reason in runtime?<br>
            How can that be? i expect to have linker errors if<br>
            required system calls are absent.<br>
<br>
            I'm using xcode toolchain and sysroot to cross-compile for<br>
            ios so i expect it to have valid and actual headers and<br>
            compiled systems libs.<br>
<br>
            What can i do to fix stat missing in llvm::sys::status(..)<br>
            ? Any flags or change invocation to any existing system<br>
            method?<br>
<br>
<br>
                That's good news because it means there's a good<br>
            chance you can<br>
                get your application working without porting LLVM's<br>
            System module.<br>
<br>
<br>
            I'm afraid i will discover a lot of places with runtime<br>
            errors (due to missing system libs) ;(<br>
            Does anybody know any other expected missing/not<br>
            implemented calls for ios?<br>
<br>
<br>
        This is a standard iOS platform? Try configuring with<br>
        -mios-simulator-version-min=7.<u></u>1<br>
<br>
<br>
    Yes, it's standard iOS Platform (iOS Simulator). I've tried 7.0,<br>
    does it make sense?<br>
    I've found few similar issue reports but they relate to 3/4 xcode<br>
    vrsion and pretty ancient ios versions.<br>
<br>
<br>
<br>
<br>
                As I recall, you wanted to perform an in-memory<br>
            compilation and<br>
                produce LLVM IR, and I suggested using the<br>
            clang-interpreter demo<br>
                as a starting point.<br>
<br>
<br>
            At that point i'm just trying to have actual llvm/clang<br>
            working via Clang-C API. This means i don't have to have<br>
            any major modifications, just cross-compile with right<br>
            configure params.<br>
<br>
            Probably the next step will be look into Cling<br>
            modifications for LLVM/Clang and making it working.<br>
<br>
<br>
        Curious, what do you need the modifications for?<br>
<br>
<br>
    Cling requires modified LLVM/Clang and it has it's own LLVM/Clang<br>
    repos.<br>
    I will start trying your clang-interpreter first which seems to do<br>
    pretty the same.<br>
<br>
<br>
        (Unless it's synced up to LLVM SVN very recently it'll be<br>
        missing the fixes from this discussion.)<br>
<br>
<br>
<br>
<br>
                Let's take that a little further..<br>
<br>
                You'll need to modify the clang-interpreter sample so<br>
            it loads C<br>
                source code for the main file from memory instead of<br>
            trying to<br>
                read from the filesystem which apparently doesn't<br>
            existing on your<br>
                platform. The code you use shouldn't include any<br>
            headers or<br>
                that'll incur filesystem access.<br>
<br>
<br>
            Actually i can access files in ios app sandbox so i expect<br>
            LLVM/Clang working for files in it.<br>
<br>
<br>
        Okay, should work fine if you need file access. Try the<br>
        configure switch I suggested.<br>
<br>
<br>
<br>
<br>
                Meanwhile I've added non-JIT interpreter support in<br>
            clang r212083,<br>
                and if that still doesn't work you can modify the<br>
            sample to print<br>
                IR to check if things work.<br>
<br>
<br>
            Great! How i can i try it? Any example to interpret<br>
            "hello-world"?<br>
<br>
<br>
        Sure, just run:<br>
<br>
        ./clang-interpreter hello.cpp<br>
<br>
        It mostly accepts the same arguments as normal clang.<br>
<br>
<br>
    Good, i will give it a try.<br>
<br>
<br>
        Alp.<br>
<br>
<br>
                With some luck it won't attempt to read from the<br>
            filesystem at all<br>
                after that, so won't hit the missing OS features.<br>
<br>
                If there are more errors, we'll need to refine the<br>
            approach a<br>
                little and eliminate other kinds of file accesses but<br>
            that should<br>
                be the general angle of attack.<br>
<br>
                It sounds like a fun project, keep the list posted :-)<br>
<br>
<br>
            Well, yes it is. I'm just making proof of concept. Any<br>
            help is appreciated.<br>
<br>
<br>
                Alp.<br>
<br>
<br>
<br>
            Regards, Anton.<br>
<br>
<br>
<br>
<br>
                    Thanks,<br>
                    Anton.<br>
<br>
<br>
                    2014-07-06 17:16 GMT+06:00 Anton Smirnov<br>
                    <<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a> <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><u></u>><br></div>

</div><div>
                    <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br></div><div><div>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><u></u>>>>:<br>
<br>
<br>
<br>
                        I've just tried to rebuild libclang.a<br>
                        with -miphoneos-version-min=7.0 - no luck.<br>
                        Also i've removed --enable-optimized<br>
            --disable-assertions<br>
                        configure flags and it confirmed error line<br>
            (Mutex.cpp):<br>
<br>
                        // Destroy the attributes<br>
                        errorcode = pthread_mutexattr_destroy(&<u></u>attr);<br>
<br>
                        Should setting LLVM_ENABLE_THREADS to "off" help?<br>
<br>
<br>
<br>
<br>
                        2014-07-06 12:03 GMT+06:00 Alp Toker<br>
            <<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a> <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>><br>
                    <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a> <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>>><br>
                        <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a> <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>><br>
            <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a> <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>>>>>:<br>
<br>
<br>
<br>
                            Did you try building with<br>
            LLVM_ENABLE_THREADS off?<br>
<br>
                            Also consider trying ToT to get the latest<br>
            fixes.<br>
<br>
                            Alp.<br>
<br>
<br>
<br>
                            On 06/07/2014 08:23, Anton Smirnov wrote:<br>
<br>
                                I've found Mutex.cpp file in llvm<br>
            sources and it seems<br>
                                it's not the first mutex-related call<br>
            in constructor.<br>
                                This makes me think it's really absent<br>
            method in<br>
                    system libs:<br>
<br>
                                // Construct a Mutex using pthread calls<br>
<br>
                                MutexImpl::MutexImpl( bool recursive)<br>
<br>
                                  : data_(0)<br>
<br>
                                {<br>
<br>
                                  // Declare the pthread_mutex data<br>
            structures<br>
<br>
                                  pthread_mutex_t* mutex =<br>
<br>
             static_cast<pthread_mutex_t*>(<u></u>malloc(sizeof(pthread_mutex_t)<u></u>));<br>
<br>
                                  pthread_mutexattr_t attr;<br>
<br>
<br>
                                  // Initialize the mutex attributes<br>
<br>
                                  int errorcode =<br>
            pthread_mutexattr_init(&attr);<br>
<br>
                                  assert(errorcode == 0); (void)errorcode;<br>
<br>
<br>
                                  // Initialize the mutex as a<br>
            recursive mutex, if<br>
                                requested, or normal<br>
<br>
                                  // otherwise.<br>
<br>
                                  int kind = ( recursive  ?<br>
            PTHREAD_MUTEX_RECURSIVE :<br>
                                PTHREAD_MUTEX_NORMAL );<br>
<br>
                                  errorcode =<br>
            pthread_mutexattr_settype(&<u></u>attr, kind);<br>
<br>
                                  assert(errorcode == 0);<br>
<br>
<br>
                                #if !defined(__FreeBSD__) &&<br>
            !defined(__OpenBSD__) &&<br>
                                !defined(__NetBSD__) && \<br>
<br>
            !defined(__DragonFly__) && !defined(__Bitrig__)<br>
<br>
                                  // Make it a process local mutex<br>
<br>
                                  errorcode =<br>
            pthread_mutexattr_setpshared(&<u></u>attr,<br>
            PTHREAD_PROCESS_PRIVATE);<br>
<br>
                                  assert(errorcode == 0);<br>
<br>
                                #endif<br>
<br>
<br>
                                  // Initialize the mutex<br>
<br>
                                  errorcode =<br>
            pthread_mutex_init(mutex, &attr);<br>
<br>
                                  assert(errorcode == 0);<br>
<br>
<br>
                                  // Destroy the attributes<br>
<br>
                                  errorcode =<br>
            pthread_mutexattr_destroy(&<u></u>attr); //<br>
                    fails here<br>
<br>
                                  assert(errorcode == 0);<br>
<br>
                                  // Assign the data member<br>
                                  data_ = mutex;<br>
<br>
                                }<br>
<br>
                                I've marked where it fails.<br>
                                How can that be that previous<br>
            mutex-related methods<br>
                                success and this one fails?<br>
                                What can i do to fix it?<br>
<br>
                                Regards, Anton.<br>
<br>
<br>
                                2014-07-05 19:31 GMT+06:00 Anton Smirnov<br>
                                <<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br>
                    <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><u></u>><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a> <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br>
                    <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><u></u>>><br>
                                <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br>
                    <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><u></u>><br>
<br>
                                <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br>
                    <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><br>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><u></u>>>>>:<br>
<br>
<br>
                                    Hi.<br>
<br>
                                    I was able to cross-compile<br>
            llvm/clang for<br>
                    i386 and<br>
                                i'm trying to<br>
                                    use it in my ios app.<br>
                                    Also i was able to add headers and<br>
            static libs<br>
                    (both<br>
                                libLLVM*.a<br>
                                    and libclang*.a) and compile/link<br>
            the project<br>
                    with no<br>
                                errors.<br>
<br>
                                    But when trying to run simple app<br>
            i'm getting<br>
                    error:<br>
<br>
                                    *Detected an attempt to call a<br>
            symbol in system<br>
                                libraries that is<br>
                                    not present on the iPhone:*<br>
<br>
            *pthread_mutexattr_destroy$<u></u>UNIX2003 called<br>
                    from function<br>
            _ZN4llvm3sys9MutexImplC2Eb in image<br>
                    LibClangUsageDemo3.*<br>
<br>
<br>
<br>
                                    What can i do in order to fix it?<br>
<br>
                                    Is it llvm/clang issue or i'm<br>
            doing smth wrong?<br>
<br>
                                    Regards, Anton.<br>
<br>
<br>
<br>
<br>
            ______________________________<u></u>_________________<br>
                                cfe-dev mailing list<br>
            <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a> <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>><br>
            <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a> <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>>><br>
                    <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
            <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>> <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
            <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>>>><br>
<br>
<br>
            <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
<br>
<br>
                            -- <a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
                            the browser experts<br>
<br>
<br>
<br>
<br>
                -- <a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
                the browser experts<br>
<br>
<br>
<br>
        --         <a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
        the browser experts<br>
<br>
<br>
<br>
</div></div></blockquote><div><div>
<br>
-- <br>
<a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
the browser experts<br>
<br>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>