premake / premake/premake-core

dependson can break links in VS

Open
#208 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug vs20xx
Dominant language
C
Stars
3.6k
Forks
654
Avg merge
1d 1h
Merged PRs (30d)
13

Description

This might be the same as #121. Tested with alpha4 on Windows with VS 2015.

Sometimes adding dependson() will neuter links(), if links() refers to a StaticLib project.

I failed at making a small repro case. The full premake5.lua file in question is: https://github.com/sumatrapdfreader/sumatrapdf/blob/ed350e101b0cd1580644f8a003f9383d711850ff/premake5.lua#L652

This is a version that compiles.

When you uncomment dependson line, it'll generate a project that doesn't compile anymore because utils, zlib and unarr project are no longer linked.

Here's the difference between working (left) and non-working (right) versions of generated Installer.vcxproj: https://www.diffchecker.com/hiuh2pjw

The changes in non-working version are:

  1. Dependencies are added as:
    <ProjectReference Include="MakeLZSA.vcxproj">
      <Project>{9D3338B7-8900-93C2-B219-816A9E45C850}</Project>
    </ProjectReference>
    <ProjectReference Include="SumatraPDF-no-MUPDF.vcxproj">
      <Project>{8F5D3594-FBBE-12A2-842C-5954F08C4961}</Project>
    </ProjectReference>
    <ProjectReference Include="PdfFilter.vcxproj">
      <Project>{85945DF9-F1FE-1170-3A3D-C315A6E6EFC4}</Project>
    </ProjectReference>
    <ProjectReference Include="PdfPreview.vcxproj">
      <Project>{616F573B-4D27-9988-B62E-72E4A2053479}</Project>
    </ProjectReference>
    <ProjectReference Include="Uninstaller.vcxproj">
      <Project>{163328E5-82E8-A0DA-0BDD-9AB1779197DE}</Project>
    </ProjectReference>

i.e. the same way as the static library added with links().

  1. Each ItemDefinitionGroup section for each configuration|platform combination gets:
<ProjectReference>
    <LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>

This unfortunately disables linking of projects I referenced via links().

Following http://blogs.msdn.com/b/kirillosenkov/archive/2015/04/04/how-to-have-a-project-reference-without-referencing-the-actual-binary.aspx, I've manually modified the project to remove the <LinkLibraryDependencies>false</LinkLibraryDependencies> and added <ReferenceOutputAssembly>false</ReferenceOutputAssembly> to <ProjectReference /> entries added via dependson.

This kind of works in my case but looking at VS link cmd-line, it looks like it still tries to link those projects if they are static libraries:

/OUT:"..\dbg\Installer.exe" /MANIFEST:NO /NXCOMPAT /PDB:"..\dbg\Installer.pdb" /DYNAMICBASE "comctl32.lib" "gdiplus.lib" "msimg32.lib" "shlwapi.lib" "urlmon.lib" "version.lib" "windowscodecs.lib" "wininet.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "C:\Users\kjk\src\sumatrapdf\dbg\utils.lib" "C:\Users\kjk\src\sumatrapdf\dbg\zlib.lib" "C:\Users\kjk\src\sumatrapdf\dbg\unarr.lib" "C:\Users\kjk\src\sumatrapdf\dbg\PdfFilter.lib" "C:\Users\kjk\src\sumatrapdf\dbg\PdfPreview.lib" /MACHINE:X86 /INCREMENTAL /PGD:"..\dbg\Installer.pgd" /SUBSYSTEM:WINDOWS",5.01" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"..\dbg\obj\x32\Debug\Installer\Installer.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1 

PdfFilter.lib and PdfPreview.lib are merely build dependencies and shouldn't be linked in.

It's harmless in my case but probably not always and that's what <LinkLibraryDependencies>false</LinkLibraryDependencies> was meant to prevent.

For the full repro, you can checkout https://github.com/sumatrapdfreader/sumatrapdf @ ed350e101b0cd1580644f8a003f9383d711850ff and generate solutions files in vs 2015 by running premake5.exe premake5.lua and the project will be in vs2015 directory.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced premake5.lua around line 652 and generate the VS 2015 files from the linked SumatraPDF commit using premake5.exe premake5.lua. Compare the working and non-working Installer.vcxproj files, especially ProjectReference and LinkLibraryDependencies entries. Done means dependson preserves links() behavior while build-only dependencies do not become linked libraries.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.