Ticket #148 (closed defect: released)

Opened 20 months ago

Last modified 2 weeks ago

Add header file dependencies to msvc build

Reported by: richard Owned by: charlie
Priority: low Milestone:
Component: MSVC makefiles Version: SVN trunk
Severity: minor Keywords:
Cc: sidnei, mhammond Blocked By:
Operating System: Microsoft Windows Blocking:

Description

Not a high priority, but it would be nice to do this at some point. Adding this bug so it doesn't get forgotten.

Attachments

patch2.patch (40.4 kB) - added by charlie 19 months ago.
Adds header dependencies to make files
patch4.patch (301.2 kB) - added by charlie 19 months ago.
Patch to add new way of header dependencies
makedepend.patch (130.8 kB) - added by mhammond 19 months ago.
patch to get makedepend building
makedepend.dsw (348 bytes) - added by mhammond 18 months ago.
New version of the workspace file that loads in MSVC

Change History

Changed 19 months ago by charlie

  • status changed from new to assigned

Changed 19 months ago by charlie

Adds header dependencies to make files

Changed 19 months ago by richard

It looks to me like the dependencies are incomplete, because objects in each directory only depend on header files in that directory - whereas, in reality, source files pull in headers from lots of different directories.

However, it's probably better than what we had before, so I'll commit it.

Changed 19 months ago by charlie

I took the list of headers directly from the Unix makefiles; if there's a better way of doing things let me know and I'll try and persuade NMAKE.

Changed 19 months ago by richard

  • status changed from assigned to closed
  • resolution set to wontfix

The unix makefiles use the list of headers only as a list of which files need to be put in tarballs when making a release. The actual dependencies are calculated automatically by the compiler: when a .cc file is compiled, the compiler also produces a makefile fragment listing all the header files which were examined when the file was compiled. This fragment is then included by make when running the next time, such that if any of the header files have changed, the .cc file is compiled again. This works whether the header files are in the same directory as the .cc file, or elsewhere in the tree.

The attachment I committed simply assumes that each .cc file depends on the header files in its directory, and not on any other header files. This is wildly inaccurate in many cases, but is still better than nothing (which is why I committed it).

I'm not sure whether it's possible to get the MS compiler to do the automatic dependency generation thing, and even if it is it's probably not something which is possible with a reasonable amount of effort.

The alternative is to use a separate utility to generate the dependencies (rather than getting them as a side effect of the compiler). This is probably even harder to set up.

Therefore, I'm resolving this bug, but setting it to WONTFIX (because we can't easily do better than we already have).

Changed 19 months ago by charlie

  • status changed from closed to reopened
  • resolution deleted

I've got a solution for this using something called makedepend (http://llg.cubic.org/docs/vc7.html) - this will add header file dependencies to the end of the Windows makefiles automatically as part of the build process. Makedepend itself needs hacking to make it work properly with Windows paths though- I'll do this soon - and thus will have to live in xapian-maintainer-tools\win32msvc

Changed 19 months ago by richard

  • cc sidnei@… added

Sidnei is reporting that his compiler doesn't seem to be calling the inference rules correctly: as a result, no .obj files are being generated. The result of attempting to compile is an error reporting "failed to find utils.obj" when linking libcommon.lib, but apparently there are no other .obj files generated either. He's using nmake 7.x from visual studio .net 2003.

I've added him to the CC list and asked him to attach the full output of a make run here, to help us work out what's going on. He's going to do that when he gets back home, hopefully.

Changed 19 months ago by sidnei

  • cc mhammond@… added

Changed 19 months ago by sidnei

Here is the error:

cd ..\common nmake /EL CFG="" DEBUG="" if not exist "..\win32\Release\libs/" mkdir "..\win32\Release\libs" link.exe -lib @C:\DOCUME~1\ADMINI~1.ALI\LOCALS~1\Temp\nm1E.tmp

LINK : fatal error LNK1181: cannot open input file '.\utils.obj' NMAKE : fatal error U1077: 'link.exe' : return code '0x49d' Stop. NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\BIN\nmake.exe"' : return code '0x2'

C:\src\xapian-build\trunk>nmake

Microsoft (R) Program Maintenance Utility Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved.

NMAKE : fatal error U1064: MAKEFILE not found and no target specified Stop.

Stop.

Changed 19 months ago by sidnei

Found the issue: Inference rules look at .SUFFIXES: to decide the order in which they are applied.

-> http://msdn2.microsoft.com/en-us/library/7zx09b9a(VS.80).aspx

.SUFFIXES is defined, by default as: .exe .obj .asm .c .cpp .cxx .bas .cbl .for .pas .res .rc .f .f90

-> http://msdn2.microsoft.com/en-us/library/d82af2ab(VS.80).aspx

Adding this to config.mak makes it work:

.SUFFIXES : .cc

FWIW, if you change the inference rules to end with '::' instead of ':' it enables 'batch-mode', which supposedly make the compilation faster because it invokes the compiler only once with all the files.

http://msdn2.microsoft.com/en-us/library/f2x0zs74(vs.80).aspx

Changed 19 months ago by charlie

Patch to add new way of header dependencies

Changed 19 months ago by richard

Applied. Please test that I've applied it right, and close this bug if so.

Changed 19 months ago by mhammond

patch to get makedepend building

Changed 19 months ago by richard

Applied marks patch - should now work, hopefully.

Changed 19 months ago by charlie

  • status changed from reopened to assigned

Changed 18 months ago by mhammond

I'm still having trouble with makedepend: * makedepend.dsp has \r line ends - MSVC insists on \r\n * makedepend.dsw has the same problem as the other files (but I neglected to include it in my patch.)

I'm attaching a new .dsw in its entirity - I haven't bothered with the .dsp, but it needs the line endings fixed.

Changed 18 months ago by mhammond

New version of the workspace file that loads in MSVC

Changed 18 months ago by richard

  • status changed from assigned to closed
  • resolution set to fixed

Applied

Changed 15 months ago by olly

  • resolution changed from fixed to released

Fixed in 1.0.4

Changed 15 months ago by trac

  • platform set to Microsoft Windows
Note: See TracTickets for help on using tickets.