Author Topic: How to compile NASM itself under Windows  (Read 18386 times)

Offline ~

  • Jr. Member
  • *
  • Posts: 8
How to compile NASM itself under Windows
« on: August 08, 2017, 10:06:20 PM »
What tools and tool versions do I need to build NASM under Windows?

This information seems to be lacking due to virtually everyone being absorbed in compiling assembly programs instead of building NASM itself.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How to compile NASM itself under Windows
« Reply #1 on: August 08, 2017, 10:44:02 PM »
If you like Visual Studio, see: Mkfiles/README and Mkfiles/msvc.mak
If you've got OpenWatcom tools, try: Mkfiles/openwcom.mak
If you've got a Windows port of gcc, I assume "autoconf", "configure", "make install_everything" should work.

What have you tried?

Best,
Frank


Offline ~

  • Jr. Member
  • *
  • Posts: 8
Re: How to compile NASM itself under Windows
« Reply #2 on: August 08, 2017, 11:00:47 PM »
I've tried nasm-2.14rc0.

I've tried the MSYS 1.0 that comes with MinGW. You can see the whole process I made here:
http://www.youtube.com/watch?v=h7vAzNko7Do

Code: [Select]
./configure
make


Then it failed because it said it couldn't expand the macros called "ftello" and "fseeko".

Code: [Select]
_@_-PC ~/nasm-2.14rc0
$ ./configure
checking for prefix by checking for nasm... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... unknown
checking for _LARGE_FILES value needed for large files... unknown
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking for gcc option to accept ISO C99... none needed
checking for gcc option to accept ISO Standard C... (cached) none needed
checking whether ln -s works... no, using cp -pR
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /bin/install -c
checking for suffix of library files... a
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for C/C++ restrict keyword... __restrict
checking for size_t... yes
checking whether byte ordering is bigendian... no
checking if gcc accepts -fwrapv... yes
checking if gcc accepts -U__STRICT_ANSI__... yes
checking if gcc accepts -fno-common... yes
checking for nroff... nroff
checking for asciidoc... no
checking for xmlto... no
configure: WARNING: No asciidoc package found
configure: WARNING: No xmlto package found
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for ANSI C header files... (cached) yes
checking for inttypes.h... (cached) yes
checking for strings.h... (cached) yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking stdnoreturn.h usability... yes
checking stdnoreturn.h presence... yes
checking for stdnoreturn.h... yes
checking io.h usability... yes
checking io.h presence... yes
checking for io.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for unistd.h... (cached) yes
checking endian.h usability... no
checking endian.h presence... no
checking for endian.h... no
checking sys/endian.h usability... no
checking sys/endian.h presence... no
checking for sys/endian.h... no
checking machine/endian.h usability... no
checking machine/endian.h presence... no
checking for machine/endian.h... no
checking sys/mman.h usability... no
checking sys/mman.h presence... no
checking for sys/mman.h... no
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking for strcasecmp... yes
checking for stricmp... yes
checking for strncasecmp... yes
checking for strnicmp... yes
checking for strsep... no
checking for strnlen... yes
checking for getuid... no
checking for getgid... no
checking for realpath... no
checking for canonicalize_file_name... no
checking for _fullpath... yes
checking for pathconf... no
checking for _LARGEFILE_SOURCE value needed for large files... unknown
checking for _fseeki64... yes
checking for ftruncate... yes
checking for _chsize... yes
checking for _chsize_s... yes
checking for fileno... yes
checking for _fileno... yes
checking for _filelengthi64... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... no
checking for getpagesize... (cached) yes
checking for sysconf... no
checking for access... yes
checking for _access... yes
checking for faccessat... no
checking for __builtin_expect... yes
checking intrin.h usability... no
checking intrin.h presence... no
checking for intrin.h... no
checking for __builtin_clz... yes
checking for __builtin_clzl... yes
checking for __builtin_clzll... yes
checking for _BitScanReverse... no
checking for _BitScanReverse64... no
checking for vsnprintf... yes
checking for _vsnprintf... yes
checking for snprintf... yes
checking for _snprintf... yes
checking for strlcpy... no
checking for struct _stati64... yes
checking for struct stat... yes
checking for stat... yes
checking for _stati64... yes
checking for fstat... yes
checking for _fstati64... yes
checking whether strcasecmp is declared... yes
checking whether stricmp is declared... yes
checking whether strncasecmp is declared... yes
checking whether strnicmp is declared... yes
checking whether strsep is declared... no
checking whether strlcpy is declared... no
checking whether strnlen is declared... yes
checking for uintptr_t... yes
checking for cpu_to_le16... no
checking for cpu_to_le32... no
checking for cpu_to_le64... no
checking for __cpu_to_le16... no
checking for __cpu_to_le32... no
checking for __cpu_to_le64... no
checking for htole16... no
checking for htole32... no
checking for htole64... no
checking for __bswap_16... no
checking for __bswap_32... no
checking for __bswap_64... no
checking for __builtin_bswap16... yes
checking for __builtin_bswap32... yes
checking for __builtin_bswap64... yes
checking for _byteswap_ushort... no
checking for _byteswap_ulong... no
checking for _byteswap_uint64... no
checking if gcc accepts -Werror=attributes... yes
checking if gcc supports the noreturn function attribute... yes
checking if gcc supports the returns_nonnull function attribute... yes
checking if gcc supports the malloc function attribute... yes
checking if gcc supports the alloc_size function attribute... yes
checking if gcc supports the format function attribute... yes
checking if gcc supports the const function attribute... yes
checking if gcc supports the pure function attribute... yes
checking if gcc supports the error function attribute... yes
checking if gcc accepts -W... yes
checking if gcc accepts -Wall... yes
checking if gcc accepts -pedantic... yes
checking if gcc accepts -Werror=unknown-warning-option... no
checking if gcc accepts -Wpedantic-ms-format... yes
checking if gcc accepts -Wc90-c99-compat... yes
checking if gcc accepts -Wlong-long... yes
checking if gcc accepts -Werror=implicit... yes
checking if gcc accepts -Werror=missing-braces... yes
checking if gcc accepts -Werror=return-type... yes
checking if gcc accepts -Werror=trigraphs... yes
checking if gcc accepts -Werror=pointer-arith... yes
checking if gcc accepts -Werror=strict-prototypes... no
checking if gcc accepts -Werror=missing-prototypes... yes
checking if gcc accepts -Werror=missing-declarations... yes
checking if gcc accepts -Werror=comment... yes
checking if gcc accepts -Werror=vla... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating config/config.h
config.status: config/config.h is unchanged
config.status: executing default-1 commands

_@_-PC ~/nasm-2.14rc0
$ make
gcc -c -g -O3 -fwrapv -U__STRICT_ANSI__ -fno-common -Werror=attributes -W -Wall
-pedantic -Wno-pedantic-ms-format -Wc90-c99-compat -Wno-long-long -Werror=implic
it -Werror=missing-braces -Werror=return-type -Werror=trigraphs -Werror=pointer-
arith -Werror=missing-prototypes -Werror=missing-declarations -Werror=comment -W
error=vla -DHAVE_CONFIG_H -I. -I. -I./include -I./include -I./x86 -I./x86 -I./as
m -I./asm -I./disasm -I./disasm -I./output -I./output -o nasmlib/file.o nasmlib/
file.c
In file included from nasmlib/file.h:38:0,
                 from nasmlib/file.c:34:
nasmlib/file.c: In function 'fwritezero':
./include/nasmlib.h:343:18: error: implicit declaration of function '_ftelli64'
[-Werror=implicit-function-declaration]
 #  define ftello _ftelli64
              ^
nasmlib/file.c:114:14: note: in expansion of macro 'ftello'
  off_t pos = ftello(fp);
          ^~~~~~
In file included from nasmlib/file.c:34:0:
nasmlib/file.h:72:34: error: implicit declaration of function '_chsize_s' [-Werr
or=implicit-function-declaration]
 # define nasm_ftruncate(fd,size) _chsize_s(fd,size)
                              ^
nasmlib/file.c:118:4: note: in expansion of macro 'nasm_ftruncate'
   !nasm_ftruncate(fileno(fp), pos) &&
    ^~~~~~~~~~~~~~
In file included from nasmlib/file.h:38:0,
                 from nasmlib/file.c:34:
./include/nasmlib.h:342:18: error: implicit declaration of function '_fseeki64'
[-Werror=implicit-function-declaration]
 #  define fseeko _fseeki64
                  ^
nasmlib/file.c:119:4: note: in expansion of macro 'fseeko'
   !fseeko(fp, pos, SEEK_SET))
    ^~~~~~
cc1.exe: some warnings being treated as errors
make: *** [nasmlib/file.o] Error 1

_@_-PC ~/nasm-2.14rc0
$

« Last Edit: August 08, 2017, 11:09:36 PM by ~ »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How to compile NASM itself under Windows
« Reply #3 on: August 08, 2017, 11:49:02 PM »
Well, I don't know what to make of that, ~. You might try the developer's list:
https://sourceforge.net/projects/nasm/lists/nasm-devel
and see if they can give you any help. Good Luck!

Best,
Frank


Offline ~

  • Jr. Member
  • *
  • Posts: 8
Re: How to compile NASM itself under Windows
« Reply #4 on: August 09, 2017, 12:01:47 AM »
In the meantime, if I cannot get to compile with MinGW, I will most surely be able to compile with the tools you pointed out.

Offline ~

  • Jr. Member
  • *
  • Posts: 8
Re: How to compile NASM itself under Windows
« Reply #5 on: August 29, 2017, 03:12:52 PM »
I made a video showing how to compile NASM with Open Watcom for win32 and dos targets:

http://www.youtube.com/?v=hoprabiNWbI


I had to modify a NASM include file because the compiler said that there was an incompatible redefinition of 2 functions, so I copied the function definition itself into the header file for those functions, and NASM 2.13.01 compiled properly.

Offline ~

  • Jr. Member
  • *
  • Posts: 8
Re: How to compile NASM itself under Windows
« Reply #6 on: September 04, 2017, 10:18:02 PM »
Build Environment (under Windows):
Code: [Select]
c:\nasm-2.13.01> wmake /f Mkfiles/openwcom.mak win32




- Edit Mkfiles/openwcom.mak as text file.
- Search for INTERNAL_CFLAGS and enclose
  in double quotes all -I directives,
  for example -I. will be -I"."

- Open include/insns.h.
- Change:
Code: [Select]
int const_func idata_bytes(enum opcode opcode);to
Code: [Select]
int idata_bytes(int opcode);
...and...

Code: [Select]
int const_func resv_bytes(enum opcode opcode);to
Code: [Select]
int resv_bytes(int opcode);


... as in common/common.c


http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.zip

open-watcom-2_0-c-win-x86.exe
https://sourceforge.net/projects/openwatcom/files/current-build/
« Last Edit: September 04, 2017, 10:20:31 PM by ~ »