LDC command arguments vs DMD argument

Derek Fawcus dfawcus+dlang at employees.org
Wed Mar 19 17:02:02 UTC 2025


Is LDC expected to work the same way with respect to command line 
arguments as DMD?

I note it offers the same set, but there are some subtle 
differences.

```text
$ ldc2 --version
LDC - the LLVM D compiler (1.28.0):
   based on DMD v2.098.0 and LLVM 11.1.0
   built with LDC - the LLVM D compiler (1.28.0)
   Default target: x86_64-pc-linux-gnu
```
```text
$ dmd --version
DMD64 D Compiler v2.109.1
```

```text
$ rm -f libs/* utf8.a
$ dmd -preview=dip1000 -preview=dip1021 -preview=in -I=. -lib 
-od=libs -of=utf8.a utf8*.d
$ ls libs
utf8.a
$ ls utf8.a
ls: cannot access 'utf8.a': No such file or directory
```

```text
$ ldc2 -preview=dip1000 -preview=dip1021 -preview=in -I=. -lib 
-od=libs -of=utf8.a utf8/*.d
$ ls libs
package.o
$ ls utf8.a
utf8.a
```

If I change the -of option for LDC to '-of=libs/utf8.a' then it 
places the library archive in the libs subdir, along with the 
objects. Note also that the 'package.o' object from each such 
library will overwrite each other if used in that form for LDC.

However if the same option is used for DMD then the library 
archive ends up in libs/libs/utf8.a.

I can make libs/libs a symlink to get the library archives in the 
same place for both compilers, however that still does not 
address the name collision and overwrite for the object files 
created by LDC.



More information about the Digitalmars-d mailing list