aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 10:04:54 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 10:04:54 +0000
commit066a378ca09ccc5d8074a942cf4bf1b9d4f40729 (patch)
tree9a6ff973e6ef07f6fec425413868805d6aed4b03
parent0305500e31eda6fe6da84f88748fc20843aebbce (diff)
fix(driver): default native output to .exe on Windows
Without -o, cpsc saved test.out on every OS, which Windows cannot run directly. Use .exe under _WIN32 and keep .out elsewhere; update the manual and architecture notes accordingly. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
-rw-r--r--AGENTS/ARCH.md5
-rw-r--r--doc/cpsc.1.md4
-rw-r--r--tools/driver/main.cc7
3 files changed, 11 insertions, 5 deletions
diff --git a/AGENTS/ARCH.md b/AGENTS/ARCH.md
index 5ddddc1..f85364b 100644
--- a/AGENTS/ARCH.md
+++ b/AGENTS/ARCH.md
@@ -43,7 +43,7 @@ The following commands use Debian/Ubuntu's versioned compiler names:
cmake -S . -B build -DCPSC_RUN_MODE=EMBEDDED \
-DCMAKE_C_COMPILER=clang-23 -DCMAKE_CXX_COMPILER=clang++-23
cmake --build build
-build/cpsc prog.cps # save prog.out beside the source
+build/cpsc prog.cps # save prog.out (prog.exe on Windows) beside the source
build/cpsc prog.cps -S # save prog.ll beside the source
build/cpsc prog.cps -r # run without saving output
build/cpsc prog.cps -r -S -o prog.ll # save IR, then run it
@@ -104,7 +104,8 @@ Driver behavior (`tools/driver/main.cc`):
verification. Diagnostics stay on stderr; source errors preserve existing output.
Native linking uses a staged file beside the output and renames it on success.
- `-S` selects textual IR; otherwise output is a native executable. Without `-o`,
- replace the entry source extension with `.ll` or `.out` beside the source on every OS.
+ replace the entry source extension with `.ll`, or with `.exe` on Windows / `.out` elsewhere
+ for an executable, beside the source.
`-o` paths are used literally and never select the format. `-r` alone saves nothing;
either `-S` or `-o` requests saving before execution.
- Lexer, Parser and CodeGen track error flags (`hadError()`); any error, including
diff --git a/doc/cpsc.1.md b/doc/cpsc.1.md
index eb5140b..3fe1778 100644
--- a/doc/cpsc.1.md
+++ b/doc/cpsc.1.md
@@ -14,7 +14,7 @@ cpsc - compile and run CIE pseudocode
Compile one or more pseudocode source files to a native executable, or to textual LLVM IR with **-S**. Options may appear among the source paths. Source input from stdin is not supported.
-Without **-o**, save beside the entry source file, replacing its extension with `.out` for an executable or `.ll` for IR. This naming also applies on Windows. With **-r** alone, run without saving a file.
+Without **-o**, save beside the entry source file, replacing its extension with `.exe` on Windows or `.out` elsewhere for an executable, or `.ll` for IR. With **-r** alone, run without saving a file.
Each input is a compilation unit. Use top-level `INCLUDE "lib.cps"` to import another input's exported definitions, including its transitive imports. Paths are relative to the including source; every included file must also appear on the command line. Repeated includes and include cycles are harmless. Giving the same input twice, including symbolic or hard links, is an error. Duplicate definitions across files are errors even if the files do not include each other.
@@ -55,7 +55,7 @@ The executable has one of the following execution modes, selected when it was bu
# EXAMPLES
-Compile and save `test.out` beside `test.cps`:
+Compile and save `test.out` (`test.exe` on Windows) beside `test.cps`:
```sh
cpsc test.cps
diff --git a/tools/driver/main.cc b/tools/driver/main.cc
index 0b3033f..2908a0a 100644
--- a/tools/driver/main.cc
+++ b/tools/driver/main.cc
@@ -200,7 +200,12 @@ int main(int argc, char **argv) {
if (OutputPath.empty() && Save) {
llvm::SmallString<256> DefaultPath(InputPaths[CG.getMainUnit()]);
- llvm::sys::path::replace_extension(DefaultPath, EmitIR ? ".ll" : ".out");
+#ifdef _WIN32
+ const char *ExecutableExtension = ".exe";
+#else
+ const char *ExecutableExtension = ".out";
+#endif
+ llvm::sys::path::replace_extension(DefaultPath, EmitIR ? ".ll" : ExecutableExtension);
OutputPath = std::string(DefaultPath);
}
for (const auto &InputPath : InputPaths) {