<div dir="ltr">Hey.<div class="gmail_extra"><br><div class="gmail_quote">2014-07-07 14:39 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 11:14, Anton Smirnov wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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> <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>>>:<div><div class="h5"><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 found it's<br>
not used at all if "LLVM_ENABLE_THREADS" was off 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 LibClangUsage7Demo[64275:60b] started*<br>
<br>
<br>
*Detected an attempt to call a symbol in system 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 will have to<br>
fix such issues one-by-one..<br>
<br>
Is there any ios-friendly version of llvm/clang? Is it ios<br>
simulator limitations (systems calls to absent 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 implemented on<br>
your platform:<br>
<br>
<br>
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.<br>
Does it mean it has required functions declarations in headers while compiling, symbols while linking but absent for some reason in runtime?<br>
How can that be? i expect to have linker errors if required system calls are absent.<br>
<br>
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.<br>
<br>
What can i do to fix stat missing in llvm::sys::status(..) ? Any flags or change invocation to any existing system method?<br>
<br>
<br>
That's good news because it means there's a good chance you can<br>
get your application working without porting LLVM's System module.<br>
<br>
<br>
I'm afraid i will discover a lot of places with runtime errors (due to missing system libs) ;(<br>
Does anybody know any other expected missing/not implemented calls for ios?<br>
</div></div></blockquote>
<br>
This is a standard iOS platform? Try configuring with -mios-simulator-version-min=7.<u></u>1</blockquote><div><br></div><div>Yes, it's standard iOS Platform (iOS Simulator). I've tried 7.0, does it make sense?</div>
<div>I've found few similar issue reports but they relate to 3/4 xcode vrsion and pretty ancient ios versions. </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><br>
<br>
<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<br>
produce LLVM IR, and I suggested using the clang-interpreter demo<br>
as a starting point.<br>
<br>
<br>
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.<br>
<br>
Probably the next step will be look into Cling modifications for LLVM/Clang and making it working.<br>
</blockquote>
<br></div>
Curious, what do you need the modifications for?<br></blockquote><div><br></div><div>Cling requires modified LLVM/Clang and it has it's own LLVM/Clang repos.</div><div>I will start trying your clang-interpreter first which seems to do pretty the same.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
(Unless it's synced up to LLVM SVN very recently it'll be missing the fixes from this discussion.)<div class=""><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Let's take that a little further..<br>
<br>
You'll need to modify the clang-interpreter sample so it loads C<br>
source code for the main file from memory instead of trying to<br>
read from the filesystem which apparently doesn't existing on your<br>
platform. The code you use shouldn't include any headers or<br>
that'll incur filesystem access.<br>
<br>
<br>
Actually i can access files in ios app sandbox so i expect LLVM/Clang working for files in it.<br>
</blockquote>
<br></div>
Okay, should work fine if you need file access. Try the configure switch I suggested.<div class=""><br>
<br>
<br>
<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,<br>
and if that still doesn't work you can modify the sample to print<br>
IR to check if things work.<br>
<br>
<br>
Great! How i can i try it? Any example to interpret "hello-world"?<br>
</blockquote>
<br></div>
Sure, just run:<br>
<br>
./clang-interpreter hello.cpp<br>
<br>
It mostly accepts the same arguments as normal clang.<br></blockquote><div><br></div><div>Good, i will give it a try.</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>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
<br>
With some luck it won't attempt to read from the 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 approach a<br>
little and eliminate other kinds of file accesses but 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 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> <mailto:<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>><br></div>
<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>>>:<div class="">
<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 --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>
<mailto:<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 class="h5"><br>
<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<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 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); //<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 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>> <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>
<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 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 static libs<br>
(both<br>
libLLVM*.a<br>
and libclang*.a) and compile/link the project<br>
with no<br>
errors.<br>
<br>
But when trying to run simple app i'm getting<br>
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<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 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></div></div>
<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>>><div class=""><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>
</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>