Skip to content

Conversation

jmalak
Copy link
Contributor

@jmalak jmalak commented Oct 5, 2025

fix slashes (use only forward slash) to be portable between Windows and Linux host
fix source path for static and generated source files
add autodepend info into object files to rebuild only what is necessary
use wcc386 instead of wcl386, wcl386 has no sense only add one indirect layer more
wmake can use DLL version of OW tools that processing is faster on platforms which use DLL

@hpax
Copy link
Member

hpax commented Oct 9, 2025

Could you please coordinate with @komh on this? He has submitted a different series, and uses OS/2, which is really the only platform for which there is a reason to use OpenWatcom to compile NASM these days (in my opinion.)

See #122 for reference.

@jmalak jmalak force-pushed the fix-6 branch 2 times, most recently from 8d37495 to ae38569 Compare October 10, 2025 01:24
@komh
Copy link
Contributor

komh commented Oct 10, 2025

Hi/2.

With this, the whole build is requested whenever calling wmake like:

Open Watcom Make Version 2.0.1
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
	set COPYCMD=/y
	perl -I./perllib -I. ./x86/preinsns.pl ./x86/insns.dat x86\insns.xda
	perl -I./perllib -I. ./x86/insns.pl -b x86/insns.xda x86/insnsb.c
Reading insns.dat...
Writing x86/insnsb.c...
Done: 12061 instructions
	perl -I./perllib -I. ./x86/insns.pl -a x86/insns.xda x86/insnsa.c
Reading insns.dat...
Writing x86/insnsa.c...
Done: 12061 instructions
	perl -I./perllib -I. ./x86/insns.pl -d x86/insns.xda x86/insnsd.c
Reading insns.dat...
Writing x86/insnsd.c...
Done: 12061 instructions
	perl -I./perllib -I. ./x86/insns.pl -i x86/insns.xda x86/insnsi.h
Reading insns.dat...
Writing x86/insnsi.h...
Done: 12061 instructions
	perl -I./perllib -I. ./x86/insns.pl -n x86/insns.xda x86/insnsn.c
Reading insns.dat...
Writing x86/insnsn.c...
Done: 12061 instructions
	perl -I./perllib -I. ./x86/regs.pl c ./x86/regs.dat > x86/regs.c
	perl -I./perllib -I. ./x86/regs.pl h ./x86/regs.dat > x86/regs.h
	perl -I./perllib -I. ./x86/regs.pl fc ./x86/regs.dat > x86/regflags.c
	perl -I./perllib -I. ./x86/regs.pl dc ./x86/regs.dat > x86/regdis.c
	perl -I./perllib -I. ./x86/regs.pl dh ./x86/regs.dat > x86/regdis.h
	perl -I./perllib -I. ./x86/regs.pl vc ./x86/regs.dat > x86/regvals.c
	perl -I./perllib -I. ./asm/tokhash.pl c 		x86/insnsn.c ./x86/regs.dat 		./asm/tokens.dat > asm/tokhash.c
3089 vectors, trying n = 8192...
1: Done: n = 8192, sv = [0x076259c3, 0xe291c26c]
	perl -I./perllib -I. ./asm/tokhash.pl h 		x86/insnsn.c ./x86/regs.dat 		./asm/tokens.dat > asm/tokens.h
	perl -I./perllib -I. ./asm/pptok.pl h ./asm/pptok.dat asm/pptok.h
	perl -I./perllib -I. ./asm/pptok.pl c ./asm/pptok.dat asm/pptok.c
128 vectors, trying n = 256...
1: Done: n = 256, sv = [0x076259c3, 0xe291c26c]
10 vectors, trying n = 16...
1: Done: n = 16, sv = [0x076259c3, 0xe291c26c]
	perl -I./perllib -I. ./x86/insns.pl -fc x86/insns.xda x86/iflag.c
Reading insns.dat...
Writing x86/iflag.c...
Done: 12061 instructions
	perl -I./perllib -I. ./x86/insns.pl -fh x86/insns.xda x86/iflaggen.h
Reading insns.dat...
Writing x86/iflaggen.h...
Done: 12061 instructions
	perl -I./perllib -I. ./asm/pptok.pl ph ./asm/pptok.dat asm/pptok.ph
	perl -I./perllib -I. ./version.pl mac < ./version > version.mac
	perl -I./perllib -I. ./macros/macros.pl version.mac 		./macros/*.mac ./output/*.mac
6 vectors, trying n = 16...
1: Done: n = 16, sv = [0x076259c3, 0xe291c26c]
	perl -I./perllib -I. ./nasmlib/perfhash.pl c ./asm/directiv.dat asm/directbl.c
62 vectors, trying n = 128...
1: Done: n = 128, sv = [0x076259c3, 0xe291c26c]
	perl -I./perllib -I. ./nasmlib/perfhash.pl h ./asm/directiv.dat asm/directiv.h
	perl -I./perllib -I. ./asm/warnings.pl c asm/warnings_c.h 		./asm/warnings.dat
	perl -I./perllib -I. ./asm/warnings.pl h include/warnings.h 		./asm/warnings.dat
	perl -I./perllib -I. ./asm/warnings.pl doc doc/warnings.src 		./asm/warnings.dat
	perl -I./perllib -I. ./version.pl h < ./version > version.h
	perl -I./perllib -I. ./version.pl make < ./version > version.mak
	perl -I./perllib -I. ./version.pl nsis < ./version > nsis/version.nsh
	wcl386 -c -zq -6 -ox -wx -wcd=124 -ze -fpi  -bt=OS2 -I"F:\lang\watcom/h" -I"F:\lang\watcom/h/os2" -I. -Iasm -Ix86 -Iinclude -I"." -I"./include" -I"./asm" -I"./x86" -I"./disasm" -I"./output" -I"./zlib" -fo=asm\directbl.obj .\asm\directbl.c
	wcl386 -c -zq -6 -ox -wx -wcd=124 -ze -fpi  -bt=OS2 -I"F:\lang\watcom/h" -I"F:\lang\watcom/h/os2" -I. -Iasm -Ix86 -Iinclude -I"." -I"./include" -I"./asm" -I"./x86" -I"./disasm" -I"./output" -I"./zlib" -fo=asm\pptok.obj .\asm\pptok.c
	wcl386 -c -zq -6 -ox -wx -wcd=124 -ze -fpi  -bt=OS2 -I"F:\lang\watcom/h" -I"F:\lang\watcom/h/os2" -I. -Iasm -Ix86 -Iinclude -I"." -I"./include" -I"./asm" -I"./x86" -I"./disasm" -I"./output" -I"./zlib" -fo=asm\tokhash.obj .\asm\tokhash.c
	wcl386 -c -zq -6 -ox -wx -wcd=124 -ze -fpi  -bt=OS2 -I"F:\lang\watcom/h" -I"F:\lang\watcom/h/os2" -I. -Iasm -Ix86 -Iinclude -I"." -I"./include" -I"./asm" -I"./x86" -I"./disasm" -I"./output" -I"./zlib" -fo=macros\macros.obj .\macros\macros.c

And the following error occurs:

Error(F38): (.\nasmlib\crc32.c) does not exist and cannot be made from existing files

@jmalak jmalak force-pushed the fix-6 branch 5 times, most recently from fd1c575 to e9ed91f Compare October 10, 2025 16:22
@jmalak
Copy link
Contributor Author

jmalak commented Oct 10, 2025

the name of crc32.c in nasmlib subdirectory was changed to crc32b.c therefore it cannot be build.
I fix name of file in Open Watcom make file and removed explicit dependency for crc32.c files, which is not needed now.

image

@jmalak jmalak force-pushed the fix-6 branch 5 times, most recently from cd12fec to 1a9e6ab Compare October 11, 2025 08:28
@jmalak
Copy link
Contributor Author

jmalak commented Oct 11, 2025

I added autodepend info into object files to rebuild only what is necessary

@jmalak
Copy link
Contributor Author

jmalak commented Oct 11, 2025

I don't understand why wcl386 tool was used, it only slowdown compilation and doesn't add any value in nasm makefile.
I replaced it by wcc386 command that wmake can call C compiler directly as DLL and compilation is much faster.

@jmalak jmalak force-pushed the fix-6 branch 2 times, most recently from 0c2b705 to ba10367 Compare October 13, 2025 02:09
@komh
Copy link
Contributor

komh commented Oct 13, 2025

Still the full build is done whenever calling wmake on OS/2.

@jmalak
Copy link
Contributor Author

jmalak commented Oct 14, 2025

There is issue with $(DIRS) dependency.
It contains names of subdirectories which clash with some phony targets names that cannot be implicitly created by wmake.
I will rework make file by explicit subdirectory creation.

@jmalak jmalak force-pushed the fix-6 branch 2 times, most recently from cc0099a to cbe2db9 Compare October 15, 2025 09:01
@jmalak
Copy link
Contributor Author

jmalak commented Oct 15, 2025

I fixed it and now dependency works OK and output subdirectories are created if not exists.
It is control by wmake implementation of if command which check existence of target subdirectory before compilation and create it if not exist and next compile output file into this subdirectory.
Anyway building nasm into source tree with same subdirectories is not good practice.

@hpax
Copy link
Member

hpax commented Oct 16, 2025

That being said, the non-autoconf Makefiles aren't good practice either.

That's why I would really love to see if someone have been able to use GNU make, autoconf, and owcc.

However, OW really need to step up their game on C99 compliance if we are going to be able to keep supporting them.

@komh
Copy link
Contributor

komh commented Oct 16, 2025

This caues the following error on OS/2:

Open Watcom Make Version 2.0.1
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
	mkdir x86\
 [7]  SYS0005: Access is denied. "F:\lang\work\nasm\nasm.git\x86"
Error(E42): Last command making (check_outdir;x86\insnsd.c;os2) returned a bad status
Error(E02): Make execution terminated

Instead, it would be simpler and better to use .BEFORE like:

DIRS =
.BEFORE
     @for %d in ($(SUBDIRS) $(XSUBDIRS)) do @if not exist %d mkdir %d

How about?

@jmalak jmalak force-pushed the fix-6 branch 2 times, most recently from 64c503b to b96f1e3 Compare October 16, 2025 06:58
@jmalak
Copy link
Contributor Author

jmalak commented Oct 16, 2025

Oh I forgot the trailing separator issue on OS/2.
Yes, it is better solution.

@komh
Copy link
Contributor

komh commented Oct 16, 2025

Thanks, it works!

BTW, the commit e86773d was missed.

@jmalak
Copy link
Contributor Author

jmalak commented Oct 16, 2025

I fixed it.

I have a question if you prefer use of tabs or spaces in OW makefile?

@komh
Copy link
Contributor

komh commented Oct 17, 2025

It works! and I prefer spaces.

Thanks!

@jmalak
Copy link
Contributor Author

jmalak commented Oct 17, 2025

I replace all tabs by spaces that it is finished.

@komh
Copy link
Contributor

komh commented Oct 17, 2025

Thanks!

@jmalak
Copy link
Contributor Author

jmalak commented Oct 17, 2025

If you are interested in ci-build by OW then below is copy of my test script for GitHub Actions
It is limites for Windows and Linux hosts, it is possible to configure it also to use OSX (Intel or ARM) host for cross-compilation but not for OS/2 host which is not available on GitHub, but all these host cross-compile nasm for OS/2

name: CI-Build
run-name: CI build

on:
  pull_request:
    branches: '*'
    paths:
      - '**'
      - '!.github/**'
      - '!README.md'
  push:
    branches:
      - master
    paths:
      - '**'
      - '!.github/**'
      - '!README.md'
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true


jobs:
  OpenWatcom-1:
    strategy:
      matrix:
        targ:
          - id: 'dos'
            title: 'DOS'
          - id: 'os2'
            title: 'OS/2'
          - id: 'win32'
            title: 'WIN32'
          - id: 'linux386'
            title: 'Linux'
        host:
          - id: 'Linux'
            image: 'ubuntu-latest'
          - id: 'Windows'
            image: 'windows-latest'
        comp: 
          - id: '1.9'
          - id: '2.0'
    runs-on: ${{matrix.host.image}}
    name: ${{matrix.targ.title}} - Open Watcom ${{matrix.comp.id}} (${{matrix.host.id}} host)

    steps:
    - name: checkout
      uses: actions/checkout@v4
    - name: Open Watcom setup
      uses: open-watcom/setup-watcom@v0
      with:
        version: ${{matrix.comp.id}}
    - name: build
      run: |
        wmake -d -sn -f Mkfiles/openwcom.mak ${{matrix.targ.id}}
  Linux-1:
    strategy:
      matrix:
        targ:
          - id: 'Linux'
        host:
          - id: 'Ubuntu'
            image: 'ubuntu-latest'
        comp: 
          - id: 'GCC'
    runs-on: ${{matrix.host.image}}
    name: ${{matrix.targ.id}} - ${{matrix.comp.id}} (${{matrix.host.id}} host)

    steps:
    - name: checkout
      uses: actions/checkout@v4
    - name: install perl module
      run: sudo cpan -i Font::TTF::Font Sort::Versions
      shell: bash
    - name: autogen
      run: |
        ./autogen.sh
      shell: bash
    - name: configure
      run: |
        ./configure
      shell: bash
    - name: build
      run: |
        make all
      shell: bash
  Windows-1:
    strategy:
      matrix:
        targ:
          - id: 'WIN64'
        host:
          - id: 'Windows 2025'
            image: 'windows-latest'
        comp: 
          - id: '2022'
    runs-on: ${{matrix.host.image}}
    name: ${{matrix.targ.id}} - Visual Studio ${{matrix.comp.id}} (${{matrix.host.id}} host)

    steps:
    - name: checkout
      uses: actions/checkout@v4
    - name: Enable Developer Command Prompt
      uses: ilammy/msvc-dev-cmd@v1
      with:
        vsversion: ${{matrix.comp.id}}
        arch: amd64
    - name: build
      run: |
        nmake /f Mkfiles\msvc.mak all
      shell: cmd

We are working on fixing OW C compiler to works with 64-bit items in switch statement then it will be possible to remove related hacks from nasm source.
It will be necessary to use latest version of OW 2.0 to build nasm because all previous WATCOM and Open Watcom compilers has this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants