Opened 18 years ago

Closed 17 years ago

Last modified 16 years ago

#148 closed defect (released)

Add header file dependencies to msvc build

Reported by: Richard Boulton Owned by: Charlie Hull
Priority: low Milestone:
Component: MSVC makefiles Version: SVN trunk
Severity: minor Keywords:
Cc: Sidnei da Silva, Mark Hammond Blocked By:
Blocking: Operating System: Microsoft Windows

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 (4)

patch2.patch (40.4 KB ) - added by Charlie Hull 17 years ago.
Adds header dependencies to make files
patch4.patch (301.2 KB ) - added by Charlie Hull 17 years ago.
Patch to add new way of header dependencies
makedepend.patch (130.8 KB ) - added by Mark Hammond 17 years ago.
patch to get makedepend building
makedepend.dsw (348 bytes ) - added by Mark Hammond 17 years ago.
New version of the workspace file that loads in MSVC

Download all attachments as: .zip

Change History (19)

comment:1 by Charlie Hull, 17 years ago

Status: newassigned

by Charlie Hull, 17 years ago

Attachment: patch2.patch added

Adds header dependencies to make files

comment:2 by Richard Boulton, 17 years ago

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.

comment:3 by Charlie Hull, 17 years ago

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.

comment:4 by Richard Boulton, 17 years ago

Resolution: wontfix
Status: assignedclosed

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).

comment:5 by Charlie Hull, 17 years ago

Resolution: wontfix
Status: closedreopened

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

comment:6 by Richard Boulton, 17 years ago

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.

comment:7 by Sidnei da Silva, 17 years ago

Cc: mhammond@… added

comment:8 by Sidnei da Silva, 17 years ago

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.

comment:9 by Sidnei da Silva, 17 years ago

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

by Charlie Hull, 17 years ago

Attachment: patch4.patch added

Patch to add new way of header dependencies

comment:10 by Richard Boulton, 17 years ago

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

by Mark Hammond, 17 years ago

Attachment: makedepend.patch added

patch to get makedepend building

comment:11 by Richard Boulton, 17 years ago

Applied marks patch - should now work, hopefully.

comment:12 by Charlie Hull, 17 years ago

Status: reopenedassigned

comment:13 by Mark Hammond, 17 years ago

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.

by Mark Hammond, 17 years ago

Attachment: makedepend.dsw added

New version of the workspace file that loads in MSVC

comment:14 by Richard Boulton, 17 years ago

Resolution: fixed
Status: assignedclosed

Applied

comment:15 by Olly Betts, 17 years ago

Operating System: Microsoft Windows
Resolution: fixedreleased

Fixed in 1.0.4

Note: See TracTickets for help on using tickets.