www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DMD, LDC, and GDC compilers and 32/64 bit

reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
I believe DMD, LDC, and GDC all have the -m32 or -m64 option to
determine the word size of compiled object and executable.

I also believe there are 32-bit and 64-bit builds of the three
compilers. Or are there?

It appears at some time in the past that some of the compilers when
compiled as 32-bit executables, could not generate 64-bit objects and
executables as they did not understand the -m64 option, it was not
compiled in.

I am asking this as I cannot test to get experimental data, but I need
to fix a long standing removal of a test in the SCons D test suite.

Is there a way to determine the bitsize of the compiler executable, in
the test it is assumed that if the OS is 32-bit then so are the D
compilers.

--=20
Russel.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
et
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Jun 18
next sibling parent Basile B. <b2.temp gmx.com> writes:
On Sunday, 18 June 2017 at 16:08:36 UTC, Russel Winder wrote:
 I believe DMD, LDC, and GDC all have the -m32 or -m64 option to 
 determine the word size of compiled object and executable.

 I also believe there are 32-bit and 64-bit builds of the three 
 compilers. Or are there?

 It appears at some time in the past that some of the compilers 
 when compiled as 32-bit executables, could not generate 64-bit 
 objects and executables as they did not understand the -m64 
 option, it was not compiled in.

 I am asking this as I cannot test to get experimental data, but 
 I need to fix a long standing removal of a test in the SCons D 
 test suite.

 Is there a way to determine the bitsize of the compiler 
 executable, in the test it is assumed that if the OS is 32-bit 
 then so are the D compilers.
I'm not sure to understand correctly the question but let's try: With version(), e.g version(X86){/*arch is i386 or -m32 is set*/} version(X86_64){/*arch is amd64* or -m64 is set/} You can know.
Jun 18
prev sibling parent reply Eugene Wissner <belka caraus.de> writes:
On Sunday, 18 June 2017 at 16:08:36 UTC, Russel Winder wrote:
 I believe DMD, LDC, and GDC all have the -m32 or -m64 option to 
 determine the word size of compiled object and executable.

 I also believe there are 32-bit and 64-bit builds of the three 
 compilers. Or are there?

 It appears at some time in the past that some of the compilers 
 when compiled as 32-bit executables, could not generate 64-bit 
 objects and executables as they did not understand the -m64 
 option, it was not compiled in.

 I am asking this as I cannot test to get experimental data, but 
 I need to fix a long standing removal of a test in the SCons D 
 test suite.

 Is there a way to determine the bitsize of the compiler 
 executable, in the test it is assumed that if the OS is 32-bit 
 then so are the D compilers.
On linux "file" gives you such information about an executable.
Jun 18
parent Eugene Wissner <belka caraus.de> writes:
On Sunday, 18 June 2017 at 17:57:28 UTC, Eugene Wissner wrote:
 On Sunday, 18 June 2017 at 16:08:36 UTC, Russel Winder wrote:
 I believe DMD, LDC, and GDC all have the -m32 or -m64 option 
 to determine the word size of compiled object and executable.

 I also believe there are 32-bit and 64-bit builds of the three 
 compilers. Or are there?

 It appears at some time in the past that some of the compilers 
 when compiled as 32-bit executables, could not generate 64-bit 
 objects and executables as they did not understand the -m64 
 option, it was not compiled in.

 I am asking this as I cannot test to get experimental data, 
 but I need to fix a long standing removal of a test in the 
 SCons D test suite.

 Is there a way to determine the bitsize of the compiler 
 executable, in the test it is assumed that if the OS is 32-bit 
 then so are the D compilers.
On linux "file" gives you such information about an executable.
Sample output on Slackware (multilib distros like ubuntu/debian are different): belka[19:55]:~$ file /usr/bin/gcc-5.3.0 /usr/bin/gcc-5.3.0: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, stripped
Jun 18