dlang / dub

Package and build management system for D
MIT License
678 stars 227 forks source link

Wrong linker used for OMF #2505

Closed torhus closed 2 years ago

torhus commented 2 years ago

System information

Bug Description

DUB doesn't pass the -m32omf flag to DMD when linking, causing it to use the Microsoft linker instead of Optlink.

How to reproduce?

dub build -a=x86_omf

Logs

c:\prog\prosjekt\MonsterBrowser_phobos2>dub build -a=x86_omf Performing "debug" build using C:\prog\dmd\windows\bin\dmd.exe for x86, x86_omf. dwt:base 1.0.5+swt-3.4.1.commit.121.g19f219e: target for configuration "library" is up to date. dwt 1.0.5+swt-3.4.1.commit.121.g19f219e: target for configuration "windows-win32" is up to date. fswatch 0.6.0: target for configuration "library" is up to date. undead 1.1.7: target for configuration "library" is up to date. monster-browser ~master: building configuration "console"... Running pre-build commands... Linking... .dub\build\console-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-CB2468B084992555201A9D16A6614832\MonsterBrowser.obj : fatal error LNK1136: invalid or corrupt file Error: linker exited with status 1136 C:\prog\dmd\windows\bin\dmd.exe failed with exit code 1.

rikkimax commented 2 years ago

Can you please get the dmd commands from the -v output to dub?

On Mon, Oct 24, 2022, 09:03 torhus @.***> wrote:

System information

  • dub version: 1.29.2
  • OS Platform and distribution: Windows 10
  • compiler version DMD 2.100.2

Bug Description

DUB doesn't pass the -m32omf flag to DMD when linking, causing it to use the Microsoft linker instead of Optlink. How to reproduce?

dub build -a=x86_omf Logs

c:\prog\prosjekt\MonsterBrowser_phobos2>dub build -a=x86_omf Performing "debug" build using C:\prog\dmd\windows\bin\dmd.exe for x86, x86_omf. dwt:base 1.0.5+swt-3.4.1.commit.121.g19f219e: target for configuration "library" is up to date. dwt 1.0.5+swt-3.4.1.commit.121.g19f219e: target for configuration "windows-win32" is up to date. fswatch 0.6.0: target for configuration "library" is up to date. undead 1.1.7: target for configuration "library" is up to date. monster-browser ~master: building configuration "console"... Running pre-build commands... Linking... .dub\build\console-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-CB2468B084992555201A9D16A6614832\MonsterBrowser.obj : fatal error LNK1136: invalid or corrupt file Error: linker exited with status 1136 C:\prog\dmd\windows\bin\dmd.exe failed with exit code 1.

— Reply to this email directly, view it on GitHub https://github.com/dlang/dub/issues/2505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHSL43OXHBMI3OP67QNYCTWEWKZHANCNFSM6AAAAAARMNUZJU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

torhus commented 2 years ago

C:\prog\dmd\windows\bin\dmd.exe -m32omf -c -of.dub\build\console-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-CB2468B084992555201A9D16A6614832\MonsterBrowser.obj -debug -g -w -version=console -version=Have_monster_browser -version=Have_dwt -version=Have_fswatch -version=Have_undead -version=Have_dwt_base -Isrc -IC:\Users\Tor\AppData\Local\dub\packages\dwt-19f219e\dwt\org.eclipse.swt.win32.win32.x86\src "-IC:\Users\Tor\AppData\Local\dub\packages\dwt-19f219e\dwt\org.eclipse.swt\Eclipse SWT\common" -IC:\Users\Tor\AppData\Local\dub\packages\dwt-19f219e\dwt\base\src -IC:\Users\Tor\AppData\Local\dub\packages\fswatch-0.6.0\fswatch\source -IC:\Users\Tor\AppData\Local\dub\packages\undead-1.1.7\undead\src -J. -Jflags -Jicons -JC:\Users\Tor\AppData\Local\dub\packages\dwt-19f219e\dwt\org.eclipse.swt.win32.win32.x86\res src\colorednames.d src\common.d src\cvartable.d src\dialogs.d src\filewatcher.d src\flagdata.d src\geoip.d src\ini.d src\launch.d src\lib\loader.d src\main.d src\mainwindow.d src\masterlist.d src\maxminddb.d src\messageboxes.d src\mswindows\taskbarlist.d src\mswindows\taskbarprogress.d src\playertable.d src\qstat.d src\rcon.d src\runtools.d src\serveractions.d src\serverdata.d src\serverlist.d src\serverqueue.d src\servertable.d src\set.d src\settings.d src\tango\sys\win32\CodePage.d src\tango\sys\win32\IUnknown.d src\tango\sys\win32\Macros.d src\tango\sys\win32\SpecialPath.d src\tango\sys\win32\Types.d src\tango\sys\win32\UserGdi.d src\tango\text\Util.d src\tango\text\xml\DocEntity.d src\tango\text\xml\PullParser.d src\tango\text\xml\SaxParser.d src\threadmanager.d src\updatecheck.d -vcolumns Linking... C:\prog\dmd\windows\bin\dmd.exe -of.dub\build\console-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-CB2468B084992555201A9D16A6614832\MonsterBrowser.exe .dub\build\console-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-CB2468B084992555201A9D16A6614832\MonsterBrowser.obj C:\Users\Tor\AppData\Local\dub\packages\dwt-19f219e\dwt.dub\build\windows-win32-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-7A54A366186E2084A2A48388AD28BB08\dwt.lib C:\Users\Tor\AppData\Local\dub\packages\dwt-19f219e\dwt.dub\build\library-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-9E87CB4A61CF1590FDD296052144AC22\dwt_base.lib C:\Users\Tor\AppData\Local\dub\packages\fswatch-0.6.0\fswatch.dub\build\library-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-D28F567DE04035991710E43365B7603E\fswatch.lib C:\Users\Tor\AppData\Local\dub\packages\undead-1.1.7\undead.dub\build\library-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-19AFA61F4A2CE86C5670657E4D5B895E\undead.lib advapi32.lib comctl32.lib comdlg32.lib gdi32.lib kernel32.lib msimg32.lib ole32.lib oleacc.lib oleaut32.lib opengl32.lib shell32.lib shlwapi.lib user32.lib usp10.lib olepro32.lib -L/rc:misc\mb.res -L+C:\Users\Tor\AppData\Local\dub\packages\dwt-19f219e\dwt\org.eclipse.swt.win32.win32.x86\lib\ -g .dub\build\console-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-CB2468B084992555201A9D16A6614832\MonsterBrowser.obj : fatal error LNK1136: invalid or corrupt file Error: linker exited with status 1136 FAIL .dub\build\console-debug-windows-x86.x86_omf-dmd_v2.100.2-dirty-CB2468B084992555201A9D16A6614832\ MonsterBrowser executable C:\prog\dmd\windows\bin\dmd.exe failed with exit code 1.

rikkimax commented 2 years ago

What that tells me is that dub is simply not emitting any -m flag during linking.

Nothing in the code stands out as obvious.

https://github.com/dlang/dub/blob/fe09137708faac9f334eb08ab7d18ec9c2bd6b5c/source/dub/generators/build.d#L561

But that should give you something to start adding writeln's to figure out where it's being added for building but not linking.

torhus commented 2 years ago

This seems to be working correctly with DUB 1.30.1-beta.1.