How to write llvm pass in Mac OS X 10.9 - macos

I built my pass on Linux and it worked there correctly. Now when I brought in my code to Mac OS X 10.9 on Mac Airbook, its not working anymore. I am describing below the steps I took for building my llvm pass.
My source tree is llvm-3.4 and llv-3.4/tools/clang-3.4
I ran ./configure --prefix=/some-path --enable-targets=host which was successful.
Then I ran make && make install which completed without any errors.
I exported the bin path export PATH=/some-path/bin:$path and checked for which clang which opt and they pointed to my installation.
Now when I tried to load hello pass opt -load /some-path/lib/LLVMHello.dylib -hello <fac.bc >/dev/null I get the following error
Error opening '/some-path/lib/LLVMHello.dylib': dlopen(/some-path/lib/LLVMHello.dylib, 9): Symbol not found: __ZN4llvm12FunctionPass17assignPassManagerERNS_7PMStackENS_15PassManagerTypeE
Referenced from: /some-path/lib/LLVMHello.dylib
Expected in: flat namespace
in /some-path/lib/LLVMHello.dylib
-load request ignored.
opt: Unknown command line argument '-hello'. Try: '/some-path/bin/opt -help'
opt: Did you mean '-help'?
Can someone help me fix this issue or at least point in the right direction.

In my case, the dynamic LLVM library, which is required for dynamically loaded passes, was missing. I solved it by configuring LLVM with --enable-shared. I also had --enable-keep-symbols set, but I don't think this is necessary. The full configure command I used:
./configure --enable-shared --enable-keep-symbols
I know I'm a bit late with the answer, but I recently ran into the same problem. And since I spent quite some time solving the issue, I wanted to pass on my findings. Hope it helps.
Cheers, Marcus

Related

cx oracle ImportError

I followed this tutorial for installing cx_oracle on Mac. After some tweaks it was successful. I was using Mavericks earlier. Then I got an upgrade to El Capitan. That's where the disaster came in.
It stopped working. I couldn't find related files in the directory earlier. Due to System Integrity Protection, I go through the whole process again and installed this at usr/local/lib/share/oracle/installclient_11_2.
But now when I run the program. It throws this error message:
ImportError: dlopen(/Library/Python/2.7/site-packages/cx_Oracle.so, 2): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
Referenced from: /Library/Python/2.7/site-packages/cx_Oracle.so
Reason: image not found
I tried a lot of solutions online, like https://gist.github.com/rmoff/5a70862f27d2284e9541, http://kevindalias.com/2014/03/26/how-to-set-up-cx_oracle-for-python-on-mac-os-x-10-89/
Still no luck on me:(
Any suggestions are welcome. Thanks in advance!
==========================================================================
UPDATE:
Found this post online, works magically on El Capitan. Delete the old install, start fresh following this intruction step-by-step.
This is related to the system integrity protection (SIP) changes in El Capitan, which among other things prevents DYLD_LIBRARY_PATH being inherited by spawned processes.
You can modify the cx_Oracle.so library to use the actual path to the Oracle client library instead of the searched path that no longer works; make sure you have ORACLE_HOME still set to point to your actual instant client location, and also note that the exact path reported by ImportError should be used - the 3071542110 value may vary depending on the version/build of Instant Client you have installed:
export ORACLE_HOME=/usr/local/lib/share/oracle/installclient_11_2
install_name_tool -change \
/ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 \
$ORACLE_HOME/libclntsh.dylib.11.1 \
/Library/Python/2.7/site-packages/cx_Oracle.so
... but then that library can't find another Oracle one:
ImportError: dlopen(/Library/Python/2.7/site-packages/cx_Oracle.so, 2): Library not loaded: /ade/b/3071542110/oracle/ldap/lib/libnnz11.dylib
Referenced from: /usr/local/lib/share/oracle/installclient_11_2/libclntsh.dylib.11.1
Reason: image not found
So you'd need to change that library too, which you may be less comfortable with:
install_name_tool -change \
/ade/b/3071542110/oracle/ldap/lib/libnnz11.dylib \
$ORACLE_HOME/libnnz11.dylib \
$ORACLE_HOME/libclntsh.dylib.11.1
Depending on the exact client version/build you may need to make the file writable before running that command, with:
chmod 755 $ORACLE_HOME/libclntsh.dylib.11.1
With those changes I can run the cx_Oracle tests on El Capitan.
More into on install_name_change here.
It looks like the 12c instant client has been built in a way that avoids this issue, so upgrading to that is gong to be simpler than hacking around int he 11g files.
sample fix with
ln -s /opt/oracle/product/12.1.0/instantclient_12_1/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib.12.1

Compile nginx 1.8.1 with http_perl_module

I need help compiling nginx with the perl_module on my Mac:
System Software Overview:
System Version: OS X 10.11.1 (15B42)
Kernel Version: Darwin 15.0.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name: Philipp
User Name: XXXXXXX XXXXXXXX (philipp)
Secure Virtual Memory: Enabled
Time since boot: 4 days 22:46
I configure nginx to be compiled with PCRE and PERL, i.e.,:
./configure --with-pcre=/Users/philipp/downloads/pcre-8.38 --with-http_perl_module --prefix=/servers/nginx
The output of the configure states:
checking for perl
+ perl version: This is perl 5, version 18, subversion 2 (v5.18.2)
built for darwin-thread-multi-2level
+ perl interpreter multiplicity found
If I execute make I run into the following error:
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I googled and found a hint to export KERNEL_BITS=64, which did not solve the problem. Any suggestions on how to compile nginx with perl. The compilation succeeds without the --with-http_perl_module option, but in that case I cannot use perl in the nginx.conf (of course :)).
UPDATE:
I was not able to compile nginx with perl. I ended up using a pre-compiled package, which is kind of unsatisfying, because now I have to deal with a lot of packages I don't like. Anyways, if someone has a solution I'd be more than happy to know.
I'm not sure if this is offtopic or not, but as it's about using perl within nginx (which I do, and is awesome).
I had a similar problem when trying to build this module. The root of it was that I hadn't got the right LD flags.
The easiest way of doing this - IMO - is install nginx from a package, run nginx -V and see what flags were used - copy them all, and include the extras. (And check it wasn't already build in your distribution - it was in mine, which I think was a Centos 7.2 package - I don't have it to hand, but I'm not sure it would necessarily help)
You may also need to install a new perl version, to go with it though.
--with-pcre=../modules/pcre-8.38
--with-openssl=../modules/openssl-1.0.2g
--prefix=/usr/local/nginx
--with-http_perl_module
--with-http_ssl_module
--with-http_addition_module
--with-http_sub_module
--with-http_realip_module
--with-http_stub_status_module
--with-cc-opt='-I /usr/local/include'
--with-ld-opt='-L /usr/local/lib -L/usr/local/opt/perl518/lib'
I got the same problem. after about 3 hours digging with this, finally solved. This is my configure file, i installed perl518 with brew located in /usr/local/opt/perl518/lib, and use the newest nginx source code of version nginx version: nginx/1.10.0.
Things seems happend as #Sobrique said, you need to give the right --with-ld-opt & --with-cc-opt.
important, after ./configure, DO NOT doing make immediately, vi ./objs/Makefile and modify openssl config from './config' to './Configure darwin-x86_64-cc' so that it can build openssl in x86_64 mod.
Hope it can help you!

Gitian error while compiling Bitcoin dependencies for OSX

I'm trying to compile Bitcoin in Gitian for OSX. I've ran the following line.
./bin/gbuild ../bitcoin/contrib/gitian-descriptors/gitian-osx-native.yml
That produces an error in the build log as follows.
cd libprunetrie && make
make[1]: Entering directory `/home/ubuntu/build/osx-cross-depends/build/toolchain4-10cc648683617cca8bcbeae507888099b41b530c/cctools2odcctools/odcctools-809/libprunetrie'
mkdir -p `dirname PruneTrie.o`
In file included from allocate.c:29:0:
../include/stuff/errors.h:39:1: error: unknown type name ‘uint32_t’
../include/stuff/errors.h:79:5: error: unknown type name ‘kern_return_t’
../include/stuff/errors.h:86:5: error: unknown type name ‘kern_return_t’
What do I need to do to make this work? If I'm not including enough information, please let me know what you need me to tell you. I didn't change the yml file from the official Bitcoin sources or anything else and I'm compiling on a Ubuntu 12.04.4 64Bit VirtualBox instance using LXC.
In case anyone else comes accross this issue, it has something to do with the way a Mac OSX system packages the tar file. You can't package it on a regular Linux system, it has to be Darwin Unix. (Mac) I came accross the link below which points to a ready made version of the stripped down Apple SDK file for Bitcoin. (MacOSX10.7.sdk.tar.gz)
https://github.com/deuscoin/deuscoin/blob/master/doc/building-deuscoin.md
Hopefully this helps someone else.

Fail Installation: OpenCV 2.4.6.1 on Mac OS X Mountain Lion

I am frustrated with installing OpenCV 2.4.6.1 on My MacBook Pro Mountain Lion, I've tried so many ways using MacPort, CMake, Cuda to no avail.
I followed the instruction from this site http://sadeepj.blogspot.sg/2012/03/installing-and-configuring-opencv-to.html to install and configure OpenCV in MacOS X. However, when I run in the command line '$ make' it always results in error at [30%].
[ 30%] Building CXX object modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_main.cpp.o
/Users/yonasstephen/Downloads/opencv-2.4.6/modules/core/perf/perf_main.cpp:3:1: error: multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(core)
^~~~~~~~~~~~~~~~~~~~~~~
/Users/yonasstephen/Downloads/opencv-2.4.6/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note: expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/yonasstephen/Downloads/opencv-2.4.6/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note: expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/\
^ ~~
1 error generated.
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
make: *** [all] Error 2
Does anybody know how to resolve this?
Thank you very much in advance :)
I have figured out how to solve this and posted it here: https://sites.google.com/site/yonasstephenfyp2013/updates/tutorialinstallingopencvonmacosxmountainlion
the essence of solving this is using the right version of OpenCV. At the time I installed, the stable version was OpenCV 2.4.3. Don't go for the latest version because it might be compatible yet with the new MacOS OS
you could just skip the performance tests for now. (you can always build them later, once this got solved)
add:
-D BUILD_PERF_TESTS=OFF
to your cmake cmdline
[edit]
looks you're having issues #3191 and 3179
both of them are fixed in 2.4 now https://github.com/Itseez/opencv/pull/1228 , https://github.com/Itseez/opencv/pull/1244
when did you download the code ? might consider getting a fresh copy ?

Help Installing psycopg2 on snow leopard : command '/usr/bin/gcc-4.0' failed with exit status 1

This has been driving me crazy for 2 days.
I have been trying to install psycopg2 using easy_install and no matter what I try (i.e using gcc-4.0 instead of the snow leopard default one) I always get the same error:
error: Setup script exited with error: command '/usr/bin/gcc-4.0' failed with exit status 1
Please see: http://dpaste.com/hold/228252/
I have googled that error so many times and nothing I have found seem to help.
Looks like you're missing a dependency, the development files for libpq. The relevant log part is here:
In file included from psycopg/psycopgmodule.c:32In file included from psycopg/psycopgmodule.c:32:
./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory
Try installing libpq development files and then rerun easy_install. You may hit another missing dependency; pay attention to the first error that GCC spits out.
Link http://dpaste.com/hold/228252/ seems to be dead, this is how I solved this problem (Mac OS X 10.6, virtualenv).
If pip fails with this message, just take a look to build folder in your virtual environment. You should edit setup.cfg file there, particularly include_dirs and library_dirs. In first one set your include folders, my option was:
include_dirs=/opt/local/include/postgresql84:/opt/local/include/postgresql84/server
and most likely you will need to set library_dirs to correct location as well:
library_dirs=/opt/local/lib/postgresql84.
probably you should install postgresql-devel first
yum -y install postgresql-devel

Resources