@@ -14,8 +14,8 @@ Rustにおけるリンクの一般的なケースについては本書の前の
14
14
<!-- the `link_args` attribute. This attribute is applied to `extern` blocks and -->
15
15
<!-- specifies raw flags which need to get passed to the linker when producing an -->
16
16
<!-- artifact. An example usage would be: -->
17
- どのようにリンクをカスタマイズするかを` rustc ` に指示するために、1つの方法があります。それは、` link_args ` アトリビュートを使うことです。
18
- このアトリビュートは` extern ` ブロックに適用され、生成物を作るときにリンカに渡したいフラグをそのまま指定します。
17
+ どのようにリンクをカスタマイズするかを ` rustc ` に指示するために、1つの方法があります。それは、 ` link_args ` アトリビュートを使うことです。
18
+ このアトリビュートは ` extern ` ブロックに適用され、生成物を作るときにリンカに渡したいフラグをそのまま指定します。
19
19
使い方の例は次のようになります。
20
20
21
21
``` no_run
@@ -34,14 +34,14 @@ extern {}
34
34
<!-- LLVM directly to link native libraries, in which case `link_args` will have no -->
35
35
<!-- meaning. You can achieve the same effect as the `link_args` attribute with the -->
36
36
<!-- `-C link-args` argument to `rustc`. -->
37
- これはリンクを実行するための認められた方法ではないため、この機能は現在` feature(link_args) ` ゲートによって隠されているということに注意しましょう。
38
- 今は` rustc ` がシステムリンカ(多くのシステムでは` gcc ` 、MSVCでは` link.exe ` )に渡すので、追加のコマンドライン引数を提供することには意味がありますが、それが今後もそうだとは限りません。
39
- 将来、` rustc ` がネイティブライブラリをリンクするためにLLVMを直接使うようになるかもしれませんし、そのような場合には` link_args ` は意味がなくなるでしょう。
40
- ` rustc ` に ` -C link-args ` 引数をつけることで、` link_args ` アトリビュートと同じような効果を得ることができます。
37
+ これはリンクを実行するための認められた方法ではないため、この機能は現在 ` feature(link_args) ` ゲートによって隠されているということに注意しましょう。
38
+ 今は ` rustc ` がシステムリンカ(多くのシステムでは ` gcc ` 、MSVCでは ` link.exe ` )に渡すので、追加のコマンドライン引数を提供することには意味がありますが、それが今後もそうだとは限りません。
39
+ 将来、 ` rustc ` がネイティブライブラリをリンクするためにLLVMを直接使うようになるかもしれませんし、そのような場合には ` link_args ` は意味がなくなるでしょう。
40
+ ` rustc ` に ` -C link-args ` 引数をつけることで、 ` link_args ` アトリビュートと同じような効果を得ることができます。
41
41
42
42
<!-- It is highly recommended to *not* use this attribute, and rather use the more -->
43
43
<!-- formal `#[link(...)]` attribute on `extern` blocks instead. -->
44
- このアトリビュートは使わ * ない* ことが強く推奨されているので、代わりにもっと正式な` #[link(...)] ` アトリビュートを` extern ` ブロックに使いましょう。
44
+ このアトリビュートは使わ * ない* ことが強く推奨されているので、代わりにもっと正式な ` #[link(...)] ` アトリビュートを ` extern ` ブロックに使いましょう。
45
45
46
46
<!-- # Static linking -->
47
47
# スタティックリンク
@@ -55,7 +55,7 @@ extern {}
55
55
<!-- change this and statically link them as well. -->
56
56
スタティックリンクとは全ての必要なライブラリを含めた成果物を生成する手順のことで、そうすればコンパイルされたプロジェクトを使いたいシステム全てにライブラリをインストールする必要がなくなります。
57
57
Rustのみで構築された依存関係はデフォルトでスタティックリンクされます。そのため、Rustをインストールしなくても、作成されたバイナリやライブラリを使うことができます。
58
- 対照的に、ネイティブライブラリ(例えば` libc ` や ` libm ` )はダイナミックリンクされるのが普通です。しかし、これを変更してそれらを同様にスタティックリンクすることも可能です。
58
+ 対照的に、ネイティブライブラリ(例えば ` libc ` や ` libm ` )はダイナミックリンクされるのが普通です。しかし、これを変更してそれらを同様にスタティックリンクすることも可能です。
59
59
60
60
<!-- Linking is a very platform-dependent topic, and static linking may not even be -->
61
61
<!-- possible on some platforms! This section assumes some basic familiarity with -->
@@ -69,8 +69,8 @@ Rustのみで構築された依存関係はデフォルトでスタティック
69
69
<!-- By default, all Rust programs on Linux will link to the system `libc` along with -->
70
70
<!-- a number of other libraries. Let's look at an example on a 64-bit Linux machine -->
71
71
<!-- with GCC and `glibc` (by far the most common `libc` on Linux): -->
72
- デフォルトでは、Linux上の全てのRustのプログラムはシステムの` libc ` とその他のいくつものライブラリとリンクされます。
73
- GCCと` glibc ` (Linuxにおける最も一般的な` libc ` )を使った64ビットLinuxマシンでの例を見てみましょう。
72
+ デフォルトでは、Linux上の全てのRustのプログラムはシステムの ` libc ` とその他のいくつものライブラリとリンクされます。
73
+ GCCと ` glibc ` (Linuxにおける最も一般的な ` libc ` )を使った64ビットLinuxマシンでの例を見てみましょう。
74
74
75
75
``` text
76
76
$ cat example.rs
@@ -95,8 +95,8 @@ $ ldd example
95
95
<!-- Static linking is supported via an alternative `libc`, [`musl`](http://www.musl-libc.org). You can compile -->
96
96
<!-- your own version of Rust with `musl` enabled and install it into a custom -->
97
97
<!-- directory with the instructions below: -->
98
- スタティックリンクは代わりの` libc ` である[ ` musl ` ] ( http://www.musl-libc.org/ ) によってサポートされています。
99
- 以下の手順に従い、` musl ` を有効にした独自バージョンのRustをコンパイルして独自のディレクトリにインストールすることができます。
98
+ スタティックリンクは代わりの ` libc ` である [ ` musl ` ] ( http://www.musl-libc.org/ ) によってサポートされています。
99
+ 以下の手順に従い、 ` musl ` を有効にした独自バージョンのRustをコンパイルして独自のディレクトリにインストールすることができます。
100
100
101
101
``` text
102
102
$ mkdir musldist
@@ -142,7 +142,7 @@ $ du -h musldist/bin/rustc
142
142
<!-- You now have a build of a `musl`-enabled Rust! Because we've installed it to a -->
143
143
<!-- custom prefix we need to make sure our system can find the binaries and appropriate -->
144
144
<!-- libraries when we try and run it: -->
145
- これで` musl ` が有効になったRustのビルドが手に入りました!
145
+ これで ` musl ` が有効になったRustのビルドが手に入りました!
146
146
独自のプレフィックスを付けてインストールしたので、試しに実行するときにはシステムがバイナリと適切なライブラリを見付けられることを確かめなければなりません。
147
147
148
148
``` text
@@ -171,5 +171,5 @@ thread '<main>' panicked at 'failed', example.rs:1
171
171
<!-- `cargo build` also permits the `--target` option so you should be able to build -->
172
172
<!-- your crates as normal. However, you may need to recompile your native libraries -->
173
173
<!-- against `musl` before they can be linked against. -->
174
- ` cargo build ` も ` --target ` オプションを受け付けるので、あなたのクレートも普通にビルドできるはずです。
175
- ただし、リンクする前にネイティブライブラリを` musl ` 向けにリコンパイルする必要はあるかもしれません。
174
+ ` cargo build ` も ` --target ` オプションを受け付けるので、あなたのクレートも普通にビルドできるはずです。
175
+ ただし、リンクする前にネイティブライブラリを ` musl ` 向けにリコンパイルする必要はあるかもしれません。
0 commit comments