- Toolchain overrides via `[toolchain]` and env (`DCR_*`)
- ASM `.S` preprocessing via GCC/Clang (`-x assembler-with-cpp`)
This commit is contained in:
2026-03-03 22:25:00 +08:00
parent 9af91a0d9f
commit 617ba85442
16 changed files with 215 additions and 19 deletions

View File

@@ -26,6 +26,17 @@ kind = "bin"
- `cflags` (string array, optional): extra compile flags.
- `ldflags` (string array, optional): extra link flags.
## Toolchain section
```toml
[toolchain]
cc = "clang"
cxx = "clang++"
as = "as"
ar = "ar"
ld = "ld"
```
## Behavior notes
- Compiler backend is selected by compiler string (`gcc`, `clang`, `cl`, `clang-cl`).

View File

@@ -39,6 +39,18 @@ If `build.platform` is set, DCR passes it as an architecture hint:
- GCC/Clang: `-march=<platform>`
- MSVC: maps to `/arch:*` for known values (`x86`, `i386`, `i486`, `i586`, `i686`, `sse2`, `avx`, `avx2`)
## Toolchain overrides
If `[toolchain]` is set, DCR uses its values to override compiler/linker tools:
- `cc`, `cxx`, `as` override compilers for C/C++/ASM
- `ar` overrides the archiver (used for `staticlib`)
- `ld` overrides the linker (used by GCC/Clang/NASM/GAS backends)
Environment overrides (highest priority):
- `DCR_COMPILER` (all languages)
- `DCR_CC`, `DCR_CXX`, `DCR_AS`, `DCR_AR`, `DCR_LD`
## Linking
For `kind = "bin"`:

View File

@@ -17,6 +17,13 @@ platform = "string" # optional
cflags = ["string", "..."] # optional
ldflags = ["string", "..."] # optional
[toolchain]
cc = "string" # optional
cxx = "string" # optional
as = "string" # optional
ar = "string" # optional
ld = "string" # optional
[dependencies]
name = {
path = "string", # required for each dependency