Skip to content
This repository was archived by the owner on Jun 8, 2018. It is now read-only.

Commit 7f8c203

Browse files
committed
Updated compile scripts, now detect target bitness automatically and take -n -f -d as a commandline argument to determine compile mode
1 parent 15a6de8 commit 7f8c203

File tree

2 files changed

+56
-20
lines changed

2 files changed

+56
-20
lines changed

comp.bat

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
11
@echo off
22
echo ----------------------------------------------------------------------
3-
set mode=d32
3+
4+
REM Ask the compiler how many bits we're targeting
5+
for /F "delims=" %%A in ('fpc -iTP') do set tcpu=%%A
6+
if %tcpu%==i386 set bits=32
7+
if %tcpu%==x86_64 set bits=64
8+
9+
REM Check commandline's first parameter for -n -f -d mode, -d is default
10+
set mode=d%bits%
11+
if "%1"=="-n" (
12+
set mode=n%bits%
13+
shift
14+
)
15+
if "%1"=="-f" (
16+
set mode=fpo%bits%
17+
shift
18+
)
19+
if "%1"=="-d" (
20+
set mode=d%bits%
21+
shift
22+
)
23+
24+
echo Compile mode: %mode%
425

526
REM When switching between modes, add -B as an argument to rebuild all code
627

728
REM Normal:
8-
if %mode%==32 fpc -CX -XXs- -O3oloopunroll,deadstore -OpPentium3 -CpPentium %*
9-
if %mode%==64 fpc -CX -XXs- -O3oloopunroll,deadstore -CpAthlon64 %*
29+
if %mode%==n32 fpc -CX -XXs- -O3oloopunroll,deadstore -OpPentium3 -CpPentium %1 %2 %3 %4
30+
if %mode%==n64 fpc -CX -XXs- -O3oloopunroll,deadstore -CpAthlon64 %1 %2 %3 %4
1031

1132
REM Full-program optimised:
1233
if %mode%==fpo32 (
13-
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -OpPentium3 -CpPentium %*
14-
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -OpPentium3 -CpPentium %*
34+
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -OpPentium3 -CpPentium %1 %2 %3 %4
35+
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -OpPentium3 -CpPentium %1 %2 %3 %4
1536
if exist opti.dat del opti.dat 1>nul
1637
)
1738

1839
if %mode%==fpo64 (
19-
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -CpAthlon64 %*
20-
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -CpAthlon64 %*
40+
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -CpAthlon64 %1 %2 %3 %4
41+
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -CpAthlon64 %1 %2 %3 %4
2142
if exist opti.dat del opti.dat 1>nul
2243
)
2344

2445
REM Debug: (add -gc in FPC304+, see if still crashes unit compilation)
25-
if %mode%==d32 fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -OpPentium3 -CpPentium %*
26-
if %mode%==d64 fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -CpAthlon64 %*
46+
if %mode%==d32 fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -OpPentium3 -CpPentium %1 %2 %3 %4
47+
if %mode%==d64 fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -CpAthlon64 %1 %2 %3 %4
2748

comp.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
1+
echo ----------------------------------------------------------------
2+
3+
# Ask the compiler how many bits we're targeting
4+
TCPU="$(fpc -iTP)"
5+
if [ "$TCPU" = "i386" ]; then BITS=32; fi
6+
if [ "$TCPU" = "x86_64" ]; then BITS=64; fi
7+
8+
# Check commandline's first parameter for -n -f -d mode, -d is default
9+
10+
mode=d$BITS
11+
if [ "$1" = "-n" ]; then mode=n$BITS; shift; fi
12+
if [ "$1" = "-f" ]; then mode=fpo$BITS; shift; fi
13+
if [ "$1" = "-d" ]; then mode=d$BITS; shift; fi
14+
15+
echo "Compile mode: $mode"
16+
117
# When switching between modes, add -B as an argument to rebuild all code
2-
mode="d64"
318

419
# Normal:
5-
if [ "$mode" = "32" ]; then fpc -CX -XXs- -O3oloopunroll,deadstore -OpPentium3 -CpPentium $*; fi
6-
if [ "$mode" = "64" ]; then fpc -CX -XXs- -O3oloopunroll,deadstore -CpAthlon64 $*; fi
20+
if [ "$mode" = "n32" ]; then fpc -CX -XXs- -O3oloopunroll,deadstore -OpPentium3 -CpPentium $1 $2 $3 $4; fi
21+
if [ "$mode" = "n64" ]; then fpc -CX -XXs- -O3oloopunroll,deadstore -CpAthlon64 $1 $2 $3 $4; fi
722

823
# Full-program optimised:
924
if [ "$mode" = "fpo32" ]; then
10-
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -OpPentium3 -CpPentium $*
11-
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -OpPentium3 -CpPentium $*
12-
if [-e opti.dat]; then rm opti.dat; fi
25+
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -OpPentium3 -CpPentium $1 $2 $3 $4
26+
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -OpPentium3 -CpPentium $1 $2 $3 $4
27+
if [ -e opti.dat ]; then rm opti.dat; fi
1328
fi
1429

1530
if [ "$mode" = "fpo64" ]; then
16-
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -CpAthlon64 $*
17-
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -CpAthlon64 $*
18-
if [-e opti.dat]; then rm opti.dat; fi
31+
fpc -FWopti.dat -CX -XXs- -O3oloopunroll,deadstore -OWall -CpAthlon64 $1 $2 $3 $4
32+
fpc -Fwopti.dat -CX -XXs -O3oloopunroll,deadstore -Owall -CpAthlon64 $1 $2 $3 $4
33+
if [ -e opti.dat ]; then rm opti.dat; fi
1934
fi
2035

2136
# Debug: (-gc not supported yet)
22-
if [ "$mode" = "d32" ]; then fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -OpPentium3 -CpPentium $*; fi
23-
if [ "$mode" = "d64" ]; then fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -CpAthlon64 $*; fi
37+
if [ "$mode" = "d32" ]; then fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -OpPentium3 -CpPentium $1 $2 $3 $4; fi
38+
if [ "$mode" = "d64" ]; then fpc -ghlt -vwinh -XXs- -Cotr -O3odeadstore -CpAthlon64 $1 $2 $3 $4; fi

0 commit comments

Comments
 (0)