Skip to content
Skills Library
Programming · Building & coding

xmake-dlang

/xmake-dlang

Use when building D projects with xmake — binary/library targets with `.d` sources, DUB package integration via `add_requires("dub::...")`, and selecting DMD / LDC / GDC compilers.

Licence
Apache-2.0
Last repository change
24.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 24.08.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Use when building D projects with xmake — binary/library targets with `.d` sources, DUB package integration via `add_requires("dub::...")`, and selecting DMD / LDC / GDC compilers.

Triggers from the description

dub::...
Original author description

Use when building D projects with xmake — binary/library targets with `.d` sources, DUB package integration via `add_requires("dub::...")`, and selecting DMD / LDC / GDC compilers.

How it works

  1. 1. Minimal project
  2. 2. Target kinds
  3. 3. DUB dependencies (v2.3.6+)
  4. 4. Compiler selection
  5. 5. Flags
  6. 6. Mixing D with C
  7. Pitfalls
  8. When to branch out
Original SKILL.md headings · 93 lines, 300 words
SKILL.md preview
---
name: xmake-dlang
description: Use when building D projects with xmake — binary/library targets with `.d` sources, DUB package integration via `add_requires("dub::...")`, and selecting DMD / LDC / GDC compilers.
---

# Building D (dlang) with Xmake

D has three main compilers (DMD, LDC, GDC); xmake drives all of them through a unified `target()` API and supports DUB for package dependencies.

## 1. Minimal project

```bash
xmake create -l dlang -t console hello
cd hello
xmake run
```

```lua
add_rules("mode.debug", "mode.release")

target("hello")
    set_kind("binary")
    add_files("src/*.d")
```

## 2. Target kinds

```lua
target("app")       set_kind("binary")
target("mylib")     set_kind("static")
target("mydyn")     set_kind("shared")
```

## 3. DUB dependencies (v2.3.6+)

```lua
add_requires("dub::vibe-d ~>0.9.5")
add_requires("dub::libasync")

target("app")
    set_kind("binary")
    add_files("src/*.d")
    add_packages("dub::vibe-d", "dub::libasync")
```

Known limitation: cascading transitive deps must be declared manually for now. Add every dep in the tree explicitly.

## 4. Compiler selection

```bash
xmake f --toolchain=dlang                    # DMD (default)
xmake f --toolchain=ldc
xmake f --toolchain=gdc
```

Or pin paths:

```bash
xmake f --toolchain=ldc --sdk=/opt/ldc-1.30
```

LDC is usually the best choice for release builds (LLVM backend, best optimization). DMD is fastest to compile with.

## 5. Flags

```lua
target("app")
    add_files("src/*.d")
    add_dcflags("-O", "-release")          -- passed to the D compiler
    add_ldflags("-Wl,--as-needed")
```

`add_dcflags` = D compiler flags. Each compiler has its own flag dialect — prefer portable ones or gate with `if is_toolchain("ldc") then ... end`.

## 6. Mixing D with C

```lua
target("app")
    set_kind("binary")
    add_files("src/main.d", "src/extern.c")    -- mix C and D in one target
    add_includedirs("include")
```

D can call C directly via `extern (C)` declarations on the D side. No bridging needed.

## Pitfalls

- **Transitive DUB deps.** You must add them manually until xmake's DUB integration is complete.
- **Compiler-specific flags leaking across toolchains.** `add_dcflags("-mattr=+avx2")` works on LDC, fails on DMD. Gate with `is_toolchain`.
- **D shared libraries on Windows.** DMD and LDC produce different import-library formats; stick to one per project on Windows.

## When to branch out

- Build modes → `xmake-targets`, `xmake-build-optimization`
- Cross-compile → `xmake-cross-compilation` (LDC supports many targets)
- Package management basics → `xmake-packages`

Versions

The database has no other skills named xmake-dlang.

Database snapshot: 13.11.2026 · package version 5cad87e8b9bd (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100xmake-nim
    Use when building Nim projects with xmake — binary/library targets with `.nim` sources, choosing the C backend (the default) vs C++, and mixing Nim with C.
  • 100xmake-go
    Use when building Go projects with xmake — binary/library targets with `.go` sources, go module integration, cross-compiling Go programs for other OS/arch, and mixing Go with C via cgo.
  • 100dub-webhooks
    Receive and verify Dub webhooks. Use when configuring Dub webhook endpoints, debugging dub-signature signatures, or handling link.created, lead.created, sale.created.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.