<div dir="ltr"><div>Hi, Alp.<br></div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-07-07 12:52 GMT+06:00 Alp Toker <span dir="ltr"><<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
On 07/07/2014 09:24, Anton Smirnov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've started to edit Mutex.cpp and RWMutex.cpp and found it's not used at all if "LLVM_ENABLE_THREADS" was off during config.<br>
So it seems that my issues was solved with it.<br>
</blockquote>
<br></div>
Great<br></blockquote><div><br></div><div><font color="#0000ff">Thanks for pointing me right direction ;)</font></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
Anyway i'm having another issue:<br>
<br></div>
*2014-07-07 12:19:54.090 LibClangUsage7Demo[64275:60b] started*<div class=""><br>
<br>
*Detected an attempt to call a symbol in system libraries that is not present on the iPhone:*<br>
<br></div>
*stat$INODE64 called from function _ZN4llvm3sys2fs6statusERKNS_<u></u>5TwineERNS1_11file_statusE in image LibClangUsage7Demo.*<div class=""><br>
<br>
Is stat missing in ios simulator? It seems that i will have to fix such issues one-by-one..<br>
<br>
Is there any ios-friendly version of llvm/clang? Is it ios simulator limitations (systems calls to absent systems methods)?<br>
</div></blockquote>
<br>
The LLVM/clang codebase is meant to be portable..<br>
<br>
So, the OS filesystem symbols are available but not implemented on your platform:<br></blockquote><div><br></div><div><font color="#0000ff">What does it mean "available but not implemented"? I'm not sure i understand it as i have no compile/link errors, runtime errors only.</font></div>
<div><font color="#0000ff">Does it mean it has required functions declarations in headers while compiling, symbols while linking but absent for some reason in runtime?</font></div><div><font color="#0000ff">How can that be? i expect to have linker errors if required system calls are absent.</font></div>
<div><br></div><div><font color="#0000ff">I'm using xcode toolchain and sysroot to cross-compile for ios so i expect it to have valid and actual headers and compiled systems libs.</font></div><div><font color="#0000ff"><br>
</font></div><div><font color="#0000ff">What can i do to fix stat missing in llvm::sys::status(..) ? Any flags or change invocation to any existing system method?</font></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
That's good news because it means there's a good chance you can get your application working without porting LLVM's System module.<br></blockquote><div><br></div><div><font color="#0000ff">I'm afraid i will discover a lot of places with runtime errors (due to missing system libs) ;(</font></div>
<div><font color="#0000ff">Does anybody know any other expected missing/not implemented calls for ios?</font></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
As I recall, you wanted to perform an in-memory compilation and produce LLVM IR, and I suggested using the clang-interpreter demo as a starting point.<br>
<br></blockquote><div><br></div><div><span style="background-color:rgb(255,255,255)"><font color="#0000ff">At that point i'm just trying to have actual llvm/clang working via Clang-C API. This means i don't have to have any major modifications, just cross-compile with right configure params.</font></span></div>
<div><span style="background-color:rgb(255,255,255)"><font color="#0000ff"><br></font></span></div><div><span style="background-color:rgb(255,255,255)"><font color="#0000ff">Probably the next step will be look into Cling modifications for LLVM/Clang and making it working.</font></span></div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Let's take that a little further..<br>
<br>
You'll need to modify the clang-interpreter sample so it loads C source code for the main file from memory instead of trying to read from the filesystem which apparently doesn't existing on your platform. The code you use shouldn't include any headers or that'll incur filesystem access.<br>
</blockquote><div><br></div><div><font color="#0000ff">Actually i can access files in ios app sandbox so i expect LLVM/Clang working for files in it.</font></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Meanwhile I've added non-JIT interpreter support in clang r212083, and if that still doesn't work you can modify the sample to print IR to check if things work.<br></blockquote><div><br></div><div><font color="#0000ff">Great! How i can i try it? Any example to interpret "hello-world"?</font></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
With some luck it won't attempt to read from the filesystem at all after that, so won't hit the missing OS features.<br>
<br>
If there are more errors, we'll need to refine the approach a little and eliminate other kinds of file accesses but that should be the general angle of attack.<br>
<br>
It sounds like a fun project, keep the list posted :-)<br></blockquote><div><br></div><div><font color="#0000ff">Well, yes it is. I'm just making proof of concept. Any help is appreciated.</font></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Alp.<br>
<br>
<br></blockquote><div><br></div><div><font color="#0000ff">Regards, Anton.</font></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
Anton.<br>
<br>
<br>
2014-07-06 17:16 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 class="">
<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 --disable-assertions<br>
    configure flags and it confirmed error line (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 <<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><div class="h5"><br>
<br>
        Did you try building with LLVM_ENABLE_THREADS off?<br>
<br>
        Also consider trying ToT to get the latest 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 sources and it seems<br>
            it's not the first mutex-related call in constructor.<br>
            This makes me think it's really absent method in 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 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 = pthread_mutexattr_init(&attr);<br>
<br>
              assert(errorcode == 0); (void)errorcode;<br>
<br>
<br>
              // Initialize the mutex as a recursive mutex, if<br>
            requested, or normal<br>
<br>
              // otherwise.<br>
<br>
              int kind = ( recursive  ? PTHREAD_MUTEX_RECURSIVE :<br>
            PTHREAD_MUTEX_NORMAL );<br>
<br>
              errorcode = pthread_mutexattr_settype(&<u></u>attr, kind);<br>
<br>
              assert(errorcode == 0);<br>
<br>
<br>
            #if !defined(__FreeBSD__) && !defined(__OpenBSD__) &&<br>
            !defined(__NetBSD__) && \<br>
<br>
                !defined(__DragonFly__) && !defined(__Bitrig__)<br>
<br>
              // Make it a process local mutex<br>
<br>
              errorcode = 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 = pthread_mutex_init(mutex, &attr);<br>
<br>
              assert(errorcode == 0);<br>
<br>
<br>
              // Destroy the attributes<br>
<br>
              errorcode = pthread_mutexattr_destroy(&<u></u>attr); // 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 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> <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br></div></div>
            <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a><div class=""><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 llvm/clang for i386 and<br>
            i'm trying to<br>
                use it in my ios app.<br>
                Also i was able to add headers and static libs (both<br>
            libLLVM*.a<br>
                and libclang*.a) and compile/link the project with no<br>
            errors.<br>
<br>
                But when trying to run simple app i'm getting error:<br>
<br>
                *Detected an attempt to call a symbol in system<br>
            libraries that is<br>
                not present on the iPhone:*<br>
<br>
                *pthread_mutexattr_destroy$<u></u>UNIX2003 called from function<br>
                _ZN4llvm3sys9MutexImplC2Eb in image LibClangUsageDemo3.*<br>
<br>
<br>
<br>
                What can i do in order to fix it?<br>
<br>
                Is it llvm/clang issue or i'm doing smth wrong?<br>
<br>
                Regards, Anton.<br>
<br>
<br>
<br>
<br>
            ______________________________<u></u>_________________<br>
            cfe-dev mailing list<br></div>
            <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>><div class=""><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>
</div></blockquote><div class="HOEnZb"><div class="h5">
<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><br></div></div></div>