Skip to content

Commit

Permalink
Define owcc (OpenWatcom C compiler) as a supported compiler.
Browse files Browse the repository at this point in the history
This is a much better idea than simply changing the the `gcc` binary
to be `owcc`, since OpenWatcom does not support certain features such
as case ranges. `$nim/config/nim.cfg` has been updated to reflect this
change. The proper memory model is also now automatically selected for
the `i086` and `i086big` CPU targets and `-bdos` is also automatically
passed to the C compiler.
  • Loading branch information
Ronsor committed Apr 25, 2022
1 parent 0f5dc5e commit 4feda71
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
29 changes: 28 additions & 1 deletion compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,32 @@ compiler tcc:
cppXsupport: "",
props: {hasSwitchRange, hasComputedGoto, hasGnuAsm})

# OpenWatcom C Compiler
compiler owcc:
result = (
name: "owcc",
objExt: "o",
optSpeed: " -O3",
optSize: " -Os",
compilerExe: "owcc",
cppCompiler: "owcc",
compileTmpl: "-c $options $include -o $objfile $file",
buildGui: " -mwindows",
buildDll: " -shared",
buildLib: "wlib $libfile $objfiles",
linkerExe: "",
linkTmpl: "$buildgui $builddll -o $exefile $objfiles $options",
includeCmd: " -I",
linkDirCmd: " -L",
linkLibCmd: " -l$1",
debug: "",
pic: "",
asmStmtFrmt: "$1 $2",
structStmtFmt: "$1 $2", # struct|union [packed] $name
produceAsm: gnuAsmListing,
cppXsupport: "",
props: {hasGnuAsm})

# Your C Compiler
compiler envcc:
result = (
Expand Down Expand Up @@ -280,7 +306,8 @@ const
envcc(),
icl(),
icc(),
clangcl()]
clangcl(),
owcc()]

hExt* = ".h"

Expand Down
2 changes: 1 addition & 1 deletion compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ type

TSystemCC* = enum
ccNone, ccGcc, ccNintendoSwitch, ccLLVM_Gcc, ccCLang, ccBcc, ccVcc,
ccTcc, ccEnv, ccIcl, ccIcc, ccClangCl
ccTcc, ccEnv, ccIcl, ccIcc, ccClangCl, ccOwcc

ExceptionSystem* = enum
excNone, # no exception system selected yet
Expand Down
20 changes: 14 additions & 6 deletions config/nim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ riscv32.linux.gcc.exe = "riscv64-linux-gnu-gcc"
riscv32.linux.gcc.linkerexe = "riscv64-linux-gnu-gcc"
riscv64.linux.gcc.exe = "riscv64-linux-gnu-gcc"
riscv64.linux.gcc.linkerexe = "arm-linux-gnueabihf-gcc"
# 16-bit x86, e.g. 8086: OpenWatcom compiler
i086.dos.gcc.exe = "owcc"
i086.dos.gcc.linkerexe = "owcc"
# 16-bit x86, but with large/huge code and data model
i086big.dos.gcc.exe = "owcc"
i086big.dos.gcc.linkerexe = "owcc"

# For OpenWRT, you will also need to adjust PATH to point to your toolchain.
mips.linux.gcc.exe = "mips-openwrt-linux-gcc"
Expand Down Expand Up @@ -99,6 +93,20 @@ nimblepath="$home/.nimble/pkgs/"
gcc.options.always %= "${gcc.options.always} -fsanitize=null -fsanitize-undefined-trap-on-error"
@end

@if (i086 or i086big) and dos:
# Cross compile for DOS using OpenWatcom
cc = owcc
owcc.options.always %= "${owcc.options.always} -bdos"
owcc.options.linker %= "${owcc.options.linker} -bdos"
@if hugeModel:
owcc.options.always %= "${owcc.options.always} -mcmodel=h"
@elif largeModel or i086big:
owcc.options.always %= "${owcc.options.always} -mcmodel=l"
@elif smallModel or i086:
owcc.options.always %= "${owcc.options.always} -mcmodel=s"
@end
@end

@if unix and mingw:
# Cross compile for Windows from Linux/OSX using MinGW
i386.windows.gcc.exe = "i686-w64-mingw32-gcc"
Expand Down

0 comments on commit 4feda71

Please sign in to comment.