Author Topic: Compiling recent versions of NASM with VC++ 2017  (Read 20877 times)

Offline mh-nexus

  • Jr. Member
  • *
  • Posts: 5
Compiling recent versions of NASM with VC++ 2017
« on: March 08, 2021, 06:23:16 PM »
Hello,

I am trying to compile a recent version of NASM with VC++ 2017 but it fails with the most recent versions.
The issue starts with version 2.15.03 and later, the previous one 2.15.02, still compiles.

Here is the error I get.
Code: [Select]
> nmake /f Mkfiles/msvc.mak

Microsoft (R) Program Maintenance Utility, Version 14.16.27030.1
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

NMAKE :  U1073: "config\config.h.in" could not be created
Stop.
Mkfiles/msvc.mak(410) : fatal error U1050: Unable to rebuild dependencies file msvc.dep
Stop.

Any clues on what could be causing this?

Offline mh-nexus

  • Jr. Member
  • *
  • Posts: 5
Re: Compiling recent versions of NASM with VC++ 2017
« Reply #1 on: April 09, 2021, 10:07:07 AM »
To answer my own question: 2.15.03 is missing config\config.h.in. Copying it from 2.15.04 solves the compiling problem for 2.15.03.

However 2.15.04 and 2.15.05 still don't compile because of this error:
Quote
Microsoft (R) Program Maintenance Utility, Version 14.16.27030.1
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

NMAKE : fatal error U1071: Schleife im Abhängigkeitsstruktur für Ziel "asm\nasm.
obj"
Stop.

Offline mh-nexus

  • Jr. Member
  • *
  • Posts: 5
Re: Compiling recent versions of NASM with VC++ 2017
« Reply #2 on: April 09, 2021, 11:30:50 AM »
After some more digging I found out the issue. Apparently the following makefile entries in msvc.mak cause the "A circular dependency exists in the dependency tree for the given target. " error.

The relevant 4 lines, starting at line no 231, are:
Code: [Select]
$(MAKE) asm\warnings.time

asm\warnings.time: $(ALLOBJ:.@OBJEXT@=.c)
: > asm\warnings.time

Comment out these 4 lines, then create the empty file asm\warnings.time manually.

After these steps compiling works again as expected with the usual command:
nmake /f Mkfiles\msvc.mak

I haven't found out a way to fix this issue properly yet, but this stackoverflow entry might give a hint:
https://stackoverflow.com/questions/32394965/makefile-cycle-in-dependency-tree
« Last Edit: April 09, 2021, 01:28:05 PM by mh-nexus »

Offline mh-nexus

  • Jr. Member
  • *
  • Posts: 5
Re: Compiling recent versions of NASM with VC++ 2017
« Reply #3 on: April 09, 2021, 12:06:47 PM »
Line 234 has the statement:
Code: [Select]
: > asm\warnings.timeWhich is an illegal command under Windows. I assume it is supposed to update the file modification time, which can be achieved like this:
Code: [Select]
type NUL > asm\warnings.timeIt will also create the file in case it does not exist.

But the real issue is the condition $(ALLOBJ:.@OBJEXT@=.c) in the line 233:
Code: [Select]
asm\warnings.time: $(ALLOBJ:.@OBJEXT@=.c)
But even if that issue would be solved, I am not sure I understand the logic behind that statement. The file asm\warnings.time has to exist already (which it does not in the default distribution), or nmake will still fail.

Offline mh-nexus

  • Jr. Member
  • *
  • Posts: 5
Re: Compiling recent versions of NASM with VC++ 2017
« Reply #4 on: April 09, 2021, 01:22:51 PM »
There are two issues with substring replacement $(ALLOBJ:.@OBJEXT@=.c).

@OBJEXT@ has no effect since macro expansion is not supported by nmake:
https://stackoverflow.com/questions/18374299/how-do-i-substitute-a-string-and-add-a-prefix-or-suffix-in-microsoft-nmake

Therefore it has to be rewritten with string literals, as such:
$(ALLOBJ:.obj=.c)

Fixing all the bugs mentioned in the posts so far, we get:
Quote
asm\warnings.time: $(ALLOBJ:.obj=.c)
   type NUL > asm\warnings.time
   $(MAKE) $(WARNFILES)

But eventhough this string replacement works, we still have cyclic dependencies, for example:

asm\warnings.time -> asm\warnings.c -> asm\warnings.time

The last dependency occurs due to line 237:
Code: [Select]
asm\warnings.c: asm\warnings.pl asm\warnings.timesand the first dependency due to
Code: [Select]
asm\warnings.time: $(ALLOBJ:.obj=.c)
Whatever the purpose of this added code to the makefile was, it will not work with nmake, due to the cyclic dependency. So until the original developer fixes it, the best option is to edit the makefile as mentioned in my third post.
« Last Edit: April 09, 2021, 05:09:30 PM by mh-nexus »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Compiling recent versions of NASM with VC++ 2017
« Reply #5 on: April 09, 2021, 04:28:57 PM »
Thank you for posting your answers !

Best.
Frank