「D言語/インストールおよび実行方法」の版間の差分

削除された内容 追加された内容
Ef3 (トーク | 投稿記録)
→‎gdcの場合: カレントディレクトリの実行ファイルを実行するので、ホームフォルダは無関係。
タグ: 2017年版ソースエディター
Ef3 (トーク | 投稿記録)
→‎ldc と dlang-tools: ldcは、LLVMをベースに開発されたD言語処理系です。 dlang-toolsは、DMDとともに再配布されるツールや、様々なビルドタスクで内部的に使用される様々なツールで、単体でもリリースされています。
タグ: 2017年版ソースエディター
57 行
 
のように表示されます。
 
=== ldc と dlang-tools ===
ldcは、LLVMをベースに開発されたD言語処理系です<ref>[https://github.com/ldc-developers/ldc The LLVM-based D Compiler.]</ref>。
dlang-toolsは、DMDとともに再配布されるツールや、様々なビルドタスクで内部的に使用される様々なツールで、単体でもリリースされています<ref>[https://github.com/dlang/tools Ancillary tools for the D programming language compiler]</ref>。
 
両方ともFreeBSDのPort Collectionに lang/ldc と lang/dlang-tools の名前でエントリーがあるので
;pkg:<syntaxhighlight lang=console>
# pkg install lang/ldc lang/dlang-tools
</syntaxhighlight>
;ports:<syntaxhighlight lang=console>
# make -C /usr/ports/lang/ldc all install clean
# make -C /usr/ports/lang/dlang-tools all install clean
</syntaxhighlight>
でインストールできます。
 
ldc のコマンド名は ldc2 です。バージョンを確認確認してみます(サポートターゲットの数が多すぎるので head で割愛しました)。
;バージョン確認:<syntaxhighlight lang=console>
% ldc2 --version | head
LDC - the LLVM D compiler (1.23.0):
based on DMD v2.093.1 and LLVM 10.0.1
built with LDC - the LLVM D compiler (0.17.6)
Default target: x86_64-portbld-freebsd13.0
Host CPU: cascadelake
http://dlang.org - http://wiki.dlang.org/LDC
 
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
</syntaxhighlight>
<!--9日前にLDC 1.30.0がリリースされたので対応必要か?2022-07-30-->
dlang-toolsには、rdmdなどが含まれているので
;バージョン確認:<syntaxhighlight lang=console>
% rdmd -v | head
rdmd build 20220408
Usage: rdmd [RDMD AND DMD OPTIONS]... program [PROGRAM OPTIONS]...
Builds (with dependents) and runs a D program.
Example: rdmd -release myprog --myprogparm 5
 
Any option to be passed to the compiler must occur before the program name. In
addition to compiler options, rdmd recognizes the following options:
--build-only just build the executable, don't run it
--chatty write compiler commands to stdout before executing them
--compiler=comp use the specified compiler (e.g. gdmd) instead of ldmd2
% cat hello.d
import std.stdio;
 
void main(){
writeln("Hello world!");
}
$ rdmd hello
Hello world!
</syntaxhighlight>
この様に、DMDを使っているのと変わらないコンパイル環境が用意できます。
 
== 実行の仕方 ==