diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index 79deced12d..2edd2d2026 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -126,10 +126,10 @@ implementation current_module.headerflags:=current_module.headerflags or uf_static_linked; if create_smartlink_library then - begin - current_module.linkunitstaticlibs.add(current_module.staticlibfilename ,link_smart); - current_module.headerflags:=current_module.headerflags or uf_smart_linked; - end; + begin + current_module.linkunitstaticlibs.add(current_module.staticlibfilename ,link_smart); + current_module.headerflags:=current_module.headerflags or uf_smart_linked; + end; if cs_lto in current_settings.moduleswitches then begin current_module.linkunitofiles.add(ChangeFileExt(current_module.objfilename,LTOExt),link_lto); @@ -2475,7 +2475,18 @@ type hp:=tmodule(loaded_units.first); while assigned(hp) do begin - if (hp<>sysinitmod) and ((hp.headerflags and uf_in_library)=0) then + if (hp<>sysinitmod) { + I commented the following condition as it breaks linking with units being shared libs. + The needed shared libs and object files are ignored + + and ((hp.headerflags and uf_in_library)=0) + + I think the right condition is + + not(assigned(hp.package)) + + as later on for packages the right shared libs are added separately (FK) + } then begin linker.AddModuleFiles(hp); if mf_checkpointer_called in hp.moduleflags then