Skip to content

std.compiler: report LDC's own version instead of the DMD frontend version - #76

Merged
JohanEngelen merged 2 commits into
ldc-developers:ldcfrom
usefahmed07:fix/1958-ldc-version-in-std-compiler
Aug 31, 2026
Merged

std.compiler: report LDC's own version instead of the DMD frontend version#76
JohanEngelen merged 2 commits into
ldc-developers:ldcfrom
usefahmed07:fix/1958-ldc-version-in-std-compiler

Conversation

@usefahmed07

Copy link
Copy Markdown

Fixes ldc-developers/ldc#1958

Fix: std.compiler.version_major/version_minor now report LDC's own version instead of the DMD frontend version.

Before this change, these values were computed from VERSION, which reflects the bundled DMD frontend version (e.g. 2112), not LDC's actual release version (e.g. 1.43). This meant std.compiler was reporting incorrect version numbers for LDC users.

Now, when compiling with LDC, version_major/version_minor are derived from LDC's real release version string instead.
Screenshot From 2026-08-30 14-17-27

… version

Fixes ldc-developers/ldc#1958.

std.compiler.version_major/version_minor previously derived from
__VERSION__, which reflects the DMD frontend version bundled into
LDC (e.g. 2112) rather than LDC's own release version (e.g. 1.43).

version(LDC) now computes version_major/version_minor from LDC's
actual release version string, string-imported at build time as
'ldccompilerversion.txt' (generated by the LDC build system).
@JohanEngelen

Copy link
Copy Markdown
Member

What about simply hardcoding the version into an __LDC_VERSION__ enum that is generated by the compiler (similar to __VERSION__), instead of the whole build complexity of generating a special file, adding that file to the distribution, reading that file, parsing the contents, ......

@usefahmed07

usefahmed07 commented Aug 30, 2026

Copy link
Copy Markdown
Author

What about simply hardcoding the version into an __LDC_VERSION__ enum that is generated by the compiler (similar to __VERSION__), instead of the whole build complexity of generating a special file, adding that file to the distribution, reading that file, parsing the contents, ......

oh Very nice u are right i will make it thanks!

Per review feedback on ldc-developers#76: use the new
__LDC_VERSION__ compiler-level magic identifier (see
ldc-developers/ldc#5277) instead of a build-generated string-import
file. This mirrors __VERSION__ and avoids extra build complexity.
@usefahmed07

Copy link
Copy Markdown
Author

What about simply hardcoding the version into an __LDC_VERSION__ enum that is generated by the compiler (similar to __VERSION__), instead of the whole build complexity of generating a special file, adding that file to the distribution, reading that file, parsing the contents, ......

Done

usefahmed07 added a commit to usefahmed07/ldc that referenced this pull request Aug 30, 2026
Fixes ldc-developers#1958 (companion to ldc-developers/phobos#76).

Per review feedback, adds __LDC_VERSION__ as a compiler-level magic
identifier (mirroring __VERSION__) instead of exposing the version
via a build-generated string-import file:

- dmd/id.d: register the __LDC_VERSION__ identifier
- dmd/lexer.d, dmd/globals.h: add CompileEnv.ldcVersionNumber and
  resolve __LDC_VERSION__ to it in the lexer
- CMakeLists.txt: derive LDC_VERSION_MAJOR/MINOR from LDC_VERSION
  and pass them as preprocessor definitions
- driver/main.cpp: set compileEnv.ldcVersionNumber at startup
- runtime/CMakeLists.txt: drop the earlier string-import approach
@JohanEngelen
JohanEngelen merged commit 4f3d5b3 into ldc-developers:ldc Aug 31, 2026
usefahmed07 added a commit to usefahmed07/ldc that referenced this pull request Aug 31, 2026
driver/main.cpp no longer calls sscanf, so the cstdio include is
unused (per @JohanEngelen review comment).

Update runtime/phobos submodule ref to 4f3d5b30f, which includes
the merged std.compiler change (ldc-developers/phobos#76) that this
PR depends on.
@usefahmed07
usefahmed07 deleted the fix/1958-ldc-version-in-std-compiler branch August 31, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set std.compiler version_major/minor to LDC version

2 participants