Does MacRuby support static compilation? - static

Does the latest version of MacRuby support static compilation?
Here's some terminal output from an attempt to use it... It shows up in the options for the macrubyc command.
Desktop > macrubyc play_all_podcasts.rb --static -o play_all_podcasts
/usr/local/bin/macrubyc:100:in `initialize': This version of MacRuby does not support static compilation. (ArgumentError)
from /usr/local/bin/macrubyc:490:in `<main>'
Desktop > macrubyc -v
MacRuby 0.11 (ruby 1.9.2) [universal-darwin10.0, x86_64]
Desktop > macrubyc --help
Usage: macrubyc [options] file...
-c Compile and assemble, but do not link
-o <file> Place the output into <file>
--static Create a standalone static executable
--framework <name> Link standalone static executable with given framework
--sdk <path> Use SDK when compiling standalone static executable
--dylib Create a dynamic library
--compatibility_version <VERSION>
Compatibility Version for linking
--current_version <VERSION> Current Version for linking
--install_name <NAME> Install Name for linking
-C Compile, assemble and link a loadable object file
-a, --arch <ARCH> Compile for specified CPU architecture
-V, --verbose Print every command line executed
-v, --version Display the version
-h, --help Display this information

From what I've gathered, static compilation is still a work and progress and most likely won't even be included in the 1.0 release.

Related

How to compile neon on ARM

I used the
arm-linux-gnueabi-g++ test.cpp -march=armv7-a -mfloat-abi=softfp -mfpu=neon -o test
on ubantu to get an excecutable file on ARM, but when I ran
adb push ./test /data/test
adb shell
cd data
chmod 777 test
./test
I got the following error:
./system/bin/sh: ./test: No such file or directory
I was confused about this.
If you intend to run the executable on Android (as it seems), you should ideally build it using the Android NDK. The problem is that your executable links to glibc which is available on normal linux systems, but not on Android. (In detail, the executable can't start because it requires the dynamic linker /lib/ld-linux.so.3 which isn't available on Android. In addition, it also requires glibc in the form of libc.so.6.)
If you build executables using the Android NDK, it will link to the Bionic libc, which is what is available on Android.
Alternatively, if you add -static when linking (in your case, in your single compile+link command), you'll get a static executable, which should work on both normal linux and Android.

Enabling Sanitizers on clang

I built clang-4.0 from the source. When I tried to use the "Undefined Behaviour" sanitizer, I got the following output.
$ clang -fsanitize=undefined parallel_big_loop.c
/usr/bin/ld: cannot find /home/user/Software/polly/llvm_build/bin/../lib/clang/4.0.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a: No such file or directory
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
Using Ubuntu 14.04.5 amd64, linux 4.4.0-31-generic.
How can I indicate CMake to include it during build ?
According to official Clang guideline: http://clang.llvm.org/get_started.html
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
cd llvm/projects
# This repository is responsible for sanitizers
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd ../..
# in-tree build is not supported
mkdir build
cd build
cmake -G"Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/clang/ ../llvm/
ninja
Instead of ninja you can of course use make, and if you don't like svn you can use this Github repository https://github.com/llvm-mirror

C: GTK+ 3.0 (3.20) - Cross-Compile from GNU/Linux (Arch Linux) to Windows

I need to cross-compile GTK+ application from GNU/Linux (Arch Linux) to Windows. I have already tried to use mingw32, but it does not see all libraries (including c's standard library!). So, I need to: find the standard libary; find all other (glib, gio, gtk, etc) libraries. But there's a problemm - I cannot find them. I also cannot compile from Windows. What must I do?
You can find the binaries for gtk 3 for windows on source forge or on http://win32builder.gnome.org/.
Once you have extracted them, you can follow this tutorial steps:
1) Install the compilation toolchain
Install the GCC compiler for Windows (namely MinGW, Arch Linux doc of package):
#pacman -S migw-w64
Download the latest all-in-one bundle ZIP archive directly from the official website (here's a direct link)
Adapt GTK+ to its location : In a terminal, move to the "gtk3-win32" folder you just created. For example: $cd /opt/gtk3-win32
then do :
find -name '*.pc' | while read pc; do sed -e "s#^prefix=.*#prefix=$PWD#" -i "$pc"; done
2) Compile
We will tell pkg-config to locate GTK+3 libraries in our custom path. If you extracted to /opt/gtk3-win32:
export PKG_CONFIG_PATH=/opt/gtk3-win32/lib/pkgconfig
We are ready to compile a sample C source ! Let's use a command in this style :
i586-mingw32msvc-gcc source.c -o executable.exe `pkg-config --cflags --libs gtk+-3.0
A new executable should have been created if everything went well.
It won't run on our Linux system, because it's targeting Windows !
3) Release
Create a folder containing the binary and the Windows .dll files. If you extracted to /opt/gtk3-win32:
mkdir ~/distri
cp executable.exe ~/distri
cp /opt/gtk3-win32/bin/*.dll ~/distri
Here we go ! Transfer this folder to a Windows box. Double-click on the executable and...
The following instructions are for gcc 5.3.0 (thread model: posix) and gtk+ 3.20.4
Install msys2 on windows
Install gtk3 files and copy the files
After installation, in msys2 shell
pacman -S mingw-w64-i686-gtk3
cd /mingw32
tar cfz c:/temp/mingw32.tar.gz
Ensure matching gcc version on Arch Linux
For gcc 5.3.0, edit /etc/pacman.conf
[core]
Server = https://archive.archlinux.org/repos/2016/05/10/$repo/os/$arch
[extra]
Server = https://archive.archlinux.org/repos/2016/05/10/$repo/os/$arch
[community]
Server = https://archive.archlinux.org/repos/2016/05/10/$repo/os/$arch
In case of upgrade
pacman -Syu
In case of downgrade
pacman -Syyuu
Later Arch Linux version seem to have gcc 6.1.1 that might be incompatible with msys2 gcc. A virtual machine might be a good idea for an Arch Linux installation that will not be upgraded (i.e. no security updates).
Copy files to linux
Unpack mingw32.tar.gz on linux, for example /opt/mingw32
Modify pkg-config files
perl -pi.bak -e 's,^prefix=.*,prefix=/opt/mingw32,' /opt/mingw32/lib/pkgconfig/*.pc
Set PKG_CONFIG_PATH
For example, before executing a configure script
export PKG_CONFIG_PATH=/opt/mingw32/lib/pkgconfig

linking clang address sanitizer on FreeBSD 10.1 Release

I'm trying to get address sanitizer working on FreeBSD 10.1 Release, but whenever I try to compile a program with -fsanitize=address I get undefined references to _asan_stack_malloc_1 etc, etc. I found
https://forums.freebsd.org/threads/gcc-clang-address-sanitizer.47985/ on google but the suggestion of adding -L/usr/local/lib -I/usr/local/include didn't resolve the linking issue. I tried the llvm binaries for FreeBSD but when I go to compile with that clang I get /usr/bin/../lib/clang/3.6.0/lib/freebsd/libclang_rt.asan-x86_64.a , no such file or directory. . Either way I'm not sure what library I need to link or where it is.
Below is the program I tried compiling and here is the command I used,
clang -fsanitize=address san.c
#include <stdio.h>
int main(void)
{
return 0;
}
As an alternative to building LLVM, as suggested in this answer on Unix SE, you can install llvm37 from ports, which supports AddressSanitizer, and build with that:
# pkg install llvm37
$ clang37 -fsanitize=address san.c
To use asan on FreeBSD you can build llvm with asan support as shown below or you can install from packages/ports like in Kevinoid's answer.
Step one, grab the latest stable llvm source.
fetch http://llvm.org/releases/3.9.0/llvm-3.9.0.src.tar.xz
Now uncompress the llvm source directory.
tar -xvf llvm-3.9.0.src.tar.xz
Next change directory to llvm and grab the clang source files.
cd llvm-3.9.0.src/tools && fetch http://llvm.org/releases/3.9.0/cfe-3.9.0.src.tar.xz
Uncompress clang.
tar -xvf cfe-3.9.0.src.tar.xz
Enter the projects directory and grab compiler-rt.
cd ../projects && fetch http://llvm.org/releases/3.9.0/compiler-rt-3.9.0.src.tar.xz
Uncompress compiler-rt.
tar -xvf compiler-rt-3.9.0.src.tar.xz
Goto the root llvm directory and make a build directory for cmake.
cd ../ && mkdir build && cd build
Use cmake to setup the llvm build.
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON [-DLLVM_ENABLE_WERROR=ON] [-DLLVM_TARGETS_TO_BUILD=X86] -DBUILD_SHARED_LIBS=ON ../
Build llvm and go grab some tea, it will take a bit.
make -j12
If the build worked you should be left with clang with asan support. Make sure to remove the old compiler, /usr/bin/clang, /usr/bin/clang++ and /usr/bin/cc.
Then install the new clang by doing sudo make install. Finally you will probably want to link /usr/bin/cc to /usr/local/bin/clang by running sudo ln /usr/local/bin/clang /usr/bin/cc.
After doing all these steps you should be able to compile code with the -fsanitize=address compile option.

-mno-cygwin : gcc building Mercurial (Windows 2000)

Because the Mercurial Installer will not work on an old Windows 2000 system, I'm trying to build it from source. Its complaining that the C Compiler doesn't recognize the option -mno-cygwin. My version of gcc is 4.6.1. and MinGw is only two months old.
Followed these steps: https://www.mercurial-scm.org/wiki/BuildingOnWindows
F:\mercurial-2.0.2>python setup.py build
running build
running build_mo
warning: hgbuildmo: could not find msgfmt executable, no translations will be built
running build_py
package init file 'mercurial\__init__.py' not found (or not a regular file)
package init file 'mercurial\__init__.py' not found (or not a regular file)
running build_ext
building 'mercurial.base85' extension
f:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -If:\python27\include
-If:\python27\PC -c mercurial/base85.c -o build\temp.win32-2.7\Release\mercurial\base85.o
**cc1.exe: error: unrecognized command line option '-mno-cygwin'**
error: command 'gcc' failed with exit status 1
From a comment by a TDM-GCC MinGW distro developer:
As of the 4.6 series, GCC no longer accepts many unrecognized options
or flags. TDM-GCC has never "supported" -mno-cygwin; now, it will
complain about it. This is also true for libtool flags such as
"-no-undefined".
So you may have to use a somewhat older GCC version that will ignore the meaningless option, or fix the build scripts so they don't use that flag (which would never be necessary with the MinGW compiler anyway).
As a follow-on note, it looks like the Cygwin compiler stopped supporting -mno-cygwin starting with GCC 4: http://www.cygwin.com/ml/cygwin/2009-03/msg00802.html
So that option has been more or less useless for a couple years.
You not to forget this step before running "python setup.py build"?
If using mingw, a setup.cfg needs to be created which directs setuptools to use it:
cd mercurial
echo [build] > setup.cfg
echo compiler=mingw32 >> setup.cfg

Resources