Skip to content

Commit

Permalink
[WIP] Add Borland 3.1 compiler to MS-DOS platform (#1419)
Browse files Browse the repository at this point in the history
* Add Borland 3.1 compiler to MS-DOS platform

* Fix formatting

* Remove useless "rm"

* Update asm-differ
  • Loading branch information
Gillou68310 authored Jan 28, 2025
1 parent 72f7bf6 commit 7fc6643
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ jobs:
- name: Install msdos assembler
run: |-
wget https://github.com/OmniBlade/binutils-gdb/releases/download/omf-build/omftools.tar.gz
sudo tar xvzf omftools.tar.gz -C /usr/bin jwasm omf-nm omf-objdump
sudo tar xvzf omftools.tar.gz -C /usr/bin jwasm
wget https://github.com/sillyc0n/binutils-gdb/releases/download/2.42-build7/omftools-2.42-build7-linux-x86_64.tar.gz
sudo tar xvzf omftools-2.42-build7-linux-x86_64.tar.gz -C /usr/bin omf-nm omf-objdump
- name: Install mips PS2 binutils
run: |-
wget https://github.com/decompals/binutils-mips-ps2-decompals/releases/download/v0.4/binutils-mips-ps2-decompals-linux-x86-64.tar.gz
Expand Down
7 changes: 5 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ RUN if [ "${ENABLE_PS2_SUPPORT}" = "YES" ] || [ "${ENABLE_PSP_SUPPORT}" = "YES"
# msdos specific
RUN if [ "${ENABLE_MSDOS_SUPPORT}" = "YES" ]; then \
wget "https://github.com/OmniBlade/binutils-gdb/releases/download/omf-build/omftools.tar.gz" && \
tar xvzf omftools.tar.gz -C /usr/bin jwasm omf-nm omf-objdump && \
rm omftools.tar.gz; \
tar xvzf omftools.tar.gz -C /usr/bin jwasm && \
rm omftools.tar.gz && \
wget "https://github.com/sillyc0n/binutils-gdb/releases/download/2.42-build7/omftools-2.42-build7-linux-x86_64.tar.gz" && \
tar xvzf omftools-2.42-build7-linux-x86_64.tar.gz -C /usr/bin omf-nm omf-objdump && \
rm omftools-2.42-build7-linux-x86_64.tar.gz; \
fi

# Patched PowerPC binutils
Expand Down
1 change: 1 addition & 0 deletions backend/compilers/compilers.linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ msdos:
- wcc10.5a
- wcc10.6
- wcc11.0
- bcc3.1

win32:
- msvc4.0
Expand Down
3 changes: 1 addition & 2 deletions backend/coreapp/asm_preludes/msdos.s
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.386P
.model FLAT

22 changes: 22 additions & 0 deletions backend/coreapp/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
COMMON_MWCC_PSP_FLAGS,
COMMON_MWCC_WII_GC_FLAGS,
COMMON_WATCOM_FLAGS,
COMMON_BORLAND_FLAGS,
Flags,
Language,
)
Expand Down Expand Up @@ -184,6 +185,12 @@ class WatcomCompiler(Compiler):
library_include_flag: str = "/IZ:"


@dataclass(frozen=True)
class BorlandCompiler(Compiler):
flags: ClassVar[Flags] = COMMON_BORLAND_FLAGS
library_include_flag: str = ""


def from_id(compiler_id: str) -> Compiler:
if compiler_id not in _compilers:
raise APIException(
Expand Down Expand Up @@ -1472,6 +1479,19 @@ def available_platforms() -> List[Platform]:
cc=WATCOM_CXX,
)

BORLAND_MSDOS_CC = (
'cat "$INPUT" | unix2dos > dos_src.c && '
"echo \"\$_hdimage = '+0 ${COMPILER_DIR} +1'\" > .dosemurc && "
'(HOME="." /usr/bin/dosemu -quiet -dumb -f .dosemurc -K . -E "D:\\bin\\bcc.exe -ID:\\include ${COMPILER_FLAGS} -c -oout.o dos_src.c") && '
'cp out.o "$OUTPUT"'
)

BORLAND_31_C = BorlandCompiler(
id="bcc3.1",
platform=MSDOS,
cc=BORLAND_MSDOS_CC,
)

_all_compilers: List[Compiler] = [
DUMMY,
DUMMY_LONGRUNNING,
Expand Down Expand Up @@ -1682,6 +1702,8 @@ def available_platforms() -> List[Platform]:
WATCOM_106_CPP,
WATCOM_110_C,
WATCOM_110_CPP,
# Borland, DOS
BORLAND_31_C,
]

_compilers = OrderedDict({c.id: c for c in _all_compilers if c.available()})
Expand Down
2 changes: 1 addition & 1 deletion backend/coreapp/diff_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_objdump_target_function_flags(

@staticmethod
def parse_objdump_flags(diff_flags: List[str]) -> List[str]:
known_objdump_flags = ["-Mno-aliases"]
known_objdump_flags = ["-Mno-aliases", "--reloc"]
known_objdump_flag_prefixes = ["-Mreg-names=", "--disassemble="]
ret = []

Expand Down
4 changes: 4 additions & 0 deletions backend/coreapp/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,7 @@ def to_json(self) -> Dict[str, Union[str, List[str]]]:
Checkbox("watcom_signedchar", "-j"),
Checkbox("watcom_fpu", "-fpi87"),
]

COMMON_MSDOS_DIFF_FLAGS: Flags = [Checkbox("diff_reloc", "--reloc")]

COMMON_BORLAND_FLAGS: Flags = []
11 changes: 9 additions & 2 deletions backend/coreapp/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from pathlib import Path
import functools

from coreapp.flags import COMMON_DIFF_FLAGS, COMMON_MIPS_DIFF_FLAGS, Flags
from coreapp.flags import (
COMMON_DIFF_FLAGS,
COMMON_MIPS_DIFF_FLAGS,
COMMON_MSDOS_DIFF_FLAGS,
Flags,
)
from coreapp.models.preset import Preset
from coreapp.models.scratch import Scratch
from rest_framework.exceptions import APIException
Expand Down Expand Up @@ -78,10 +83,12 @@ def from_id(platform_id: str) -> Platform:
id="msdos",
name="Microsoft DOS",
description="x86",
arch="i686",
arch="x86",
assemble_cmd='jwasm -c -Fo"$OUTPUT" -Fi"$PRELUDE" "$INPUT"',
objdump_cmd="omf-objdump",
nm_cmd="omf-nm",
supports_objdump_disassemble=True,
diff_flags=COMMON_DIFF_FLAGS + COMMON_MSDOS_DIFF_FLAGS,
)

WIN32 = Platform(
Expand Down
2 changes: 1 addition & 1 deletion backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frontend/src/lib/i18n/locales/en/compilers.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@
"wcc11.0": "Watcom Optimizing C i386 Compiler 11.0",
"wpp11.0": "Watcom Optimizing C++ i386 Compiler 11.0",

"bcc3.1": "Borland C i386 Compiler 3.1",

"cygnus-2.7-96Q3": "cygnus-2.7-96Q3 SOA-960904",

"armcc_opt_level": "Optimization level",
Expand Down Expand Up @@ -458,6 +460,7 @@
"mno_aliases": "Disable pseudo instructions",
"no_show_rodata_refs": "Hide rodata refs in diff, e.g. jtbl labels",
"diff_function_symbols": "Include function labels in diff",
"diff_reloc": "Diff relocation",

"diff_algorithm": "Diff algorithm",
"diff_algorithm.-DIFFlevenshtein": "Levenshtein",
Expand Down

0 comments on commit 7fc6643

Please sign in to comment.