Bug 6142 – 32- and 64-bit libraries are combined without error

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2011-06-10T06:58:20Z
Last change time
2024-12-13T17:55:29Z
Keywords
bootcamp
Assigned to
No Owner
Creator
Lars T. Kyllingstad
Moved to GitHub: dmd#18347 →

Comments

Comment #0 by post — 2011-06-10T06:58:20Z
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. :(
Comment #1 by post — 2011-06-10T07:01:19Z
Simple solution: Detect architecture of the first object file in the archive and take that to be the architecture of the library.
Comment #2 by andrei — 2016-10-14T16:53:20Z
Fixing this would be quite nice.
Comment #3 by robert.schadek — 2024-12-13T17:55:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18347 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB