www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6142] New: 32- and 64-bit libraries are combined without error

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6142

           Summary: 32- and 64-bit libraries are combined without error
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bugzilla kyllingen.net



06:58:20 PDT ---
DMD will happily combine static library files for different architectures. 
This confuses the linker.

Steps to reproduce (performed on 64-bit Linux):

1. Write libfoo.d.

    void foo() { }

2. Write libbar.d.

    void bar() { }

3. Compile libfoo as 32-bit library.

    dmd -lib -m32 libfoo.d

4. Compile libbar as 64-bit library, including libfoo.

    dmd -lib -m64 -oflibbar.a libfoo.a libbar.d

5. Compile any program with -m64 -lbar

    /usr/bin/ld: skipping incompatible ./libbar.a when searching for -lbar
    /usr/bin/ld: cannot find -lbar

ld accepts the library if -m32 is specified in step 5, but complains about the
64-bit object files.

This is the model upon which druntime+Phobos is compiled.  I spent an hour
trying to figure out why the linker didn't recognise the 64-bit libphobos2.a,
until I realised that it had been compiled with a 32-bit version of
libdruntime.a. :(

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6142




07:01:19 PDT ---
Simple solution:  Detect architecture of the first object file in the archive
and take that to be the architecture of the library.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2011