Linux hosted mingw w64 C,C++ and Java cross compiler

Hi everyone !

As i said in my previous article, i want to share with you about the steps to get a fully working w64-mingw32 gcc and gcj 4.6.0 toolchain. I’ll try to be as accurate as possible. Despite of all my efforts, I didn’t manage to get the multilib compiler to build, so I will only describe the steps to get an i686 compiler. Most of the content of this post is based upon mingw w64 instructions, but as I didn’t manage to get it fully compiling following theses instructions, that’s why I’m writing this post.

The times given in this article are thoses obtained with an Intel Xeon CPU X5560 @ 2.80GHz.
The gcc version used was:
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48).

Pre-requisites

  • Native working gcc/gcj installed (at least 4.1), for i686 architecture
  • Environment variables:
    • $work = directory where to work (for example, $HOME/mingw)
    • $prefix = directory where to install the cross compiler (for example, $work/root)
    • $CFLAGS = optimization flags (for example “-march=core2 -mtune=core2 -O2 -pipe”, see Safe CFLAGS for how to define them),
  • Directories:
    • mkdir -p $work/sources $work/tarballs $work/builds $prefix

Sources

Retrieve the following sources in the directory $work/tarballs:

  1. binutils 2.21.51
  2. gcc 4.6.1 20110401: core, g++, java, fix for libjava build error, fix for boehm-gc dll exports, fix for gcj spec file
  3. mingw-w64-trunk-r4105-20110404
  4. ecj 4.5
  5. ppl 11.2, cloog 0.16.2
  6. mpfr 3.0.1, gmp 5.0.1, mpc 0.9

Once everything is retrieved, check that files you downloaded are valid using provided sha1sums.txt (download it to $work/tarballs) and the following command:

# cd $work/tarballs
# sha1sum -c sha1sums.txt
binutils-2.21.51.tar.bz2: OK
cloog-0.16.2.tar.gz: OK
ecj-4.5.jar: OK
gcc-4.6.1-20110401-fix-boehm-gc-dll-export.patch: OK
gcc-4.6.1-20110401-fix-gcj-spec-file.patch: OK
gcc-4.6.1-20110401-fix-libjava-reflect-build-error.patch: OK
gcc-core-4.6-20110401.tar.bz2: OK
gcc-g++-4.6-20110401.tar.bz2: OK
gcc-java-4.6-20110401.tar.bz2: OK
gmp-5.0.1.tar.bz2: OK
mingw-w64-trunk-r4105-20110404.tbz2: OK
mpc-0.9.tar.gz: OK
mpfr-3.0.1.tar.bz2: OK
ppl-0.11.2.tar.bz2: OK

Read more »

How to use git cvs frontend

As my company is still using CVS as a software revision control system, and as I am used to Git and cannot work without it, i had to deal with the git-cvs front end. I have to say that it is not so easy to use it, because there is not a lot of maintainers, and also a lack of users. So i had to made some scripts to get it to work in an automatic way.

In this tutorial, the following prerequisites are expected:

  • You have Git installed,
  • You have CVS installed,
  • You have cvsps installed,
  • You have an existing CVS repository,
  • You defined the environment variable CVSROOT correctly and already logged in to CVS with “cvs login”,
  • You defined the environment variable CVSMODULE with the name of your CVS module you want to import into Git,
  • You defined the environment variable WORKDIR with the name of your working directory (ie where you want the repository),
  • You have basic knowledges about Git and CVS (ie you know and understand how to do following operations: checkout, commit, update).

Read more »

Dealing with MinGw cross compiler

Since i’m working on an open-source project to provide easy-to-use asynchronous network I/O framework, and with the aim to make this project as portable as possible, i had to deal with building a cross-compiler for Windows platform, and i’m sorry to say that it wasn’t an «out-of-the-box» task.

When i first started this, i tried to use Mingw, but their website was just hacked the same time i needed it, so back on google, where i found w64 cross compiler project. The documentation was quite easy to follow, and it took me around 1 day to get it working.

I followed theses instructions with an half success. Actually, they are saying that we can build a multilib compiler, but i found out that only the 32 bits compiler was able to build. For the multilib, it fails to build because of incompatible registers name in the early stage 1 of gcc. Also, i wanted to use JNI interface without the need to uses a JDK (mostly because JNI headers are not located in standard locations, for instance with Gentoo, it was under /opt), so i needed to build the GCJ compiler, which is mostly a pain in the ass ! First of all, it seems the cross-compiling is very difficult to reach, mostly because it seems there is no maintainers for the Makefiles, for example, compiling ecjx.exe fails with original sources, as it is trying to build it with the cross compiler, instead of the host’s one. Fixing it was not easy, but i manage to get it to work.

Well, after some time tweaking the Makefiles by myself, i finally got my w64-mingw32 gcc 4.6.0 compiler, and it’s working like a charm. I managed to use most of win32 API without any problem, except that for Condition Variables, i had to take the mingw trunk crt.

So if some of you needs help to develop portable applications for both Win32 and Linux, i am now able to point you things out 😉

In a future article, i will try to describe the steps to have a fully working i686-w64-mingw32-{gcc,ecj} toolchain, so see you soon !

French gentoo mirrors

I have one dedicated server on which is located this blog, and i provide Gentoo mirrors on both IPv4 and IPv6, for syncing portage tree through Rsync, or getting latests distfiles. Hereby are the needed informations to access these :

The bug number on bugs.gentoo.org is #184177 . You can report me bugs or problems regarding these mirrors on gentoo.mirrors@linuxant.fr , or using comments on this article.

Hope this will help the Gentoo Community,

Dynamic DNS using Bind

Today, we’ll see how to configure bind to perform dynamic DNS updates according to your public IP address changes.

Prerequisites: net-dns/bind, net-dns/bind-tools, control a nameserver and a domain of course

First, we have to use a TSIG key, which will be used by server to allow someone to update a zone, and by the client to identify itself to the nameserver. To generate one, issue the following on your favorite shell prompt:

dnssec-keygen -a HMAC-SHA512 -b 512 -n HOST yourkey

This will generate two files in the current directory named Kyourkey.+xxx+yyyy.key containing the public key and Kyourkey.+xxx+yyyy.private containing the private key, where xxx stand for the algorithm identifier (for HMAC-SHA512, 161) and yyyy is the id of the key.

Then, assuming you will name your dynamic host dyn.example.com, and the zone is then example.com, you have to edit the /etc/bind/named.conf to add first the allowed key, and then the update-policy for the zone example.com:

key yourkey {
algorithm HMACSHA512;
secret [Key: data of the .private file];
};
[..snip..]
zone example.com {
[..snip..]
updatepolicy { grant yourkey name dyn.example.com. A; };
}

Some explanations now:
– with the key statement, you give a name to the private key, to reuse it later in the zone statement
– with the update-policy statement in the zone, you allow the key named yourkey to update the A record of dyn.example.com. (note the dot at the end: this is a FQDN)

Tip: You can use this update-policy statement to update more than the A statement

Then it is time to add the name dyn.example.com to the zonefile:

rndc freeze example.com

Then edit the zonefile of example.com adding the following:

$TTL 600
dyn IN A 0.0.0.0

Do not forget to update the SOA serial record to allows bind to propage the changes to the slaves nameservers, if any.
The IP address is 0.0.0.0 by default, and will be updated later from the client. The TTL is set to 600 (10 minutes), because a dynamic IP can change at anytime, so this allows the DNS cache servers to be quickly up-to-date, but keep in mind that a too short TTL imply much requests to your nameserver…
Finally, propage changes to bind:

rndc reload example.com
rndc thaw example.com

Then it’s time to update the IP address of your client. For this we will use nsupdate. You need to have both .key and .private files to get the update working.
If you use a modem line connected directly to your computer client, get your external/public IP address from your ppp0 interface, if you are connected to a local network, get your external IP address using websites like checkip.dyndns.org . For example, we will take 1.2.3.4 as your external IP address, assuming you use dns.example.com as primary nameserver:

nsupdate -v -k Kyourkey.+xxx+yyyy.key <<EOF
server dns.example.com
zone example.com.
update delete dyn.example.com. A
update add dyn.example.com. 600 A 1.2.3.4
send
EOF

And that’s done !

You can have a look using dig to get the IP address of your host:

dig @dns.example.com dyn.example.com A

Hello World !

under active writing

under active writing

This blog is actually under writing…
Be patient, some useful Gentoo tips may appears here soon 🙂