What's the best way to compile Ruby from source on 64-bit RedHat Linux - ruby-on-rails

On RedHat Enterprise Linux 5 the latest Ruby version available via RPM is 1.8.5. My Rails app requires 1.8.6 or above so I need to compile Ruby from source.
I have tried the following to build it and it seems to build ok, but then I'm seeing gcc compilation errors when trying to run a plug-in which requires RubyInline.
There seems to be a lack of decent documentation for building Ruby from source, suitable for running Rails apps.
Here's how I compiled Ruby:
./configure --prefix=/usr --with-openssl-include=/usr/include/openssl --with-openssl-lib=/usr/lib64/openssl/engines
make
sudo make install
I wonder whether there are specific compile flags I need to build this on a 64-bit system. The actual error I'm seeing is
error executing "gcc -shared -fPIC -g -O2 -I /usr/lib/ruby/1.8/x86_64-linux -I /usr/include -L/usr/lib -o \"/home/deploy/.ruby_inline/Inline_ImageScience_aa58.so\" \"/home/deploy/.ruby_inline/Inline_ImageScience_aa58.c\" -lfreeimage -lstdc++ ":
Any advice would be greatly appreciated

The best way would probably be to just "steal" a Ruby 1.8.6 RPM from Fedora. The second best way would be to steal a Ruby 1.8.6 SRPM from Fedora and build it yourself.
However, there is one thing you could do: add a --disable-pthread flag to the configure line and remove --enable-pthread if it's there. --enable-pthread makes MRI significantly slower, and is only needed if you want to use Ruby/Tk and your system's Tk library was built with --enable-pthread.

Ruby packages for Fedora (including SRPM)
Couldn't post as a comment on the correct answer so added here - editors feel free to tidy-up.

Related

How to build clang with the memtag sanitiser enabled

I have spent a few hours trying to get the built-from-sources version of clang (v15) to work with the memtag sanitiser. For those of you who don't know what that is, it is simply a version of the address sanitiser that leverages the Memory Tagging features of ARM.
Anyway, while I can use it normally with the repository version of clang (v10), using the version built from sources just does not work.
Here is the command I use for both: clang main.c -S -march=armv8+memtag -fsanitize=memtag with clang which is either the repository-version or the built-from-sources version. Although the former works seamlessly, the latter does not.
I've tried to built llvm with different parameters, but none seemed to have done the trick. Here's my current building configuration:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;openmp;polly;pstl;compiler-rt" -DLLVM_TARGETS_TO_BUILD="AArch64" ../llvm
I wonder if there is some parameter I have to specify to build clang with this sanitiser enabled.
PS: using the -fsanitize=memtag flag does not give any error: with the built version of clang it simply does not insert the instrumentation code.
If anybody is able to give me some insight I would really appreciate it. Thanks ;)

Is there another version of the binutils for x86_64?

I am trying to install a cross-compiler following instructions that I found here. I am using the 64 bit version of Ubuntu 13.10. As soon as I entered the command to configure the binutils I get:
Configuring for a x86_64-unknown-linux-gnu host.
Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized
Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized
Unrecognized host system name x86_64-unknown-linux-gnu.
Is there really a 64-bit version of the binutils? If not, can anyone tell me what commands to enter to avoid this error?
After a little googleing I found a post. In this post the author explains that all you have to do in order to install the binutils on a 64-bit linux system is fool the system by typing "linux32" before your command. For example in this case it would be:
linux32 ./configure
linux32 make
linux32 make install
to build for a regular compiler and this:
linux32 ./configure --target=$TARGET --prefix="$PREFIX" --disable-nls
linux32 make
linux32 make install
to build for a cross-compiler.
I got the same error with binutils-2.9.I just used binutils-2.28(a lower version) and it worked for me.

OpenSSL error building Erlang OTP from source

Trying to build a completely self-contained OTP that can be moved around independently of libs installed on a system.
Build OpenSSL 1.0.0d from source as follows:
./config --prefix=<open-ssl-dir>
make
make install
Then OTP R14B03:
./configure --prefix=<erlang-dir> --with-ssl=<open-ssl-dir> --without-termcap
Make of Erlang then fails as follows:
relocation R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a shared object; recompile with -fPIC
We're talking Ubuntu 10.04. Any help greatly appreciated - thanks!
The "can not be used when making a shared object; recompile with -fPIC" would mean SSL is not build with the Position Independent Code flag. This is needed for building it as a Dynamic Shared Object (DSO). This is probably needed by Erlang build process. Example build:
$ tar zxvf openssl-0.x.tar.gz
$ cd openssl-x
$ sh config shared -fPIC
$ make
$ sudo make install
For ppc64le:
./configure --prefix=/home/huaxin/huaxin/toolsInstalled/ --build=ppc64le CFLAGS="-D_GNU_SOURCE -DOPENSSL_NO_EC=1"
I suggest that you build on a VM where you have sudo permissions. Then build libraries like OpenSSL using --prefix=/usr so that make install puts them in the usual system library.
Then build your tool, in this case Erlang, using -rpath. Then use ldd to find all library dependencies for Erlang and any ports (C extensions) and copy those into Erlangs lib directory. Check all binaries and libraries with readelf -d to make sure that RPATH is set to $ORIGIN or $ORIGIN/../lib as needed. Use patchelf to fix these things if the linking process is not quite right (or you copied in secondary dependencies of system libraries).
Then use patchelf to set the interpreter for your binaries (not libraries) to point to ld-linux.so.2 in Erlang's lib directory. And then run a test suite using
strace -e open erl ... to make sure that your build is not opening anything in /lib or /usr/lib.
At this point tar it up and it will run on any Linux.
See this question Compiling Python 2.6.6 and need for external packages wxPython, setuptools, etc... in Ubuntu for far more detail on how I built Python in this fashion.

Can't install ruby 1.9.1 on MacOSX 10.6

I can't seem to be get Ruby installed on my Mac. These are the steps I've taken so far:
Downloaded the package from Ruby's site (http://www.ruby-lang.org/en/downloads/)
Unpacked it running { tar xzvf ruby-1.9.1-p376.tar.gz }
Went into the new ruby folder, and configured using {./configure}
This is where the error happens. When I run the configure, it gives me the error:
/usr/local/include/fuse/fuse_common.h:32:2: error: #error Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
In file included from /usr/local/include/fuse/fuse.h:857,
from <command-line>:0:
/usr/local/include/fuse/fuse_compat.h:69:24: error: sys/statfs.h: No such file or directory
As a result, I can't make the package nor install it. I have no idea what is wrong. Any help is greatly appreciated. Thanks!
Have you tried RVM? It lets you manage multiple versions of ruby and will take of installing them and managing any gem versions for you. It's pretty magic!
After you've installed it all you need to do is:
`rvm install 1.9`
Done!
If the last line of configure output is
config.status: creating Makefile
then you have a makefile and you can try building it.
I got the fuse.h error, and just ran make to build a working ruby:
[neilk#maczombie ~]$ ruby --version
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10.2.0]
Looks like others have run into this issue.
If you want need the binary, you could try rubyosx.
I guessing that the issue is that you have FUSE (or MacFUSE) installed in /usr/local and for whatever reason, the configure phase is doing something that's including it. If you're not trying to build ruby with some local extensions, but you want to build ruby yourself, try moving aside /usr/local (at least temporarily).
sudo mv /usr/local /usr/local.aside
(Beware, randomly messing with /usr and /usr/local directories can lead to trouble.)
What happens if you set C_Flags or CPP_Flags before doing your ./configure?
This isnt ananswer so much as a suggested alternative... use macports :-)

Erlang: Building Issue of not finding Ncurses on Solaris 10

I am trying to build Erlang on Solaris 10. The build process fails with the message that it can not find libncurses.so.5.
I have installed libncurses from sunfreeware.com, which I have build from scratch and has installed itself in /usr/local/lib/.
I have tried to set LDFLAGS with -L/usr/local/lib/ but have still had no luck.
What am I missing so that make picks up the library?
I am using GNU Make 3.81 and GCC 3.4.6.
Could you post the relevant bit from config.log?
Did you also set the include path with -I in either CPPFLAGS or CFLAGS?
Update: You could also try installing Erlang from OpenCSW instead.

Resources