QEMU용 라우터 커널을 컴파일하는 데 문제가 있습니다. OpenWRT 커널을 사용하여 QEMU에서 라우터를 작동시켰지만 네트워크가 작동하지 않습니다. 그래서 원본 커널을 컴파일하고 있습니다.
다음 명령은 (주) Makefile에 의해 간접적으로 실행되는 잘못된 명령입니다. 간접적으로 말하는 것은 구성 스크립트를 명시적으로 실행하도록 선택하지도 않고 단지 커널을 컴파일하는 데 필요한 다운로드된 패키지의 디렉터리에 있기 때문에 그렇게 하기로 선택한 것뿐입니다.
경로=/home/debian/build-new/host/bin:/home/debian/build-new/host/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/ 게임:/usr/games AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/ 홈/debian/build-new/host/usr/bin/ccache /usr/bin/gcc" GCC="/home/debian/build-new/host/usr/bin/ccache /usr/bin/gcc" CXX= "/home/debian/build-new/host/usr/bin/ccache /usr/bin/g++" CPP="/usr/bin/cpp" CPPFLAGS="-I/home/debian/build-new/host/ usr/include" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" CXXFLAGS="-O2 -I/home/debian/build-new/host/usr/include" LDFLAGS= "-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/usr/lib -Wl,-rpath,/home/debian/build-new/host/usr/ lib" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/debian/build-new/host/usr/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/debian/build-new/host/usr /lib/pkgconfig:/home/debian/build-new/host/usr/share/pkgconfig" PERLLIB="/home/debian/build-new/host/usr/lib/perl" LD_LIBRARY_PATH="/home/debian/ build-new/host/usr/lib:" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" LDFLAGS="-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/usr/lib -Wl,-rpath,/home/debian/build-new/host/usr/lib" CC="/usr/bin/gcc" ./configure --prefix="/home/debian/build-new/host/usr" --sysconfdir="/home/debian/build-new/host/etc" --enable-shared --disable-static --disable- gtk-doc --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no ccache_cv_zlib_1_2_3=no
인터럽트 명령 플래그는 LDFLAGS입니다.
LD="/usr/bin/ld" LDFLAGS="-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/usr/lib -Wl,-rpath,/ home/debian/build-new/host/usr/lib" LDFLAGS="-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/usr/lib -Wl, -rpath,/home/debian/build-new/host/usr/lib"
명령 실행 결과는 다음과 같습니다.
debian@debian-i686:~/build-new/build/host-ccache-3.1.8$ PATH=/home/debian/build-new/host/bin:/home/debian/build-new/host/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/home/debian/build-new/host/usr/bin/ccache /usr/bin/gcc" GCC="/home/debian/build-new/host/usr/bin/ccache /usr/bin/gcc" CXX="/home/debian/build-new/host/usr/bin/ccache /usr/bin/g++" CPP="/usr/bin/cpp" CPPFLAGS="-I/home/debian/build-new/host/usr/include" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" CXXFLAGS="-O2 -I/home/debian/build-new/host/usr/include" LDFLAGS="-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/usr/lib -Wl,-rpath,/home/debian/build-new/host/usr/lib" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/debian/build-new/host/usr/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/debian/build-new/host/usr/lib/pkgconfig:/home/debian/build-new/host/usr/share/pkgconfig" PERLLIB="/home/debian/build-new/host/usr/lib/perl" LD_LIBRARY_PATH="/home/debian/build-new/host/usr/lib:" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" LDFLAGS="-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/usr/lib -Wl,-rpath,/home/debian/build-new/host/usr/lib" CC="/usr/bin/gcc" ./configure --prefix="/home/debian/build-new/host/usr" --sysconfdir="/home/debian/build-new/host/etc" --enable-shared --disable-static --disable-gtk-doc --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no ccache_cv_zlib_1_2_3=no
configure: WARNING: unrecognized options: --enable-shared, --disable-static, --disable-gtk-doc, --disable-doc, --disable-docs, --disable-documentation, --with-xmlto, --with-fop
configure: Configuring ccache
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... no
configure: error: in `/home/debian/build-new/build/host-ccache-3.1.8':
configure: error: C compiler cannot create executables
See `config.log' for more details
LDFLAGS를 제거하면 특정 오류가 해결되었지만 나중에 다른 오류가 발생했습니다.
debian@debian-i686:~/build-new/build/host-ccache-3.1.8$ PATH=/home/debian/build-new/host/bin:/home/debian/build-new/host/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/home/debian/build-new/host/usr/bin/ccache /usr/bin/gcc" GCC="/home/debian/build-new/host/usr/bin/ccache /usr/bin/gcc" CXX="/home/debian/build-new/host/usr/bin/ccache /usr/bin/g++" CPP="/usr/bin/cpp" CPPFLAGS="-I/home/debian/build-new/host/usr/include" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" CXXFLAGS="-O2 -I/home/debian/build-new/host/usr/include" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/debian/build-new/host/usr/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/debian/build-new/host/usr/lib/pkgconfig:/home/debian/build-new/host/usr/share/pkgconfig" PERLLIB="/home/debian/build-new/host/usr/lib/perl" LD_LIBRARY_PATH="/home/debian/build-new/host/usr/lib:" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" CC="/usr/bin/gcc" ./configure --prefix="/home/debian/build-new/host/usr" --sysconfdir="/home/debian/build-new/host/etc" --enable-shared --disable-static --disable-gtk-doc --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no ccache_cv_zlib_1_2_3=no
configure: WARNING: unrecognized options: --enable-shared, --disable-static, --disable-gtk-doc, --disable-doc, --disable-docs, --disable-documentation, --with-xmlto, --with-fop
configure: Configuring ccache
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/home/debian/build-new/build/host-ccache-3.1.8':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
아래 명령을 얻기 위해 모든 플래그를 제거하면 구성 스크립트가 완벽하게 실행됩니다.
./configure --prefix="/home/debian/build-new/host/usr" --sysconfdir="/home/debian/build-new/host/etc" --enable-shared --disable-static - -disable-gtk-doc --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no ccache_cv_zlib_1_2_3=no
구성 스크립트는 path/to/lib/libc.so.0 및 path/to/usr/lib/uclibc_nonshared.a 파일을 찾으려고 하기 때문에 충돌이 발생합니다. 문제는 Makefile이 라이브러리를 가져와야 하는 위치를 명시적으로 설정하더라도 스크립트가 /lib/ 및 /usr/lib/에서 이러한 라이브러리를 찾으려고 한다는 것입니다. LDFLAGS가 가리키는 위치에서 라이브러리를 수동으로 심볼릭 링크하여 /lib/ 및 /usr/lib/에 연결하면 다음 메시지만 표시됩니다.
/usr/bin/ld: skipping incompatible /lib/libc.so.0 when searching for /lib/libc.so.0
/usr/bin/ld: cannot find /lib/libc.so.0
/usr/bin/ld: skipping incompatible /usr/lib/uclibc_nonshared.a when searching for /usr/lib/uclibc_nonshared.a
/usr/bin/ld: cannot find /usr/lib/uclibc_nonshared.a
또한 LD 플래그를 설정해도 LD="/home/debian/build-new/host/usr/bin/mips-linux-ld"
문제가 해결되지 않습니다.
Makefile을 올바르게 컴파일하는 방법은 무엇입니까? 일부 로그와 구성을 남겼습니다.Github의 주요 서비스.
편집하다:
사용@filbranden의 팁이제 다음과 같은 출력을 얻는 지점에 도달했습니다.
/home/debian/build-new/toolchain/gcc-4.7.3-intermediate/./gcc/xgcc -B/home/debian/build-new/toolchain/gcc-4.7.3-intermediate/./gcc/ - B/home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/bin/ -B/home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/lib/ - isystem /home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/include -isystem /home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/sys-include - g -Os -O2 -g -Os -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fPIC -I. -나. -I../.././gcc -I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc -I/home/debian/build-new/toolchain/gcc-4.7.3/ libgcc/.-I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc/../gcc -I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc/. ./include -DHAVE_CC_TLS -o _fractHADI_s.o -MT _fractHADI_s.o -MD -MP -MF _fractHADI_s.dep -DSHARED -DL_fract -DFROM_HA -DTO_DI -c /home/debian/build-new/toolchain/gcc-4.7.3 /libgcc/고정 bit.c
/home/debian/build-new/toolchain/gcc-4.7.3-intermediate/./gcc/xgcc -B/home/debian/build-new/toolchain/gcc-4.7.3-intermediate/./gcc/ - B/home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/bin/ -B/home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/lib/ - isystem /home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/include -isystem /home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/sys-include - g -Os -O2 -g -Os -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fPIC -I. -나. -I../.././gcc -I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc -I/home/debian/build-new/toolchain/gcc-4.7.3/ libgcc/.-I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc/../gcc -I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc/. ./include -DHAVE_CC_TLS -o _fractHATI_s.o -MT _fractHATI_s.o -MD -MP -MF _fractHATI_s.dep -DSHARED -DL_fract -DFROM_HA -DTO_TI -c /home/debian/build-new/toolchain/gcc-4.7.3 /libgcc/고정 bit.c
/home/debian/build-new/toolchain/gcc-4.7.3-intermediate/./gcc/xgcc -B/home/debian/build-new/toolchain/gcc-4.7.3-intermediate/./gcc/ - B/home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/bin/ -B/home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/lib/ - isystem /home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/include -isystem /home/debian/build-new/host/usr/mips-buildroot-linux-uclibc/sys-include - g -Os -O2 -g -Os -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fPIC -I. -나. -I../.././gcc -I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc -I/home/debian/build-new/toolchain/gcc-4.7.3/ libgcc/.-I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc/../gcc -I/home/debian/build-new/toolchain/gcc-4.7.3/libgcc/. ./include -DHAVE_CC_TLS -o _fractHASF_s.o -MT _fractHASF_s.o -MD -MP -MF _fractHASF_s.dep -DSHARED -DL_fract -DFROM_HA -DTO_SF -c /home/debian/build-new/toolchain/gcc-4.7.3 /libgcc/고정 bit.c
이 컴파일은 현재 17-18시간 동안 실행되었습니다(그리고 충돌이 발생하지 않았거나 오류가 발생했음을 나타내는 다른 작업을 수행하지 않았습니다). 고정된 bit.c에서는 여전히 작동합니다. 조금 이상해 보이지만 어쩌면 정상일까요?
답변1
사용@filbranden의 댓글, 내 라우터용 커널을 컴파일할 수 있었습니다(해결해야 할 버그가 더 있지만 이 질문의 범위는 아닙니다).
로그와 컴파일된 커널 구성을 남겼습니다.Github 하이라이트(새 로그 및 구성). 구성이 손상되어 Linux의 실제 컴파일 단계까지는 명확하지 않지만 솔루션은 간단합니다.
커널을 컴파일하기 위해 다음 명령을 실행합니다.
menuconfig를 O=~/build-new/로 만드세요.
RANLIB="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-ranlib" READELF="/home/debian/new-kernel/ sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-readelf" OBJDUMP="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2. 3/usr/bin/mips-linux-uclibc-objdump" AR="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux- uclibc- ar" AS="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-as" LD="/home/debian/ new- 커널/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-gcc" NM="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc- 4.2. 3-3/usr/bin/mips-linux-uclibc-nm" CC="/home/debian/bin-new/ccache-3.1.8/ccache /home/debian/new-kernel/sagem/uclibc-crosstools- gcc-4.2.3-3/usr/bin/mips-linux-uclibc-gcc" GCC="/home/debian/bin-new/ccache-3.1.8/ccache /home/debian/new-kernel/ sagem/ uclibc-crosstools-gcc-4.2.3-3/usr/bin/gcc" CXX="/home/debian/bin-new/ccache-3.1.8/ccache /home/debian/new-kernel/sagem/ uclibc- crosstools-gcc-4.2.3-3/usr/bin/g++" CPP="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips- linux- uclibc-cpp" CPPFLAGS="-I/home/debian/build-new/host/usr/include" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" CXXFLAGS= "- O2 -I/home/debian/build-new/host/usr/include" LDFLAGS="-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/ usr/ lib" make autoconf O=~/build-new/
RANLIB="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-ranlib" READELF="/home/debian/new-kernel/ sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-readelf" OBJDUMP="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2. 3/usr/bin/mips-linux-uclibc-objdump" AR="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux- uclibc- ar" AS="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-as" LD="/home/debian/ new- 커널/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-gcc" NM="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc- 4.2. 3-3/usr/bin/mips-linux-uclibc-nm" CC="/home/debian/bin-new/ccache-3.1.8/ccache /home/debian/new-kernel/sagem/uclibc-crosstools- gcc-4.2.3-3/usr/bin/mips-linux-uclibc-gcc" GCC="/home/debian/bin-new/ccache-3.1.8/ccache /home/debian/new-kernel/ sagem/ uclibc-crosstools-gcc-4.2.3-3/usr/bin/gcc" CXX="/home/debian/bin-new/ccache-3.1.8/ccache /home/debian/new-kernel/sagem/ uclibc- crosstools-gcc-4.2.3-3/usr/bin/g++" CPP="/home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips- linux- uclibc-cpp" CPPFLAGS="-I/home/debian/build-new/host/usr/include" CFLAGS="-O2 -I/home/debian/build-new/host/usr/include" CXXFLAGS= "- O2 -I/home/debian/build-new/host/usr/include" LDFLAGS="-L/home/debian/build-new/host/lib -L/home/debian/build-new/host/ usr/ lib -Wl,-rpath,/home/debian/build-new/host/usr/lib" make O=~/build-new/
다음 오류가 발생하면 make 명령을 실행하기 전에 일부 바이너리를 심볼릭 링크해야 합니다.
Checking for C compiler ... none found
ERROR: no C compiler found
Checking for linker ... '/home/debian/build-new/host/usr/bin/mips-buildroot-linux-uclibc-gcc' not found (user)
ERROR: no linker found
Checking for ar ... /home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-ar ()
Checking for ranlib ... /home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-ranlib ()
Checking for readelf ... none found
ERROR: no readelf found
Checking for objdump ... /home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-objdump ()
내 심볼릭 링크 바이너리는 다음과 같습니다. 심볼릭 링크가 중요하지 않다고 생각하는 기호 앞에 해시 기호를 넣었습니다(make 명령의 접두사에서 경로를 설정할 수 없기 때문입니다).
mkdir -p /home/debian/build-new/host/usr/bin/
cp -r /home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/* /home/debian/build-new/host/usr/bin/
cd /home/debian/build-new/host/usr/bin/
ln -s mips-linux-uclibc-gcc mips-buildroot-linux-uclibc-gcc
#ln -s /home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-ranlib mips-buildroot-linux-uclibc-ranlib
#ln -s /home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-readelf mips-buildroot-linux-uclibc-readelf
#ln -s /home/debian/new-kernel/sagem/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-objdump mips-buildroot-linux-uclibc-objdump
커널 자체를 빌드할 때 여기의 구성과 명령은 여전히 손상되어 있지만 이 버그가 있는 단계를 극복할 만큼 충분히 기능합니다. 오늘 아침에 커널을 성공적으로 컴파일했지만(순수한 컴파일 시간만 24시간 이상 걸렸습니다), QEMU에서 부팅하고 라우터에서 복사한 파일 시스템을 마운트한 후 잘못된 엔디안을 선택했다는 사실을 깨닫기 시작했습니다. 리틀 엔디안 대신 빅 엔디안, MSB 대신 LSB를 선택합니다.
그렇지 않으면 @filbranden의 도움을 사용하여 커널을 성공적으로 컴파일했습니다.