www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - -m64 doesn't work?

reply Andre Tampubolon <andre lc.vlsm.org> writes:
When I was looking at dmd's options, I found this:
m64 generate 64 bit code

I guessed it behaves like gcc (m64 for 64 bit code and m32 for 32 bit code,
assuming you have the multilibs), so I did a rebuild.
This is the structure of my /opt/dmd-dev
 
   |-bin (64-bit version of dmd, impcnvgen, idgen, optabgen, plus dmd.conf)
   |-import
   |---core
   |-----stdc
   |-----sync
   |-----sys
   |-------osx
   |---------mach
   |-------posix
   |---------arpa
   |---------net
   |---------netinet
   |---------sys
   |-------windows
   |-lib32 (libdruntime-linux32.a and libphobos.a)
   |-lib64 (libdruntime-linux64.a and libphobos.a)
   |-phobos
   |---std
   |-----c
   |-------freebsd
   |-------linux
   |-------osx
   |-------windows
   |-----internal
   |-------math
   |-------windows
   |-----net
   |-----windows

And this is my dmd.conf:
[Environment]
DFLAGS=-I/opt/dmd-dev/import -I/opt/dmd-dev/phobos -L-L/opt/dmd-dev/lib32
-L-L/opt/dmd-dev/lib64

dmd -32 works fine. But either dmd or dmd -m64 doesn't work, e.g:
$ dmd -m64 einstein2b.d
/usr/bin/ld: skipping incompatible /opt/dmd-dev/lib32//libphobos2.a when
searching for -lphobos2
/usr/bin/ld: cannot find -lphobos2
collect2: ld returned 1 exit status
--- errorlevel 1

I wonder why ld searches at /opt/dmd-dev/lib32, whereas it should be
/opt/dmd-dev/lib64 ?
Feb 12 2012
next sibling parent reply Trass3r <un known.com> writes:
   |-bin (64-bit version of dmd, impcnvgen, idgen, optabgen, plus  
 dmd.conf)

^^ You don't need impcnvgen, idgen and optabgen.
Feb 12 2012
parent Andre Tampubolon <andre lc.vlsm.org> writes:
Uhmm OK. But what does it do with dmd? I mean, dmd -m64 still doesn't work.

Anyway, I used to build both versions and put this on my ~/.bashrc:
alias dmd32='/opt/dmd-dev/bin32/dmd'
alias dmd64='/opt/dmd-dev/bin64/dmd'

But if a single dmd can generate both 32 and 64 bit code, it will be very
convenient.

On 02/12/2012 06:58 PM, Trass3r wrote:
   |-bin (64-bit version of dmd, impcnvgen, idgen, optabgen, plus dmd.conf)

^^ You don't need impcnvgen, idgen and optabgen.

Feb 12 2012
prev sibling next sibling parent reply Mike Wey <mike-wey example.com> writes:
On 02/12/2012 09:26 AM, Andre Tampubolon wrote:
 And this is my dmd.conf:
 [Environment]
 DFLAGS=-I/opt/dmd-dev/import -I/opt/dmd-dev/phobos -L-L/opt/dmd-dev/lib32
-L-L/opt/dmd-dev/lib64

Try adding -L--no-warn-search-mismatch -- Mike Wey
Feb 12 2012
parent reply Andre Tampubolon <andre lc.vlsm.org> writes:
Hmm doesn't work. The same error still applies.

On 02/12/2012 08:36 PM, Mike Wey wrote:
 On 02/12/2012 09:26 AM, Andre Tampubolon wrote:
 And this is my dmd.conf:
 [Environment]
 DFLAGS=-I/opt/dmd-dev/import -I/opt/dmd-dev/phobos -L-L/opt/dmd-dev/lib32
-L-L/opt/dmd-dev/lib64

Try adding -L--no-warn-search-mismatch

Feb 12 2012
parent reply Mike Wey <mike-wey example.com> writes:
On 02/12/2012 03:21 PM, Andre Tampubolon wrote:
 Hmm doesn't work. The same error still applies.

 On 02/12/2012 08:36 PM, Mike Wey wrote:
 On 02/12/2012 09:26 AM, Andre Tampubolon wrote:
 And this is my dmd.conf:
 [Environment]
 DFLAGS=-I/opt/dmd-dev/import -I/opt/dmd-dev/phobos -L-L/opt/dmd-dev/lib32
-L-L/opt/dmd-dev/lib64

Try adding -L--no-warn-search-mismatch


Can you post the output of dmd when compiling with: "-v" ? -- Mike Wey
Feb 12 2012
parent Andre Tampubolon <andre lc.vlsm.org> writes:
This is the log:
http://pastebin.com/bGt7MVd2

Anyway, I found the culprit, which is ~/dmd.conf. The content is:
[Environment]
DFLAGS=-I/opt/dmd-dev/import -I/opt/dmd-dev/phobos -L-L/opt/dmd-dev/lib32/

That's why dmd couldn't locate the 64 bit libs. I should use only 1 dmd.conf,
which is located in /opt/dmd-dev/bin.
Now -m64 works fine :)

On 02/12/2012 09:45 PM, Mike Wey wrote:
 On 02/12/2012 03:21 PM, Andre Tampubolon wrote:
 Hmm doesn't work. The same error still applies.

 On 02/12/2012 08:36 PM, Mike Wey wrote:
 On 02/12/2012 09:26 AM, Andre Tampubolon wrote:
 And this is my dmd.conf:
 [Environment]
 DFLAGS=-I/opt/dmd-dev/import -I/opt/dmd-dev/phobos -L-L/opt/dmd-dev/lib32
-L-L/opt/dmd-dev/lib64

Try adding -L--no-warn-search-mismatch


Can you post the output of dmd when compiling with: "-v" ?

Feb 12 2012
prev sibling parent reply "Michel Fortin" <michel.fortin michelf.com> writes:
On Sunday, 12 February 2012 at 08:26:07 UTC, Andre Tampubolon 
wrote:

  |-lib32 (libdruntime-linux32.a and libphobos.a)
  |-lib64 (libdruntime-linux64.a and libphobos.a)

... Are you sure it's libphobos.a and not libphobos2.a?
 dmd -32 works fine. But either dmd or dmd -m64 doesn't work, 
 e.g:
 $ dmd -m64 einstein2b.d
 /usr/bin/ld: skipping incompatible 
 /opt/dmd-dev/lib32//libphobos2.a when searching for -lphobos2
 /usr/bin/ld: cannot find -lphobos2
 collect2: ld returned 1 exit status
 --- errorlevel 1

 I wonder why ld searches at /opt/dmd-dev/lib32, whereas it 
 should be /opt/dmd-dev/lib64 ?

Actually it searches both directories all the time because dmd.conf adds the two to the link path. The theory is that the linker should just discard the wrong one. -- Michel Fortin michel.fortin michelf.com http://michelf.com
Feb 12 2012
parent Andre Tampubolon <andre lc.vlsm.org> writes:
Sorry, libphobos.a is a typo :)

On 02/12/2012 09:42 PM, Michel Fortin wrote:
 On Sunday, 12 February 2012 at 08:26:07 UTC, Andre Tampubolon wrote:
 
  |-lib32 (libdruntime-linux32.a and libphobos.a)
  |-lib64 (libdruntime-linux64.a and libphobos.a)

... Are you sure it's libphobos.a and not libphobos2.a?
 dmd -32 works fine. But either dmd or dmd -m64 doesn't work, e.g:
 $ dmd -m64 einstein2b.d
 /usr/bin/ld: skipping incompatible /opt/dmd-dev/lib32//libphobos2.a when
searching for -lphobos2
 /usr/bin/ld: cannot find -lphobos2
 collect2: ld returned 1 exit status
 --- errorlevel 1

 I wonder why ld searches at /opt/dmd-dev/lib32, whereas it should be
/opt/dmd-dev/lib64 ?

Actually it searches both directories all the time because dmd.conf adds the two to the link path. The theory is that the linker should just discard the wrong one. -- Michel Fortin michel.fortin michelf.com http://michelf.com

Feb 12 2012