Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 233f86c

Browse files
committed
ci: generate pages at 1d654ca [ci skip]
1 parent 1d654ca commit 233f86c

14 files changed

+372
-104
lines changed

docs/atcoder-env/compiling-and-running-program.html

Lines changed: 91 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
8080
<div class="sidebar-scrollbox">
81-
<ol class="chapter"><li><a href="../introduction.html"><strong aria-hidden="true">1.</strong> はじめに (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">2.</strong> AtCoderの環境について (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">2.1.</strong> ソフトウェアのバージョンなど (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">2.2.</strong> 単一のソースファイル (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">2.3.</strong> 利用可能なクレート (TODO)</a></li></ol></li><li><a href="../todo.html"><strong aria-hidden="true">3.</strong> 開発環境の準備 (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">3.1.</strong> Rustツールチェインのインストール (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">3.2.</strong> ソースコードエディタとデバッガの準備 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">3.3.</strong> cargo-generateテンプレート (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">3.3.1.</strong> cargo-generateのインストール (TODO)</a></li></ol></li></ol></li><li><a href="../todo.html"><strong aria-hidden="true">4.</strong> コンテストの参加方法 (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">4.1.</strong> Cargoパッケージの作成 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.2.</strong> 利用するクレートの選択 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.3.</strong> テストケースの作成 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.4.</strong> プログラムの作成 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.5.</strong> プログラムのテスト (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.6.</strong> プログラムの提出 (TODO)</a></li></ol></li><li><a href="../todo.html"><strong aria-hidden="true">5.</strong> Tips(小技集) (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">5.1.</strong> クレートの利用例 (TODO)</a></li></ol></li><li><a href="../atcoder-env/index.html"><strong aria-hidden="true">6.</strong> AtCoder運営者向けの情報</a></li><li><ol class="section"><li><a href="../atcoder-env/supported-environment.html"><strong aria-hidden="true">6.1.</strong> 本章で想定している環境と利用形態 (TODO)</a></li><li><a href="../atcoder-env/installation.html"><strong aria-hidden="true">6.2.</strong> インストール</a></li><li><ol class="section"><li><a href="../atcoder-env/installing-rust-toolchain.html"><strong aria-hidden="true">6.2.1.</strong> Rustツールチェインのインストール</a></li><li><a href="../atcoder-env/installing-rust-crates.html"><strong aria-hidden="true">6.2.2.</strong> クレートのコンパイルとインストール</a></li><li><a href="../atcoder-env/installing-rustc-dep-option-generator.html"><strong aria-hidden="true">6.2.3.</strong> クレート検索パス生成ツールのインストール</a></li></ol></li><li><a href="../atcoder-env/compiling-and-running-program.html" class="active"><strong aria-hidden="true">6.3.</strong> コンパイルコマンドと実行コマンド</a></li></ol></li><li><a href="../contributors.html"><strong aria-hidden="true">7.</strong> コントリビュータ (TODO)</a></li></ol>
81+
<ol class="chapter"><li><a href="../introduction.html"><strong aria-hidden="true">1.</strong> はじめに (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">2.</strong> AtCoderの環境について (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">2.1.</strong> ソフトウェアのバージョンなど (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">2.2.</strong> 単一のソースファイル (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">2.3.</strong> 利用可能なクレート (TODO)</a></li></ol></li><li><a href="../todo.html"><strong aria-hidden="true">3.</strong> 開発環境の準備 (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">3.1.</strong> Rustツールチェインのインストール (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">3.2.</strong> ソースコードエディタとデバッガの準備 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">3.3.</strong> cargo-generateテンプレート (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">3.3.1.</strong> cargo-generateのインストール (TODO)</a></li></ol></li></ol></li><li><a href="../todo.html"><strong aria-hidden="true">4.</strong> コンテストの参加方法 (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">4.1.</strong> Cargoパッケージの作成 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.2.</strong> 利用するクレートの選択 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.3.</strong> テストケースの作成 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.4.</strong> プログラムの作成 (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.5.</strong> プログラムのテスト (TODO)</a></li><li><a href="../todo.html"><strong aria-hidden="true">4.6.</strong> プログラムの提出 (TODO)</a></li></ol></li><li><a href="../todo.html"><strong aria-hidden="true">5.</strong> Tips(小技集) (TODO)</a></li><li><ol class="section"><li><a href="../todo.html"><strong aria-hidden="true">5.1.</strong> クレートの使用例 (TODO)</a></li></ol></li><li><a href="../atcoder-env/index.html"><strong aria-hidden="true">6.</strong> AtCoder運営者向けの情報</a></li><li><ol class="section"><li><a href="../atcoder-env/supported-environment.html"><strong aria-hidden="true">6.1.</strong> 本章で想定している環境</a></li><li><a href="../atcoder-env/installation.html"><strong aria-hidden="true">6.2.</strong> インストール</a></li><li><ol class="section"><li><a href="../atcoder-env/installing-rust-toolchain.html"><strong aria-hidden="true">6.2.1.</strong> Rustツールチェインのインストール</a></li><li><a href="../atcoder-env/installing-rust-crates.html"><strong aria-hidden="true">6.2.2.</strong> クレートのコンパイルとインストール</a></li><li><a href="../atcoder-env/installing-rustc-dep-option-generator.html"><strong aria-hidden="true">6.2.3.</strong> クレート検索パス生成ツールのインストール</a></li></ol></li><li><a href="../atcoder-env/compiling-and-running-program.html" class="active"><strong aria-hidden="true">6.3.</strong> コンパイルコマンドと実行コマンド</a></li></ol></li><li><a href="../contributors.html"><strong aria-hidden="true">7.</strong> コントリビュータ (TODO)</a></li></ol>
8282
</div>
8383
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
8484
</nav>
@@ -157,15 +157,15 @@ <h2><a class="header" href="#ファイルレイアウトとコンパイルの流
157157
└-- main.rs # ユーザプログラム(提出されたプログラム)のソースコード
158158
</code></pre>
159159
<p><code>WORKAREA</code><code>cd</code>で移動して、後述のコンパイルコマンドを実行します。
160-
すると以下のことが行われ<code>main</code>という名の実行可能ファイル(バイナリ)が生成されます</p>
160+
すると以下のことが行われ<code>main</code>という名の実行ファイルが生成されます</p>
161161
<ol>
162162
<li>プログラムがアセンブリコードに変換されオブジェクトファイルが作られる</li>
163163
<li>オブジェクトファイルがRustの標準ライブラリや<code>${RUST_MOME}/lib/target/release/deps</code>配下に作成しておいた<code>rlib</code>とリンクされる</li>
164164
</ol>
165165
<pre><code class="language-console">$HOME
166166
└-- WORKAREA
167167
|-- main.rs
168-
└-- main # コンパイルとリンクの成果物。実行可能ファイル(バイナリ)
168+
└-- main # コンパイルとリンクの成果物。実行ファイル
169169
</code></pre>
170170
<h2><a class="header" href="#コンパイルコマンド" id="コンパイルコマンド">コンパイルコマンド</a></h2>
171171
<p>ツールチェインのインストールのページで説明したように、コンパイルを実行するシェルに以下の環境変数が設定されている必要があります。</p>
@@ -182,20 +182,100 @@ <h2><a class="header" href="#コンパイルコマンド" id="コンパイルコ
182182
... /usr/local/lib/rust/cargo/bin; ...
183183
</code></pre>
184184
<p>コンパイルコマンドは以下のとおりです。</p>
185-
<pre><code class="language-console">$ cd ${HOME}/WORKAREA
186-
$ RUST_LIB=${RUST_HOME}/lib
185+
<pre><code class="language-console">$ cd $HOME/WORKAREA
186+
$ RUST_LIB=$RUST_HOME/lib
187187
$ rustc --edition=2018 -C opt-level=3 \
188-
$(rustc-dep-option-generator ${RUST_LIB}/Cargo.toml ${RUST_LIB}/target/release/deps) \
188+
$(rustc-dep-option-generator $RUST_LIB/Cargo.toml $RUST_LIB/target/release/deps) \
189189
main.rs
190190
</code></pre>
191-
<p>これにより<code>${HOME}/WORKAREA</code>ディレクトリに<code>main</code>という名のバイナリが生成されます</p>
191+
<p>これにより<code>$HOME/WORKAREA</code>ディレクトリに<code>main</code>という名の実行ファイルが生成されます</p>
192192
<h3><a class="header" href="#コンパイルオプションについて" id="コンパイルオプションについて">コンパイルオプションについて</a></h3>
193-
<p><strong>TODO</strong></p>
193+
<p><code>rustc</code>コマンドに渡すコンパイルオプションは、<code>cargo</code>でデフォルトのreleaseプロファイルを使用した時に、<code>cargo build --release</code>で生成される、ごく一般的なものを使用します。
194+
たとえばバイナリの実行速度を最適化するためのオプションとしては<code>-C opt-level=3</code>だけを指定しています。</p>
195+
<p>もし実行速度を追求するなら<code>-C target-cpu=native</code>のようなオプションを追加することもできます。
196+
しかしAtCoder運営者様から以下のようなお話があったため、今回の言語アップデートでは使用しないことにします。</p>
197+
<p><a href="https://twitter.com/chokudai/status/1138677406984691712">https://twitter.com/chokudai/status/1138677406984691712</a></p>
198+
<blockquote>
199+
<p>もうすぐジャッジアップデートの話を出すけれども、ジャッジの目的は「正解と不正解を分けること」であって、「最速を目指すこと」ではないので、十分に早い言語(C++, Rustなど)では、過剰な最適化とかを含めた提案はRejectすることがあるかも。</p>
200+
</blockquote>
201+
<p><a href="https://twitter.com/chokudai/status/1138677959059943424">https://twitter.com/chokudai/status/1138677959059943424</a></p>
202+
<blockquote>
203+
<p>といいつつ、言語間の差を減らすために「C++はO2とか付けない!」みたいな滅茶苦茶なことを言い出すつもりは全くなくて、「AtCoder環境がちょっと変わると動かなくなる」みたいな最適化は受け入れない、くらいの話です。</p>
204+
</blockquote>
205+
<p>通常形式のコンテスト(アルゴリズム系)では最速を目指すことには意味がありません。</p>
206+
<p>一方、マラソン系のコンテストでは、たとえ数パーセントでも速度が向上するなら嬉しいことも多くあります。
207+
AtCoderでは将来マラソン系のコンテストもRatedにする可能性があり、その際にコンパイルオプションを追加するか検討できるかもしれません(<a href="https://twitter.com/tatsuya6502/status/1140049804082311168">参考</a></p>
208+
<h3><a class="header" href="#コンパイルコマンドが動作することの確認" id="コンパイルコマンドが動作することの確認">コンパイルコマンドが動作することの確認</a></h3>
209+
<p>コンパイルコマンドが動作することを確認しましょう。
210+
クレートのインストールに使用したCargoプロジェクトには、それらのクレートを使用する簡単なサンプルコードが含まれています。</p>
211+
<p>以下の方法でコンパイルできます。</p>
212+
<pre><code class="language-console">## 一般ユーザで実行
213+
214+
## 作業用のディレクトリを作成する
215+
216+
$ mkdir $HOME/WORKAREA
217+
$ cd $HOME/WORKAREA
218+
219+
## サンプルコードの入ったソースファイル(2つある)をコピーする
220+
221+
$ RUST_LIB=$RUST_HOME/lib
222+
223+
$ cp -p $RUST_LIB/src/main.rs .
224+
$ cp -p $RUST_LIB/tests/test_jemallocator.rs .
225+
226+
## サンプルコードをコンパイル、リンクする
227+
228+
$ rustc --edition=2018 -C opt-level=3 \
229+
$(rustc-dep-option-generator $RUST_LIB/Cargo.toml $RUST_LIB/target/release/deps) \
230+
main.rs
231+
232+
$ rustc --edition=2018 -C opt-level=3 \
233+
$(rustc-dep-option-generator $RUST_LIB/Cargo.toml $RUST_LIB/target/release/deps) \
234+
test_jemallocator.rs
235+
</code></pre>
236+
<p>コンパイルとリンクに成功すると実行ファイルが作られます。</p>
237+
<pre><code class="language-console">$ file main
238+
main: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
239+
dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0,
240+
BuildID[sha1]=50373af3038c60f2a3e7a162b310e5226b08c8a9,
241+
with debug_info, not stripped
242+
243+
$ file test_jemallocator
244+
test_jemallocator: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
245+
dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0,
246+
BuildID[sha1]=31b718908ebf067f4b1161b1dc5cf679f012ad7f,
247+
with debug_info, not stripped
248+
</code></pre>
194249
<h2><a class="header" href="#実行コマンド" id="実行コマンド">実行コマンド</a></h2>
195-
<p>バイナリを実行するコマンドは以下のとおりです。</p>
196-
<pre><code class="language-console">$ cd ${HOME}/WORKAREA
197-
$ ./main &lt; 入力データファイル
250+
<p>実行ファイルを実行するコマンドは以下のとおりです。</p>
251+
<pre><code class="language-console">$ cd $HOME/WORKAREA
252+
$ ./main
253+
</code></pre>
254+
<h3><a class="header" href="#実行コマンドが動作することの確認" id="実行コマンドが動作することの確認">実行コマンドが動作することの確認</a></h3>
255+
<p>実行コマンドが動作することを確認しましょう。
256+
先ほど作成した実行ファイルを実行します。</p>
257+
<pre><code class="language-console">## 一般ユーザで実行
258+
259+
$ cd $HOME/WORKAREA
260+
261+
$ ./main
262+
...
263+
264+
## いろいろなメッセージが表示されるが、テスト用の出力なので内容は確認しなくてよい
265+
## 終了コード0で終了したことだけを確認すればOK
266+
267+
$ echo $?
268+
0
269+
270+
$ ./test_jemallocator
271+
...
272+
273+
## こちらも終了コード0で終了したことだけを確認すればOK
274+
$ $?
275+
0
198276
</code></pre>
277+
<p>AtCoder運営者向けの情報は以上となります。
278+
内容について質問などがありましたら、<a href="https://github.com/rust-lang-ja/atcoder-rust-resources/issues">GitHub Issue</a>などでご連絡ください。</p>
199279

200280
</main>
201281

0 commit comments

Comments
 (0)