add "-m32" to root-config --cflags?

From: Konstantin Olchanski <olchansk_at_triumf.ca>
Date: Wed, 28 Mar 2007 13:12:44 -0700

Hi, all!

The 64-bit "root-config --cflags" adds the "-m64" compiler switch to tell GCC to compile user code as 64-bit (arch=linuxx8664gcc).

But the corresponding 32-bit "root-config --cflags" does not add the "-m32" compiler switch to compile user code as 32-bit. (arch=linux).

This causes problems with using 32-bit ROOT on 64-bit machines, for example when using a fast 64-bit machine to crosscompile applications that will run on a slow 32-bit machine.

What happens is that GCC installed on 64-bit Linux is usually configured to produce 64-bit code by default. Generic Makefiles are usually written to use
CFLAGS=$(shell $(ROOTSYS)/bin/root-config --cflags) so all code is compiled as 64-bit (no "-m32" !!!) and then fails to link against the 32-bit ROOT libraries, with a misleading error message "/usr/bin/ld: cannot find -lCore".

The experienced user then curses, edits the Makefile to add "-m32", and all is well until the same Makefile is used to compile the code for 64-bit use, at which time things explode again from a conflict between "-m32" manually added to the Makefile and "-m64" coming from "root-config --cflags". This is exactly the situation that use of "root-config --cflags" is supposed to prevent.

I suggest that "-m32" be added to "root-config --cflags" for 32-bit Linux. AFAIK, all known 32-bit Linux GCC versions accept this flag and do the correct thing.

-- 
Konstantin Olchanski
Data Acquisition Systems: The Bytes Must Flow!
Email: olchansk-at-triumf-dot-ca
Snail mail: 4004 Wesbrook Mall, TRIUMF, Vancouver, B.C., V6T 2A3, Canada
Received on Wed Mar 28 2007 - 22:12:51 CEST

This archive was generated by hypermail 2.2.0 : Wed Mar 28 2007 - 23:50:01 CEST