64-bit Computing
This page contains notes on running on a 64-bit OS. For notes specific to Scientific Linux 5 (not just 64-bit SL5), please see ScientificLinux5.
When building on a 32-bit machine, you will produce a 32-bit executable. When building on a 64-bit machine, you can specify the target architecture to produce a 32-bit executable. Otherwise, you will produce a 64-bit executable if you build on a 64-bit machine and don't specify the target architecture.
Application Support
setarch
The command,
setarch
, can be used to change the reported architecture in new program environment. For example,
setarch i386 program
will cause "program" to see i686 instead of x86_64 as the machine type. See
man setarch
for more information.
With a 64-bit operating system, by default both firefox and its plugins are 64-bit. Some java applications (for example) require a 32-bit java plugin. To use these applications, you would need to start firefox in 32-bit mode. This can be done using
setarch i386 firefox
.
Totalview can be run from any linux computer using
/nfs/opt/totalview/bin/totalview
If you're debugging a 32-bit (i386) executable on a 64-bit machine, you can use
linux32 /nfs/opt/toolworks/totalview.8.9.2-2/linux-x86/bin/tv8
Please see the
TotalView Debugger Documentation section of the
Accelerator Physics Code Libraries wiki.
If you are on a 64-bit system, matlab will start in 64-bit mode. You can force 32-bit mode using the
-glnx86 option.
If you are on SL5,
matlab will start 2010a. Otherwise,
matlab will start 2007b. You can force a specific version of matlab using, for example
-r 2007b or
-r 2010a.
For example, Matlab 2007b can be run in 32-bit mode using
matlab -r 2007b -glnx86
For more information, please see the
Matlab wiki.
Java
All native binary code that was written for a 32-bit VM must be recompiled for use in a 64-bit VM. For more information, please see
Frequently Asked Questions About the Java HotSpot VM.
In order to work on both 32-bit and 64-bit systems,
~/.java/deployment/deployment.properties
needs to be updated to support both 32 and 64-bit OS's. If you have trouble running
javaws on a 32-bit or 64-bit OS, this can be fixed as follows:
-
mv ~/.java/deployment/deployment.properties ~/.java/deployment/deployment.properties.bk
- create a new ~/.java/deployment/deployment.properties that contains the following (replace "dab66" with your username)
#deployment.properties
#Tue Aug 31 17:23:01 EDT 2010
deployment.javaws.splash.index=/home/dab66/.java/deployment/cache/6.0/splash/splash.xml
deployment.version=6.0
deployment.javapi.cache.update=true
deployment.browser.path=/usr/bin/firefox
#Java Deployment jre's
#Tue Aug 31 17:23:01 EDT 2010
deployment.javaws.jre.0.product=1.6.0_24
deployment.javaws.jre.0.registered=false
deployment.javaws.jre.0.osname=Linux
deployment.javaws.jre.0.platform=1.6
deployment.javaws.jre.0.path=/usr/java/default/jre/bin/java
deployment.javaws.jre.0.location=http\://java.sun.com/products/autodl/j2se
deployment.javaws.jre.0.enabled=true
deployment.javaws.jre.0.osarch=i386
deployment.javaws.jre.1.product=1.6.0_24
deployment.javaws.jre.1.registered=false
deployment.javaws.jre.1.osname=Linux
deployment.javaws.jre.1.platform=1.6
deployment.javaws.jre.1.path=/usr/java/default/jre/bin/java
deployment.javaws.jre.1.location=http\://java.sun.com/products/autodl/j2se
deployment.javaws.jre.1.enabled=true
deployment.javaws.jre.1.osarch=amd64
- In the third line of the new deployment.properties file, replace "dab66" with your LEPP Unix username
EPICS
To build 32-bit apps on a 64-bit OS, the following lines will need to be added to the source Makefile (or possibly a more central location, such as CONFIG.Common.linux-x86):
ARCH_DEP_CFLAGS += -m32
ARCH_DEP_LDFLAGS += -m32
GCC
To compile a 32-bit C/C++ application for Scientific Linux running on a 64-bit platform, use the gcc option -m32. According to the man page for gcc, the -m32 option sets int, long, and pointer variables to 32 bits (4 bytes). The -m64 option sets int to 32 bits (4 bytes) and long & pointer to 64 bits (8 bytes).
The following segment of code demonstrates this:
#include <stdio.h>
int main()
{
int i;
long l;
char *p;
printf("Integer size: %i bytes\\n", sizeof(i));
printf("Long Integer size: %i bytes\\n", sizeof(l));
printf("Pointer size: %i bytes\\n", sizeof(p));
return 0;
}
The following is a comparison of the output when compiled with the -m32 and -m64 options:
# gcc -o ./test.64 -m64 test.c
# gcc -o ./test.32 -m32 test.c
#
# ./test.64
Integer size: 4 bytes
Long Integer size: 8 bytes
Pointer size: 8 bytes
#
# ./test.32
Integer size: 4 bytes
Long Integer size: 4 bytes
Pointer size: 4 bytes
ld (The GNU linker)
With a 64-bit OS, 32-bit libraries are stored in new directories that may need to be added to your library search path. This includes, at least,
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/32 and
/usr/lib/gcc/x86_64-redhat-linux/4.1.1/32.
For some makefiles, this can be handled by adding the following to the beginning of your make file.
LOCAL_LFLAGS := -L /usr/lib/gcc/x86_64-redhat-linux/3.4.6/32 -L /usr/lib/gcc/x86_64-redhat-linux/4.1.1/32