This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Changing the CHOST variable

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This page is a translated version of the page Changing the CHOST variable and the translation is 75% complete.
Outdated translations are marked like this.

이 문서는 시스템에 있는 CHOST 변수 값을 바꾸는 방법을 설명합니다.

도입부

CHOST 값을 바꾸는 일은 시스템 전체를 이상하게 꼬이게 할 수 있는 큰 문제입니다 - 그러니까 왜 그 대혼란을 야기할 문제가 안내서에 있냐고요?

CHOST 값을 어쩔 수 없이 바꿨을때 몇가지 상황이 발생하는데, 예컨대, nptl만 지원하는 glibc 2.4를 업그레이드 하려 하는데 CHOST 값을 nptl 사용이 불가능한 i386으로 설정한 경우를 찾을 때가 있습니다. 이 경우, 상당히 많은 옵션을 보유하지 않아, 이 옵션 중 CHOST 값을 바꿔야 합니다.

이 절차를 따르더라도 문제가 발생할 수 있으니, 매우 조심스럽게 읽고 실행에 옮겼는지 확인 하십시오. 이 경우 CHOST 값이 i386에서 i686 으로 바뀌며, 개인적인 상황에 따라 다른 값을 바꿨을 경우 그에 따라 명령도 바꿉니다.

CHOST 변수 값 바꾸기

Updating make.conf

To start out with the CHOST variable change, edit the /etc/portage/make.conf file and add/change the CHOST value to suit the requirements.

파일 /etc/portage/make.conf
CHOST="i686-pc-linux-gnu"

Please note that if you are planning to use another value of CHOST than the profile default, you may need to update the CHOST_${ABI} variable as well. You can query the current value of these variable via portageq tool:

user $portageq envvar ABI
x86
user $portageq envvar CHOST_x86
i686-pc-linux-gnu

If this value is equal to your CHOST, you're good. Otherwise, you should override it as well, e.g.:

파일 /etc/portage/make.conf
CHOST_x86="i686-pc-linux-gnu"

꾸러미 빌드

중요
It is generally a good idea to rebuild the packages to the same versions as before the CHOST switch, i.e. avoiding combining upgrades with it. If you have multiple slots installed, either uninstall extraneous slots or rebuild all of them. If you can't do that, please upgrade the packages first (with old CHOST). While it may not be impossible to do so, it is hard to predict which potential problems may arise and almost impossible to document them in this guide.
요령
On a system with CHOST set to an i386 value, mask glibc 2.4 (or newer) during the gcc upgrade as it cannot be used with i386. Unmask it once the change has been performed completely.

Rebuild the following packages in this order:

root #emerge --ask --oneshot sys-devel/binutils
참고
gcc를 컴파일하기 전에 binutils-config 를 실행해야 할지도 모릅니다.
root #emerge --ask --oneshot sys-devel/gcc
root #emerge --ask --oneshot sys-libs/glibc

동작 확인

이제 gcc-configbinutils-config 설정이 온전한지 확인하고 /etc/env.d/에서 나머지 요소를 날릴 때입니다.

gcc-configbinutils-config 출력은 다음과 같아야 합니다:

참고
gcc 버전과 CHOST 값에 따라 다를 수 있으며, 여기는 GCC 4.1.1과 i686에 해당합니다
root #gcc-config -l
 [1] i686-pc-linux-gnu-4.1.1 *
root #gcc-config -c
i686-pc-linux-gnu-4.1.1
root #binutils-config -l
 [1] i686-pc-linux-gnu-2.16.1 *
# binutils-config -c
i686-pc-linux-gnu-2.16.1

다음, 이전 CHOST 변수 값을 /etc/env.d/에서 참조하는지 확인하십시오:

root #cd /etc/env.d/
root #grep 386 *
05gcc-i386-pc-linux-gnu:PATH="/usr/i386-pc-linux-gnu/gcc-bin/4.1.1"
05gcc-i386-pc-linux-gnu:ROOTPATH="/usr/i386-pc-linux-gnu/gcc-bin/4.1.1"
참고
대부분의 경우 아무 일도 안일어납니다만 이 경우 05gcc-i386-pc-linux-gnu에 오래된 CHOST 값 참조가 들어있습니다. 어떤 CHOST 값으로 바꾸느냐에 따라 시스템이 달라볼 수 있거나 그 상태로 괜찮을 수 있습니다. 어떤 경우에는 남아있는 참조가 없을 수도 있습니다. 이름은 05gcc-your_new_CHOST-pc-linux-gnu여야 합니다.

파일을 지우기 전에 업데이트한 CHOST 값이 파일에 붙었는지 확인하도록 하겠습니다:

root #grep 686 *
05binutils:MANPATH=/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/man
05binutils:INFOPATH=/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/info
05binutils:LDPATH=/usr/i686-pc-linux-gnu/lib
05gcc:PATH="/usr/i686-pc-linux-gnu/gcc-bin/4.1.1"
05gcc:ROOTPATH="/usr/i686-pc-linux-gnu/gcc-bin/4.1.1"
05gcc:MANPATH="/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man"
05gcc:INFOPATH="/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info"
05gcc:LDPATH="/usr/lib/gcc/i686-pc-linux-gnu/4.1.1"

여기서는 /etc/env.d/의 (05gcc를 예로 들어)gcc에 대해서만 결과가 잘 나온것처럼 보이니, 잘못된 참조가 들어간 파일을 삭제하도록 하겠습니다:

root #rm 05gcc-i386-pc-linux-gnu

이 같은 설정은 binutils에도 적용합니다 - 추가 요소가 있을 경우 오래된 요소를 찾아 삭제하십시오. 다음 /etc/env.d/binutils/ 디렉터리를 확인하십시오:

root #cd /etc/env.d/binutils/
root #ls -la
total 8
-rw-r--r-- 1 root root  15 Sep  3 13:48 config-i686-pc-linux-gnu
-rw-r--r-- 1 root root 126 Sep  3 13:48 i686-pc-linux-gnu-2.16.1
root #cat config-i686-pc-linux-gnu
CURRENT=2.16.1
root #cat i686-pc-linux-gnu-2.16.1
TARGET="i686-pc-linux-gnu"
VER="2.16.1"
LIBPATH="/usr/lib/binutils/i686-pc-linux-gnu/2.16.1"
FAKE_TARGETS="i686-pc-linux-gnu"

보기 좋아보이는군요, 실제로 두 파일이 위치해 있습니다. 이제 gcc/ 디렉터리로 이동할 때입니다.

root #cd /etc/env.d/gcc
# ls -la
total 12
-rw-r--r-- 1 root root  32 Sep  3 16:43 config
-rw-r--r-- 1 root root  32 Aug  3 14:25 config-i386-pc-linux-gnu
-rw-r--r-- 1 root root 292 Sep  3 16:43 i686-pc-linux-gnu-4.1.1
root #cat config
CURRENT=i686-pc-linux-gnu-4.1.1
root #cat config-i386-pc-linux-gnu
CURRENT=i386-pc-linux-gnu-4.1.1
root #cat i686-pc-linux-gnu-4.1.1
PATH="/usr/i686-pc-linux-gnu/gcc-bin/4.1.1"
ROOTPATH="/usr/i686-pc-linux-gnu/gcc-bin/4.1.1"
LDPATH="/usr/lib/gcc/i686-pc-linux-gnu/4.1.1"
GCCBITS="32"
MANPATH="/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man"
INFOPATH="/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info"
STDCXX_INCDIR="g++-v4"

configi686-pc-linux-gnu-4.1.1은 괜찮지만 제거해야 할 config-i386-pc-linux-gnu가 남아있습니다.

참고
다시 말해 오래된 GCC 버전 참조가 들어있는 파일 이름은 i686으로 바꾸더라도 config-i686-pc-linux-gnu 처럼 다를 수 있습니다. 이름 뿐만 아니라 파일의 내용을 확인하는 것도 중요합니다.
root #rm config-i386-pc-linux-gnu

이제 환경을 업데이트하려면 다음 명령을 실행하십시오:

root #env-update && source /etc/profile

모든 문제를 고쳤는지 확인하십시오:

root #grep -r 386 /etc/env.d/

여전이 파일이 남아있다면, 계속 진행하기 전에 쭉 살펴보십시오.

값 바꾸기 끝내기

이제 sys-devel/libtool를 다시 이머지하고 /usr/share/gcc-data/$CHOST/<gcc-version>/에 있는 fix_libtool_files.sh를 실행해야 합니다. 올바른 gcc 버전을 사용중이며(현재 여기서는 4.1.1) 이전 아키텍처(i386)를 매개변수로 넘겼는지 확인하십시오. $CHOST 값을 새 CHOST 값으로 바꾸고 <gcc-version>를 현재 gcc 버전으로 바꾸십시오. 이 예제에서는 CHOST 값을 i686으로 설정했음을 가정합니다.

root #emerge --ask --oneshot libtool
root #/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/fix_libtool_files.sh 4.1.1 --oldarch i386-pc-linux-gnu

이제 모든 꾸러미를 다시 빌드할 수 있습니다:

root #emerge -e world

In theory, it should not be necessary to do so, but it cannot be 100% guaranteed that this is actually the case. Alternatively, you can manually rebuild all the known problematic packages:

  • multilib packages using CHOST prefixing or header wrapping,
  • Perl, Python and other tools that store configured compiler path.
root #emerge --ask --oneshot /usr/bin/i386-pc-linux-gnu-* /usr/include/i386-pc-linux-gnu /usr/lib/llvm/*/bin/i386-pc-linux-gnu-* dev-lang/perl dev-lang/python

Note that you may need to remove paths that do not apply to your system from the above invocation.

When encountering other packages that need recompiling, please let us know through the discussion page of this guide.

일반적인 문제

CHOST 값을 바꾼 후 GCC 3.3에서 4.1로 업그레이드 할 때(어쨌든 이렇게 하지 마십시오), 꽤 많은 사람이 sys-apps/groffmail-mta/courier같은 꾸러미가 깨져 다시 컴파일해야 한다고 보고했습니다:

코드 오류 메시지
error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

이 일은 업그레이드 도중에 CHOST 값이 CTARGET과 일치하지 않고, 컴파일러가 크로스컴파일하는걸로 간주하기 때문에 일어나는 일입니다. 결과적으로 LDPATH 값을 ld.so.conf에 넣지 않아 이 오류가 나타납니다.

GCC 업그레이드 후 다시 빌드해야 할 꾸러미의 정보는 GCC 업그레이드 안내서를 참고하십시오.

어떤 드문 경우에는 오래된 버전의 파이선도 깰 수 있습니다. /usr/lib/gcc-lib/i386-pc-linux-gnu/3.3.6(이전 CHOST 값에 따라 바꾸십시오)를 /etc/ld.so.conf 에 추가하고 ldconfig를 실행한 다음 emerge libstdc++-v3를 실행하면 문제를 해결할 수 있습니다. 그러나 보신 바와 같이 이 문제에 직면하는걸 제대로 막아야 합니다. CHOST 값과 GCC 버전을 동시에 바꾸지 마십시오.

피드백

That should be all, feedback (both if it worked, failed or other problems were encountered) is welcome, please use the discussion page or post to this forum thread. Much in this guide comes from vapier, thanks for your help!


This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Wernfried Haas, Mike Frysinger (vapier), Chris White
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.