Since Windows 10 Creators Update was released two months ago, we have started seeing reports of issues with runtime package (for example, https://quality.embarcadero.com/browse/ RSP-17972, where myself, Embarcadero support and R&D have chimed in), mostly while debugging applications. The issue is affecting applications that use runtime packages (BPL), not applications compiled as a single executable. In general terms, the problem affects all applications that use runtime packages, built with any version of Delphi (recent, old, or even the early ones). In most cases, the slowdown for end user application is relatively limited, however applications with runtime packages on network shares are affected. But what is happening?
The Core Issue: Optimized DLL Loading
Let's start with some background information. On the Windows operating system, dynamic linking (DLLs) support both load-time binding and full runtime binding (LoadLibrary). In both cases, when the DLL is generated it is has a table of entry points (export table). Any other library or executable referring to it has an import table referring to functions of that export table. Since the early days, when the Delphi compiler (and linker) generate a DLL or package library (BPL) by assembling multiple units in a single binary file, and do so by making functions and methods available by creating multiple sections in the export/import table. This was likely a minor linker optimization, and never had a real side effect.
Fast forward to Windows 10 Creators Update. Microsoft decided to rewrite the DLL loading code to make it parallel (different threads can load different libraries in parallel) to optimize applications loading. However this change has ended up affecting the loading of libraries with multiple sections in the export tables. Empirically, it looks like a BPL is loaded once for each segment. Now consider that most of the core Delphi BPL (rtl, vcl, fmx) have dozens and dozens of sections, and the result is libraries are loaded (and unloaded) dozens and dozens of times.
Here is a screenshot of the effect in the Event log (this is a single form FMX application):
While in this simple application on my machine it takes a couple of extra seconds, with larger applications having many runtime packages the effect on the debugger can be fairly extreme. Here is the full debugger log, with operations on packages (and other notable ones) marked in bold:
Thread Start: Thread ID: 12052. Process Project13.exe (13088) Process Start: C:\Users\marco\Documents\Embarcadero\Studio\Projects\Win32\Debug\Project13.exe. Base Address: $00400000. Process Project13.exe (13088) Module Load: Project13.exe. Has Debug Info. Base Address: $00400000. Process Project13.exe (13088) Module Load: ntdll.dll. No Debug Info. Base Address: $76F40000. Process Project13.exe (13088) Module Load: KERNEL32.dll. No Debug Info. Base Address: $74520000. Process Project13.exe (13088) Module Unload: KERNEL32.dll. Process Project13.exe (13088) Module Load: KERNEL32.dll. No Debug Info. Base Address: $74520000. Process Project13.exe (13088) Module Load: KERNELBASE.dll. No Debug Info. Base Address: $73B80000. Process Project13.exe (13088) Thread Start: Thread ID: 14596. Process Project13.exe (13088) Thread Start: Thread ID: 2688. Process Project13.exe (13088) Thread Start: Thread ID: 2076. Process Project13.exe (13088) Module Load: rtl250.bpl. Has Debug Info. Base Address: $50050000. Process Project13.exe (13088) Module Load: rtl250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: rtl250.bpl. Has Debug Info. Base Address: $01740000. Process Project13.exe (13088) Module Load: rtl250.bpl. Has Debug Info. Base Address: $02170000. Process Project13.exe (13088) Module Unload: rtl250.bpl. Process Project13.exe (13088) Module Unload: rtl250.bpl. Process Project13.exe (13088) Module Unload: rtl250.bpl. Process Project13.exe (13088) Module Load: OLEAUT32.dll. No Debug Info. Base Address: $74980000. Process Project13.exe (13088) Module Load: msvcp_win.dll. No Debug Info. Base Address: $76130000. Process Project13.exe (13088) Module Load: ucrtbase.dll. No Debug Info. Base Address: $743A0000. Process Project13.exe (13088) Module Load: combase.dll. No Debug Info. Base Address: $75EA0000. Process Project13.exe (13088) Module Load: RPCRT4.dll. No Debug Info. Base Address: $73A30000. Process Project13.exe (13088) Module Load: SspiCli.dll. No Debug Info. Base Address: $73A10000. Process Project13.exe (13088) Module Load: CRYPTBASE.dll. No Debug Info. Base Address: $73A00000. Process Project13.exe (13088) Module Load: bcryptPrimitives.dll. No Debug Info. Base Address: $76810000. Process Project13.exe (13088) Module Load: SECHOST.dll. No Debug Info. Base Address: $763A0000. Process Project13.exe (13088) Module Load: ADVAPI32.dll. No Debug Info. Base Address: $73AF0000. Process Project13.exe (13088) Module Load: msvcrt.dll. No Debug Info. Base Address: $75DE0000. Process Project13.exe (13088) Module Load: USER32.dll. No Debug Info. Base Address: $76870000. Process Project13.exe (13088) Module Load: win32u.dll. No Debug Info. Base Address: $74A20000. Process Project13.exe (13088) Module Load: GDI32.dll. No Debug Info. Base Address: $74A50000. Process Project13.exe (13088) Module Load: gdi32full.dll. No Debug Info. Base Address: $74640000. Process Project13.exe (13088) Module Load: imagehlp.dll. No Debug Info. Base Address: $74060000. Process Project13.exe (13088) Module Load: SHLWAPI.dll. No Debug Info. Base Address: $745F0000. Process Project13.exe (13088) Module Load: ole32.dll. No Debug Info. Base Address: $74080000. Process Project13.exe (13088) Module Load: WS2_32.dll. No Debug Info. Base Address: $73E20000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $031A0000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $031A0000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $031A0000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $031A0000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $01940000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02570000. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Unload: fmx250.bpl. Process Project13.exe (13088) Module Load: VERSION.dll. No Debug Info. Base Address: $73990000. Process Project13.exe (13088) Module Load: NETAPI32.dll. No Debug Info. Base Address: $712F0000. Process Project13.exe (13088) Module Load: MPR.dll. No Debug Info. Base Address: $72BB0000. Process Project13.exe (13088) Module Load: SHFOLDER.dll. No Debug Info. Base Address: $737E0000. Process Project13.exe (13088) Module Load: SHELL32.dll. No Debug Info. Base Address: $74A80000. Process Project13.exe (13088) Module Load: WINHTTP.dll. No Debug Info. Base Address: $72B00000. Process Project13.exe (13088) Module Load: WSOCK32.dll. No Debug Info. Base Address: $72A00000. Process Project13.exe (13088) Module Load: OLEACC.dll. No Debug Info. Base Address: $6F3D0000. Process Project13.exe (13088) Module Load: CFGMGR32.dll. No Debug Info. Base Address: $73D50000. Process Project13.exe (13088) Module Load: OPENGL32.dll. No Debug Info. Base Address: $6F2F0000. Process Project13.exe (13088) Module Load: SHCORE.dll. No Debug Info. Base Address: $73D90000. Process Project13.exe (13088) Module Load: GLU32.dll. No Debug Info. Base Address: $70C90000. Process Project13.exe (13088) Module Load: netutils.dll. No Debug Info. Base Address: $71C70000. Process Project13.exe (13088) Module Load: Windows.Storage.dll. No Debug Info. Base Address: $769B0000. Process Project13.exe (13088) Module Load: AppCore.dll. No Debug Info. Base Address: $73B70000. Process Project13.exe (13088) Module Load: POWRPROF.dll. No Debug Info. Base Address: $760E0000. Process Project13.exe (13088) Module Load: profapi.dll. No Debug Info. Base Address: $74970000. Process Project13.exe (13088) Module Load: fmx250.bpl. Has Debug Info. Base Address: $00D10000. Process Project13.exe (13088) Module Load: COMDLG32.dll. No Debug Info. Base Address: $742A0000. Process Project13.exe (13088) Module Load: COMCTL32.dll. No Debug Info. Base Address: $6F510000. Process Project13.exe (13088) Module Load: urlmon.dll. No Debug Info. Base Address: $6CE50000. Process Project13.exe (13088) Module Load: WINMM.dll. No Debug Info. Base Address: $72F20000. Process Project13.exe (13088) Module Load: d3d9.dll. No Debug Info. Base Address: $68C10000. Process Project13.exe (13088) Module Load: WINSPOOL.DRV. No Debug Info. Base Address: $6F280000. Process Project13.exe (13088) Module Load: iertutil.dll. No Debug Info. Base Address: $6CC30000. Process Project13.exe (13088) Module Load: WINMMBASE.dll. No Debug Info. Base Address: $72A10000. Process Project13.exe (13088) Module Load: WINMMBASE.dll. No Debug Info. Base Address: $001D0000. Process Project13.exe (13088) Module Unload: WINMMBASE.dll. Process Project13.exe (13088) Module Load: WINMMBASE.dll. No Debug Info. Base Address: $001D0000. Process Project13.exe (13088) Module Unload: WINMMBASE.dll. Process Project13.exe (13088) Module Load: dwmapi.dll. No Debug Info. Base Address: $6C320000. Process Project13.exe (13088) Module Load: bcrypt.dll. No Debug Info. Base Address: $729E0000. Process Project13.exe (13088) Module Load: IMM32.dll. No Debug Info. Base Address: $76370000. Process Project13.exe (13088) Module Load: UxTheme.dll. No Debug Info. Base Address: $6C2A0000. Process Project13.exe (13088) Module Load: MSCTF.dll. No Debug Info. Base Address: $761C0000. Process Project13.exe (13088) Module Load: gdiplus.dll. No Debug Info. Base Address: $6BFA0000. Process Project13.exe (13088) Thread Start: Thread ID: 2908. Process Project13.exe (13088) Module Load: TextInputFramework.dll. No Debug Info. Base Address: $6F1E0000. Process Project13.exe (13088) Module Load: CoreMessaging.dll. No Debug Info. Base Address: $6C8A0000. Process Project13.exe (13088) Module Load: CoreUIComponents.dll. No Debug Info. Base Address: $6C930000. Process Project13.exe (13088) Module Load: NTMARTA.dll. No Debug Info. Base Address: $71F60000. Process Project13.exe (13088) Module Load: WinTypes.dll. No Debug Info. Base Address: $70CF0000. Process Project13.exe (13088) Module Load: USERMGRCLI.dll. No Debug Info. Base Address: $70C00000. Process Project13.exe (13088) Thread Start: Thread ID: 14704. Process Project13.exe (13088) Thread Start: Thread ID: 11932. Process Project13.exe (13088) Thread Start: Thread ID: 12476. Process Project13.exe (13088) Module Load: CLBCatQ.DLL. No Debug Info. Base Address: $74210000. Process Project13.exe (13088) Module Load: DataExchange.dll. No Debug Info. Base Address: $5B340000. Process Project13.exe (13088) Module Load: d3d11.dll. No Debug Info. Base Address: $625F0000. Process Project13.exe (13088) Module Load: dcomp.dll. No Debug Info. Base Address: $5B250000. Process Project13.exe (13088) Module Load: dxgi.dll. No Debug Info. Base Address: $62850000. Process Project13.exe (13088) Module Load: twinapi.appcore.dll. No Debug Info. Base Address: $6F790000. Process Project13.exe (13088) Module Load: d3d10_1.dll. No Debug Info. Base Address: $6B4A0000. Process Project13.exe (13088) Module Load: d3d10_1core.dll. No Debug Info. Base Address: $69450000. Process Project13.exe (13088) Module Unload: d3d10_1core.dll. Process Project13.exe (13088) Module Unload: d3d10_1.dll. Process Project13.exe (13088) Module Load: d3d10_1.dll. No Debug Info. Base Address: $6B4A0000. Process Project13.exe (13088) Module Load: d3d10_1core.dll. No Debug Info. Base Address: $69450000. Process Project13.exe (13088) Module Load: ResourcePolicyClient.dll. No Debug Info. Base Address: $6D230000. Process Project13.exe (13088) Module Unload: ResourcePolicyClient.dll. Process Project13.exe (13088) Module Load: igd10iumd32.dll. No Debug Info. Base Address: $5C3A0000. Process Project13.exe (13088) Module Load: ncrypt.dll. No Debug Info. Base Address: $6B860000. Process Project13.exe (13088) Module Load: NTASN1.dll. No Debug Info. Base Address: $6B830000. Process Project13.exe (13088) Module Load: igdusc32.dll. No Debug Info. Base Address: $5ECD0000. Process Project13.exe (13088) Module Unload: igdusc32.dll. Process Project13.exe (13088) Module Unload: NTASN1.dll. Process Project13.exe (13088) Module Unload: ncrypt.dll. Process Project13.exe (13088) Module Unload: igd10iumd32.dll. Process Project13.exe (13088) Module Load: igd10iumd32.dll. No Debug Info. Base Address: $5C3A0000. Process Project13.exe (13088) Module Load: ncrypt.dll. No Debug Info. Base Address: $6B860000. Process Project13.exe (13088) Module Load: NTASN1.dll. No Debug Info. Base Address: $6B830000. Process Project13.exe (13088) Module Load: igdusc32.dll. No Debug Info. Base Address: $5ECD0000. Process Project13.exe (13088) Module Load: d2d1.dll. No Debug Info. Base Address: $51D40000. Process Project13.exe (13088) Module Load: CRYPT32.dll. No Debug Info. Base Address: $73EE0000. Process Project13.exe (13088) Module Load: MSASN1.dll. No Debug Info. Base Address: $74390000. Process Project13.exe (13088) Module Load: DWrite.dll. No Debug Info. Base Address: $51AF0000. Process Project13.exe (13088) Module Load: WindowsCodecs.dll. No Debug Info. Base Address: $699C0000. Process Project13.exe (13088)
Notice, again, this is not specific to Delphi 10.2 Tokyo or Delphi 10.1 Berlin, but the same applies to the XE series and even classic versions of the product. The issue is caused by a change at the operating system level.
If you are a developer using RAD Studio, we recommend holding off moving to Windows 10 Creators Update on your developer machines, but this is clearly not a solution, also also prevents you from experimenting with the latest version of Windows.
First Solution: Embarcadero to Fix the Linker
Given the issue is how runtime packages are managed by the operating system, the ultimate solutions can come only from two player: Embarcadero or Microsoft. In fact, it is coming from both sides.
On the Embarcadero side, our R&D team has worked on changing the linker in 10.2 Tokyo, so that it produces a single import table with all required entries. The problem is if we just release a new linker, all existing package libraries will still misbehave. So we need to update a fairly large portion of the product, something more commonly done in an Update (or new Release) than via a hot fix. This is by no mean a final decision and R&D and PM are weighing in the alternatives. Now, what about older version of Delphi? Given the effect on packages (from us and third parties) all requiring to be recompiled, this is a fairly difficult scenario to address for past versions of RAD Studio.
Second Solution: Microsoft to Fix the Loader
The second solution would be to Microsoft to address the issue wih the loaded, keep the optimized parallel loading but taking into account the scenario of Delphi packages (which, in fact, happens also with a handful of platform libraries, even if to a more limited extent). Now, we are very happy to share the fact that we have engaged with Microsoft on the issue and they have been very fast to tackle it. The latest 16215 "Insider Build" of Windows 10 Fall Creators Update (https://blogs.windows.com/windowsexperience/2017/06/08/announcing-windows-10-insider-preview-build-16215-pc-build-15222-mobile) addresses the issue. As you can see, using the RTM version of 10.2 Tokyo the FMX library is loaded twice. Still not exactly as it used to work, but not really causing any actual problem:
This is the complete event log as you start debugging a Windows FireMonkey application with runtime packages on build 16215. Lines related with Delphi packages are in bold:
Thread Start: Thread ID: 208. Process Project3.exe (6184) Process Start: C:\Users\Marco\Documents\Embarcadero\Studio\Projects\Win32\Debug\Project3.exe. Base Address: $00400000. Process Project3.exe (6184) Module Load: Project3.exe. Has Debug Info. Base Address: $00400000. Process Project3.exe (6184) Module Load: ntdll.dll. No Debug Info. Base Address: $76FA0000. Process Project3.exe (6184) Module Load: KERNEL32.dll. No Debug Info. Base Address: $74360000. Process Project3.exe (6184) Module Unload: KERNEL32.dll. Process Project3.exe (6184) Module Load: KERNEL32.dll. No Debug Info. Base Address: $74360000. Process Project3.exe (6184) Module Load: KERNELBASE.dll. No Debug Info. Base Address: $76DD0000. Process Project3.exe (6184) Module Load: rtl250.bpl. Has Debug Info. Base Address: $50050000. Process Project3.exe (6184) Module Load: OLEAUT32.dll. No Debug Info. Base Address: $74EA0000. Process Project3.exe (6184) Module Load: msvcp_win.dll. No Debug Info. Base Address: $76C20000. Process Project3.exe (6184) Module Load: ucrtbase.dll. No Debug Info. Base Address: $76B00000. Process Project3.exe (6184) Module Load: combase.dll. No Debug Info. Base Address: $76680000. Process Project3.exe (6184) Module Load: RPCRT4.dll. No Debug Info. Base Address: $74F40000. Process Project3.exe (6184) Module Load: SspiCli.dll. No Debug Info. Base Address: $739F0000. Process Project3.exe (6184) Module Load: CRYPTBASE.dll. No Debug Info. Base Address: $739E0000. Process Project3.exe (6184) Module Load: bcryptPrimitives.dll. No Debug Info. Base Address: $74580000. Process Project3.exe (6184) Module Load: SECHOST.dll. No Debug Info. Base Address: $746A0000. Process Project3.exe (6184) Module Load: ADVAPI32.dll. No Debug Info. Base Address: $76D50000. Process Project3.exe (6184) Module Load: msvcrt.dll. No Debug Info. Base Address: $73D00000. Process Project3.exe (6184) Module Load: USER32.dll. No Debug Info. Base Address: $764E0000. Process Project3.exe (6184) Module Load: win32u.dll. No Debug Info. Base Address: $73A10000. Process Project3.exe (6184) Module Load: GDI32.dll. No Debug Info. Base Address: $74660000. Process Project3.exe (6184) Module Load: gdi32full.dll. No Debug Info. Base Address: $73AC0000. Process Project3.exe (6184) Module Load: imagehlp.dll. No Debug Info. Base Address: $745E0000. Process Project3.exe (6184) Module Load: SHLWAPI.dll. No Debug Info. Base Address: $76CF0000. Process Project3.exe (6184) Module Load: ole32.dll. No Debug Info. Base Address: $74480000. Process Project3.exe (6184) Module Load: WS2_32.dll. No Debug Info. Base Address: $73C90000. Process Project3.exe (6184) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02B40000. Process Project3.exe (6184) Module Unload: fmx250.bpl. Process Project3.exe (6184) Module Load: VERSION.dll. No Debug Info. Base Address: $73850000. Process Project3.exe (6184) Module Load: MPR.dll. No Debug Info. Base Address: $6FC30000. Process Project3.exe (6184) Module Load: SHFOLDER.dll. No Debug Info. Base Address: $6FC60000. Process Project3.exe (6184) Module Load: SHELL32.dll. No Debug Info. Base Address: $75100000. Process Project3.exe (6184) Module Load: CFGMGR32.dll. No Debug Info. Base Address: $74CC0000. Process Project3.exe (6184) Module Load: SHCORE.dll. No Debug Info. Base Address: $75010000. Process Project3.exe (6184) Module Load: Windows.Storage.dll. No Debug Info. Base Address: $74700000. Process Project3.exe (6184) Module Load: AppCore.dll. No Debug Info. Base Address: $746F0000. Process Project3.exe (6184) Module Load: POWRPROF.dll. No Debug Info. Base Address: $74430000. Process Project3.exe (6184) Module Load: profapi.dll. No Debug Info. Base Address: $76660000. Process Project3.exe (6184) Module Load: NETAPI32.dll. No Debug Info. Base Address: $6EA80000. Process Project3.exe (6184) Module Load: WINHTTP.dll. No Debug Info. Base Address: $70F70000. Process Project3.exe (6184) Thread Start: Thread ID: 6828. Process Project3.exe (6184) Module Load: WSOCK32.dll. No Debug Info. Base Address: $70D50000. Process Project3.exe (6184) Module Load: OLEACC.dll. No Debug Info. Base Address: $6FB20000. Process Project3.exe (6184) Module Load: OPENGL32.dll. No Debug Info. Base Address: $6C8D0000. Process Project3.exe (6184) Thread Start: Thread ID: 6456. Process Project3.exe (6184) Module Load: GLU32.dll. No Debug Info. Base Address: $6FAC0000. Process Project3.exe (6184) Module Load: netutils.dll. No Debug Info. Base Address: $6E4A0000. Process Project3.exe (6184) Module Load: fmx250.bpl. Has Debug Info. Base Address: $02C40000. Process Project3.exe (6184) Module Load: COMDLG32.dll. No Debug Info. Base Address: $76A10000. Process Project3.exe (6184) Module Load: COMCTL32.dll. No Debug Info. Base Address: $70D60000. Process Project3.exe (6184) Module Load: urlmon.dll. No Debug Info. Base Address: $6FF00000. Process Project3.exe (6184) Module Load: WINMM.dll. No Debug Info. Base Address: $6CEC0000. Process Project3.exe (6184) Module Load: WINSPOOL.DRV. No Debug Info. Base Address: $6C860000. Process Project3.exe (6184) Module Load: d3d9.dll. No Debug Info. Base Address: $6B960000. Process Project3.exe (6184) Module Load: iertutil.dll. No Debug Info. Base Address: $6FCE0000. Process Project3.exe (6184) Thread Start: Thread ID: 7136. Process Project3.exe (6184) Module Load: WINMMBASE.dll. No Debug Info. Base Address: $6CE90000. Process Project3.exe (6184) Module Load: dwmapi.dll. No Debug Info. Base Address: $6F4C0000. Process Project3.exe (6184) Module Load: bcrypt.dll. No Debug Info. Base Address: $71C50000. Process Project3.exe (6184) Module Load: IMM32.dll. No Debug Info. Base Address: $74E70000. Process Project3.exe (6184) Thread Start: Thread ID: 4232. Process Project3.exe (6184) Module Load: UxTheme.dll. No Debug Info. Base Address: $70620000. Process Project3.exe (6184) Module Load: MSCTF.dll. No Debug Info. Base Address: $768C0000. Process Project3.exe (6184) Module Load: gdiplus.dll. No Debug Info. Base Address: $70830000. Process Project3.exe (6184) Thread Start: Thread ID: 3124. Process Project3.exe (6184) Module Load: TextInputFramework.dll. No Debug Info. Base Address: $6C7A0000. Process Project3.exe (6184) Module Load: CoreUIComponents.dll. No Debug Info. Base Address: $6C570000. Process Project3.exe (6184) Module Load: CoreMessaging.dll. No Debug Info. Base Address: $6C4D0000. Process Project3.exe (6184) Module Load: NTMARTA.dll. No Debug Info. Base Address: $705F0000. Process Project3.exe (6184) Module Load: WinTypes.dll. No Debug Info. Base Address: $6C400000. Process Project3.exe (6184) Module Load: WinTypes.dll. No Debug Info. Base Address: $05960000. Process Project3.exe (6184) Module Unload: WinTypes.dll. Process Project3.exe (6184) Thread Start: Thread ID: 3616. Process Project3.exe (6184) Thread Start: Thread ID: 5984. Process Project3.exe (6184) Module Load: CLBCatQ.DLL. No Debug Info. Base Address: $73A30000. Process Project3.exe (6184) Module Load: DataExchange.dll. No Debug Info. Base Address: $69B60000. Process Project3.exe (6184) Module Load: d3d11.dll. No Debug Info. Base Address: $69910000. Process Project3.exe (6184) Module Load: dcomp.dll. No Debug Info. Base Address: $69800000. Process Project3.exe (6184) Module Load: dxgi.dll. No Debug Info. Base Address: $69770000. Process Project3.exe (6184) Module Load: twinapi.appcore.dll. No Debug Info. Base Address: $6CBF0000. Process Project3.exe (6184) Module Load: RMCLIENT.dll. No Debug Info. Base Address: $6CBD0000. Process Project3.exe (6184) Module Load: d3d10_1.dll. No Debug Info. Base Address: $63B40000. Process Project3.exe (6184) Module Load: d3d10_1core.dll. No Debug Info. Base Address: $63AE0000. Process Project3.exe (6184) Module Unload: d3d10_1core.dll. Process Project3.exe (6184) Module Unload: d3d10_1.dll. Process Project3.exe (6184) Module Load: d3d10_1.dll. No Debug Info. Base Address: $63B40000. Process Project3.exe (6184) Module Load: d3d10_1core.dll. No Debug Info. Base Address: $63AE0000. Process Project3.exe (6184) Module Load: ResourcePolicyClient.dll. No Debug Info. Base Address: $63A40000. Process Project3.exe (6184) Module Unload: ResourcePolicyClient.dll. Process Project3.exe (6184) Module Load: vm3dum10.exe. No Debug Info. Base Address: $63AA0000. Process Project3.exe (6184) Module Unload: vm3dum10.exe. Process Project3.exe (6184) Module Load: vm3dum10.exe. No Debug Info. Base Address: $63AA0000. Process Project3.exe (6184) Module Unload: vm3dum10.exe. Process Project3.exe (6184) Module Load: vm3dum10.exe. No Debug Info. Base Address: $63AA0000. Process Project3.exe (6184) Module Unload: vm3dum10.exe. Process Project3.exe (6184) Module Load: vm3dum10.exe. No Debug Info. Base Address: $63AA0000. Process Project3.exe (6184) Module Load: d2d1.dll. No Debug Info. Base Address: $65120000. Process Project3.exe (6184) Module Load: CRYPT32.dll. No Debug Info. Base Address: $73DC0000. Process Project3.exe (6184) Module Load: MSASN1.dll. No Debug Info. Base Address: $75000000. Process Project3.exe (6184) Module Load: DWrite.dll. No Debug Info. Base Address: $64EA0000. Process Project3.exe (6184) Module Load: WindowsCodecs.dll. No Debug Info. Base Address: $6C290000. Process Project3.exe (6184)
Perfect solution, right? Well, it does fix the issue for current and old versions of Delphi, but unfortunately not immediately. It is true Microsoft fixed the problem, but if the solution will show only in the next major release of the operating system, still several months away (Fall Creators Update), what happens to developers and users on Creators Update? We still hope and have been asking Microsoft for a fix also for the current version of Windows, and you can certainly join us in this request.
Some Temporary Workarounds
Given the two solutions above are coming but don't address the issue immediately and for all developers, it is important to focus also on a few available workarounds.
A first one is for debugging. Given the issue happens when loading the application, running it standalone and later attaching the debugger to it seems to work for most developers. Clearly, it is an annoyance, but clearly much better than waiting a lot of time or see the debugger get stuck.
A second workaround (for end users) is to consider one of the tools that fix-up and cleanup PE executables, including reorganizing the import/export tables. There are many such tools. One of them is http://www.ntcore.com/exsuite.php.
There are of course other more extreme options, like staying on Windows 10 Anniversary edition, jumping to the latest Insider release or moving from the use of runtime packages to releasing a single executable.
Conclusion
We are working on releasing our linker solution for the issue, we'll keep pushing Microsoft for a broad and more immediate fix, and we are also evaluating alternative workarounds for the short term. Stay tuned for more information.