ビルドされたLinuxソースコードのみを提供するツール

ビルドされたLinuxソースコードのみを提供するツール

Linuxは大きくて複雑なソフトウェアです。システムで実行されているカーネルがすべてのコードを使用するわけではありません。

.configカーネルを構築するために必要なソースコードを提供できるツールを探しています。 sにスキップしたすべての行ifdefやビルドに使用されていないソースファイル、またはフォルダ内のファイルまで削除したいと思いますdrivers

そのようなツールがありますか?

私がこれを見つける理由は、カーネルに実際にどのコードが組み込まれているのかよく分からないからです。手動で行うことができることに同意しますが、不要なifdefを使用しないと、コードをより明確に理解できるようです。

ベストアンサー1

Linuxカーネルの構成は、最終的にCコンパイラのプリプロセッサディレクティブを定義します。前処理されたソースの出力は、探しているものと似ている必要があります。ただし、コンパイラによって最適化されたデッドコードがあるかもしれません。

gccコンパイラは、stdoutの前処理された出力生成を使用および停止するように指示できます-E

  -E  Stop after the preprocessing stage; do not run the compiler
      proper.  The output is in the form of preprocessed source code,
      which is sent to the standard output.

カーネル全体の場合、コンパイラフラグを統合する方が簡単です--save-temps

   -save-temps
   -save-temps=cwd
       Store the usual "temporary" intermediate files permanently; place
       them in the current directory and name them based on the source
       file.  Thus, compiling foo.c with -c -save-temps would produce
       files foo.i and foo.s, as well as foo.o.  This creates a
       preprocessed foo.i output file even though the compiler now
       normally uses an integrated preprocessor.

       When used in combination with the -x command line option,
       -save-temps is sensible enough to avoid over writing an input
       source file with the same extension as an intermediate file.  The
       corresponding intermediate file may be obtained by renaming the
       source file before using -save-temps.

おすすめ記事