레이블이 make인 게시물을 표시합니다. 모든 게시물 표시
레이블이 make인 게시물을 표시합니다. 모든 게시물 표시

centos bash 4.4 설치

# centos 7.7 사용중인데 bash 최신 버전(4.4이상)을 설치하려고
# yum 으로 시도하면 4.2.46 만 설치된다.
sudo yum install bash

# 때문에 소스를 다운로드 받아 빌드 및 설치해본다.
wget https://ftp.gnu.org/gnu/bash/bash-4.4.tar.gz
tar zxvf bash-4.4.tar.gz
cd ./bash-4.4
./configure
make -j4
sudo make install

# 이제 로그아웃 후 다시 로그인해 버전 확인
bash --version
GNU bash, version 4.4.0(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

도커 컨테이너에서 make -j 옵션

# 6cores(12threads), 32GB RAM 맥북에서
# 도커 컨테이너를 띄우고 c++ make 속도를 높이기 위해
# make -j 4 -> make -j 8 로 같이 병렬 컴파일 잡 개수를 높였다.
# 그런데 다음과 같은 에러가 발생한다.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[1]: *** [util/utf8_string_bounder.o] Error 4
make[1]: *** Waiting for unfinished jobs....

# 위와 같은 에러는 빌드시 메모리 부족으로 스왑 파일을 사용하는데
# 스왑파일도 1GB 로 적어 컴파일을 끝낼 수 없어 발생한 에러다.
# 컨테이너의 메모리가 2GB 로 설정되어 있었다.
# 컨테이너에서 사용할 cpu, memory 를 늘려야 한다.(스왑파일도 늘리 수 있다.)
# 도커 setting -> resources -> advanced 에서 변경한다.


# 이제 컨테이너를 run 하고
docker run --name ysoftman_centos -dit ysoftman/centos

# 컨테이너에 접속해서
docker exec -u root -e COLUMNS=$(tput cols) -e LINES=$(tput lines) -it ysoftman_centos /bin/bash

# cpu, memroy 를 확인해 보면
# cpu 6, memory 8G 로 설정된것을 볼 수 있다.
cat /proc/cpuinfo  | \grep processor
processor : 0
processor : 1
processor : 2
processor : 3
processor : 4
processor : 5

free -h
              total        used        free      shared  buff/cache   available
Mem:           7.8G        326M        7.1G        868K        384M        7.2G
Swap:          1.0G          0B        1.0G

# 이제 make -j 8 을 수행하면 잘 된다.
time make -j8

# 컨테이너 리소스 증가에 따라 make 빌드 소요 시간도 줄지만
# 같은 리소스상태에서는 -j 값이 어느정도 부터는 시간이 더 이상 줄지 않는다.
# 2CPUs, 2GB mem, make -j 8 --> (2:12초)
# 6CPUs, 8GB mem, make -j 8 --> (1:42초)
# 10CPUs, 16GB mem, make -j 10 --> (1:39초)
# 10CPUs, 16GB mem, make -j 12 --> (1:39초)

# 참고
# make -j 옵션 사용시 값을 명시하지 않으면 무한대로 설정된다.
make --help | \grep  '\-j'
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.

# 무한대로 하면 모든 cpp 파일이 동시 컴파일 되고 더 많은 메모리를 필요로 해서
# 에러가 또 발생할 수 있어 memory 리소스에 따른 적절한 -j 수치를 정해야 한다.