develop/toolchains/other_x_compilers.html · develop/toolchains/other_x_compilers.rst 공식 원문 ↗

Zephyr 3.7.0 · Develop · Toolchains · 기타 Cross Compiler

기타 Cross Compiler

Directory·target triplet·마지막 dash를 합친 prefix로 GNU cross toolchain 전체를 지정합니다.

Official pathdevelop/toolchains/other_x_compilers.html
Source filedevelop/toolchains/other_x_compilers.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Linux kernel식 CROSS_COMPILE mechanism, 배포판 package 설치, cross-compile variant, binary 공통 prefix 규칙과 지원 범위를 설명합니다.

Variant

cross-compile

Prefix

CROSS_COMPILE

Scope

mechanism supported

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 FB7106680C8468DBD7CA5D8CB983834B573C48CB2E92E208C5778F251EDB1A0F
.. _other_x_compilers:

Other Cross Compilers
######################

This toolchain variant is borrowed from the Linux kernel build system's
mechanism of using a ``CROSS_COMPILE`` environment variable to set up a
GNU-based cross toolchain.

Examples of such "other cross compilers" are cross toolchains that your Linux
distribution packaged, that you compiled on your own, or that you downloaded
from the net. Unlike toolchains specifically listed in
:ref:`toolchains`, the Zephyr build system may not have been
tested with them, and doesn't officially support them. (Nonetheless, the
toolchain set-up mechanism itself is supported.)

Follow these steps to use one of these toolchains.

#. Install a cross compiler suitable for your host and target systems.

   For example, you might install the ``gcc-arm-none-eabi`` package on
   Debian-based Linux systems, or ``arm-none-eabi-newlib`` on Fedora or Red
   Hat:

   .. code-block:: console

      # On Debian or Ubuntu
      sudo apt-get install gcc-arm-none-eabi
      # On Fedora or Red Hat
      sudo dnf install arm-none-eabi-newlib

#. :ref:`Set these environment variables <env_vars>`:

   - Set :envvar:`ZEPHYR_TOOLCHAIN_VARIANT` to ``cross-compile``.
   - Set ``CROSS_COMPILE`` to the common path prefix which your
     toolchain's binaries have, e.g. the path to the directory containing the
     compiler binaries plus the target triplet and trailing dash.

#. To check that you have set these variables correctly in your current
   environment, follow these example shell sessions (the
   ``CROSS_COMPILE`` value may be different on your system):

   .. code-block:: console

      # Linux, macOS:
      $ echo $ZEPHYR_TOOLCHAIN_VARIANT
      cross-compile
      $ echo $CROSS_COMPILE
      /usr/bin/arm-none-eabi-

   You can also set ``CROSS_COMPILE`` as a CMake variable.

When using this option, all of your toolchain binaries must reside in the same
directory and have a common file name prefix.  The ``CROSS_COMPILE`` variable
is set to the directory concatenated with the file name prefix. In the Debian
example above, the ``gcc-arm-none-eabi`` package installs binaries such as
``arm-none-eabi-gcc`` and ``arm-none-eabi-ld`` in directory ``/usr/bin/``, so
the common prefix is ``/usr/bin/arm-none-eabi-`` (including the trailing dash,
``-``).  If your toolchain is installed in ``/opt/mytoolchain/bin`` with binary
names based on target triplet ``myarch-none-elf``, ``CROSS_COMPILE`` would be
set to ``/opt/mytoolchain/bin/myarch-none-elf-``.

Part 3

한국어 전문 번역

기타 GNU cross compiler

이 toolchain variant는 Linux kernel build system이 CROSS_COMPILE 환경 변수로 GNU 기반 cross toolchain을 지정하는 방식을 가져온 것입니다.

Linux distribution package, 직접 compile한 toolchain 또는 internet에서 받은 toolchain이 여기에 해당합니다. Toolchain 목차에 따로 열거된 toolchain과 달리 Zephyr build system에서 시험되지 않았을 수 있으며 공식 지원 대상도 아닙니다. 다만 이 toolchain 설정 mechanism 자체는 지원됩니다.

설정 절차

  1. Host와 target system에 맞는 cross compiler를 설치합니다.
  2. 환경 변수 설정 안내에 따라 ZEPHYR_TOOLCHAIN_VARIANT=cross-compile로 설정하고, CROSS_COMPILE을 compiler binary directory와 target triplet, 마지막 dash를 합친 공통 prefix로 지정합니다.
  3. 현재 shell에서 두 변수를 출력해 값이 예상한 compiler prefix와 일치하는지 확인합니다.

Debian·Ubuntu에서는 gcc-arm-none-eabi, Fedora·Red Hat에서는 arm-none-eabi-newlib package를 설치하는 예:

# On Debian or Ubuntu
sudo apt-get install gcc-arm-none-eabi
# On Fedora or Red Hat
sudo dnf install arm-none-eabi-newlib

환경 변수를 확인하는 예:

# Linux, macOS:
$ echo $ZEPHYR_TOOLCHAIN_VARIANT
cross-compile
$ echo $CROSS_COMPILE
/usr/bin/arm-none-eabi-

CROSS_COMPILE은 환경 변수뿐 아니라 CMake 변수로도 설정할 수 있습니다.

Prefix가 의미하는 것

이 방식을 사용할 때 모든 toolchain binary는 같은 directory에 있고 file name prefix를 공유해야 합니다. CROSS_COMPILE 값은 directory와 공통 prefix를 이어 붙인 문자열이며 마지막 -도 포함합니다.

  • Debian의 gcc-arm-none-eabi package가 /usr/bin/에 arm-none-eabi-gcc, arm-none-eabi-ld 등을 설치하면 prefix는 /usr/bin/arm-none-eabi-입니다.
  • /opt/mytoolchain/bin에 설치했고 target triplet이 myarch-none-elf라면 CROSS_COMPILE=/opt/mytoolchain/bin/myarch-none-elf-입니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.