LibGCC编译失败,出现错误:无法计算对象文件后缀:无法编译

qacovj5a  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(316)

当我尝试安装gcc交叉编译器时,使用以下说明:

sudo apt update
sudo apt -y install curl build-essential m4 libgmp3-dev libmpc-dev libmpfr-dev

# install gmp 6.2.0
curl --output gmp-6.2.0.tar.bz2 https://ftp.gnu.org/gnu/gmp/gmp-6.2.0.tar.bz2
tar -xvf gmp-6.2.0.tar.bz2
cd gmp-6.2.0
./configure --prefix=/usr/local/cc
make check && sudo make install
cd ..

# install mpfr
curl --output mpfr-4.1.0.tar.bz2 https://ftp.gnu.org/gnu/mpfr/mpfr-4.1.0.tar.bz2
tar -xvf mpfr-4.1.0.tar.bz2
cd mpfr-4.1.0
./configure --prefix=/usr/local/cc
make check && sudo make install
cd ..

# install mpc
curl --output mpc-1.2.0.tar.gz https://ftp.gnu.org/gnu/mpc/mpc-1.2.0.tar.gz
tar -xvf mpc-1.2.0.tar.gz
cd mpc-1.2.0
./configure --prefix=/usr/local/cc
make check && sudo make install
cd ..

# install gcc
curl --output gcc-10.2.0.tar.xz https://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.xz
tar -xvf gcc-10.2.0.tar.xz
mkdir gcc-make-tmp
cd gcc-make-tmp
../gcc-10.2.0/configure\
    --target=x86_64-elf\
    --prefix=/usr/local/cc\
    --disable-nls\
    --enable-languages=c\
    --without-headers\
    --with-gmp=/usr/local/cc\
    --with-mpfr=/usr/local/cc\
    --with-mpc=/usr/local/cc\
    --with-headers=/usr/include\
    --with-headers=/usr/include/x86_64-linux-gnu

make all-gcc && make install-gcc
make all-target-libgcc && make install-target-libgcc

但是make all-target-libgcc失败,并返回错误:configure: error: cannot compute suffix of object files: cannot compile .
config.log:

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by GNU C Runtime Library configure 1.0, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ /mnt/d/gcc-10.2.0/libgcc/configure --srcdir=../../../gcc-10.2.0/libgcc --cache-file=./config.cache --enable-multilib --with-cross-host=x86_64-pc-linux-gnu --prefix=/mnt/d/usr/local/cc --disable-nls --without-headers --with-headers=/usr/include --with-headers=/usr/include/x86_64-linux-gnu --disable-sanity-checks --enable-languages=c,lto --program-transform-name=s&^&x86_64-elf-& --disable-option-checking --with-target-subdir=x86_64-elf --build=x86_64-pc-linux-gnu --host=x86_64-elf --target=x86_64-elf

## --------- ##
## Platform. ##
## --------- ##

hostname = NOTE02
uname -m = x86_64
uname -r = 4.4.0-18362-Microsoft
uname -s = Linux
uname -v = #836-Microsoft Mon May 05 16:04:00 PST 2020

/usr/bin/uname -p = x86_64
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /mnt/d/usr/local/cc/bin/
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /snap/bin

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2071: loading cache ./config.cache
configure:2300: checking build system type
configure:2314: result: x86_64-pc-linux-gnu
configure:2334: checking host system type
configure:2347: result: x86_64-pc-elf
configure:2450: checking for --enable-version-specific-runtime-libs
configure:2463: result: no
configure:2534: checking for a BSD-compatible install
configure:2602: result: /usr/bin/install -c
configure:2618: checking for gawk
configure:2645: result: gawk
configure:2752: checking for x86_64-elf-ar
configure:2779: result: x86_64-elf-ar
configure:2844: checking for x86_64-elf-lipo
configure:2871: result: x86_64-elf-lipo
configure:2936: checking for x86_64-elf-nm
configure:2963: result: /mnt/d/gcc-build-tmp/./gcc/nm
configure:3028: checking for x86_64-elf-ranlib
configure:3055: result: x86_64-elf-ranlib
configure:3120: checking for x86_64-elf-strip
configure:3147: result: x86_64-elf-strip
configure:3209: checking whether ln -s works
configure:3213: result: yes
configure:3230: checking for x86_64-elf-gcc
configure:3257: result:  /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include   
configure:3526: checking for C compiler version
configure:3535:  /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include    --version >&5
xgcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3546: $? = 0
configure:3535:  /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include    -v >&5
Reading specs from /mnt/d/gcc-build-tmp/./gcc/specs
COLLECT_GCC=/mnt/d/gcc-build-tmp/./gcc/xgcc
COLLECT_LTO_WRAPPER=/mnt/d/gcc-build-tmp/./gcc/lto-wrapper
Target: x86_64-elf
Configured with: ../gcc-10.2.0/configure --target=x86_64-elf --prefix=/mnt/d/usr/local/cc --disable-nls --enable-languages=c --without-headers --with-gmp=/mnt/d/usr/local/cc --with-mpfr=/mnt/d/usr/local/cc --with-mpc=/mnt/d/usr/local/cc/ : (reconfigured) ../gcc-10.2.0/configure --target=x86_64-elf --prefix=/mnt/d/usr/local/cc --disable-nls --enable-languages=c --without-headers --with-gmp=/mnt/d/usr/local/cc --with-mpfr=/mnt/d/usr/local/cc --with-mpc=/mnt/d/usr/local/cc/ --with-headers=/usr/include : (reconfigured) ../gcc-10.2.0/configure --target=x86_64-elf --prefix=/mnt/d/usr/local/cc --disable-nls --enable-languages=c --without-headers --with-gmp=/mnt/d/usr/local/cc --with-mpfr=/mnt/d/usr/local/cc --with-mpc=/mnt/d/usr/local/cc/ --with-headers=/usr/include --with-headers=/usr/include/x86_64-linux-gnu : (reconfigured) ../gcc-10.2.0/configure --target=x86_64-elf --prefix=/mnt/d/usr/local/cc --disable-nls --enable-languages=c --without-headers --with-gmp=/mnt/d/usr/local/cc --with-mpfr=/mnt/d/usr/local/cc --with-mpc=/mnt/d/usr/local/cc/ --with-headers=/usr/include --with-headers=/usr/include/x86_64-linux-gnu --disable-libmudflap --disable-libssp --disable-threads : (reconfigured) ../gcc-10.2.0/configure --target=x86_64-elf --prefix=/mnt/d/usr/local/cc --disable-nls --enable-languages=c --without-headers --with-gmp=/mnt/d/usr/local/cc --with-mpfr=/mnt/d/usr/local/cc --with-mpc=/mnt/d/usr/local/cc/ --with-headers=/usr/include --with-headers=/usr/include/x86_64-linux-gnu --disable-libmudflap --disable-libssp --disable-threads --disable-shared : (reconfigured) ../gcc-10.2.0/configure --target=x86_64-elf --prefix=/mnt/d/usr/local/cc --disable-nls --enable-languages=c --without-headers --with-gmp=/mnt/d/usr/local/cc --with-mpfr=/mnt/d/usr/local/cc --with-mpc=/mnt/d/usr/local/cc/ --with-headers=/usr/include --with-headers=/usr/include/x86_64-linux-gnu --disable-sanity-checks
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC) 
configure:3546: $? = 0
configure:3535:  /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include    -V >&5
xgcc: error: unrecognized command-line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3546: $? = 1
configure:3535:  /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include    -qversion >&5
xgcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
xgcc: fatal error: no input files
compilation terminated.
configure:3546: $? = 1
configure:3562:  /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include    -o conftest -g -O2   conftest.c  >&5
/mnt/d/gcc-build-tmp/./gcc/as: 106: exec: -o: not found
configure:3565: $? = 1
configure:3778: checking for suffix of object files
configure:3800:  /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include    -c -g -O2  conftest.c >&5
/mnt/d/gcc-build-tmp/./gcc/as: 106: exec: -o: not found
configure:3804: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3818: error: in `/mnt/d/gcc-build-tmp/x86_64-elf/libgcc':
configure:3820: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=x86_64-pc-linux-gnu
ac_cv_c_compiler_gnu=no
ac_cv_env_CC_set=set
ac_cv_env_CC_value=' /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include   '
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value='-g -O2'
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=set
ac_cv_env_build_alias_value=x86_64-pc-linux-gnu
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=x86_64-elf
ac_cv_env_target_alias_set=set
ac_cv_env_target_alias_value=x86_64-elf
ac_cv_header_ftw_h=yes
ac_cv_header_inttypes_h=yes
ac_cv_header_memory_h=yes
ac_cv_header_stdc=no
ac_cv_header_stdint_h=yes
ac_cv_header_stdlib_h=yes
ac_cv_header_string_h=yes
ac_cv_header_strings_h=yes
ac_cv_header_sys_auxv_h=yes
ac_cv_header_sys_stat_h=yes
ac_cv_header_sys_types_h=yes
ac_cv_header_unistd_h=yes
ac_cv_host=x86_64-pc-elf
ac_cv_path_EGREP='/usr/bin/grep -E'
ac_cv_path_GREP=/usr/bin/grep
ac_cv_path_install='/usr/bin/install -c'
ac_cv_prog_AR=x86_64-elf-ar
ac_cv_prog_AWK=gawk
ac_cv_prog_CC=' /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include   '
ac_cv_prog_CPP=' /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include    -E'
ac_cv_prog_LIPO=x86_64-elf-lipo
ac_cv_prog_NM=/mnt/d/gcc-build-tmp/./gcc/nm
ac_cv_prog_RANLIB=x86_64-elf-ranlib
ac_cv_prog_STRIP=x86_64-elf-strip
ac_cv_prog_cc_c89=no
ac_cv_prog_cc_g=no
ac_cv_sizeof_double=0
ac_cv_sizeof_long_double=0
ac_cv_sjlj_exceptions=yes
ac_cv_sys_file_offset_bits=unknown
ac_cv_sys_large_files=unknown
ac_cv_sys_largefile_CC=no
acl_cv_prog_gnu_ld=no
gcc_cv_have_cc_tls=no
gcc_cv_use_emutls=yes
libgcc_cv_cfi=no
libgcc_cv_cfi_sections_directive=no
libgcc_cv_dfp=no
libgcc_cv_fixed_point=no
libgcc_cv_hidden_visibility_attribute=no
libgcc_cv_init_priority=no

## ----------------- ##
## Output variables. ##
## ----------------- ##

AR='x86_64-elf-ar'
AWK='gawk'
CC=' /mnt/d/gcc-build-tmp/./gcc/xgcc -B/mnt/d/gcc-build-tmp/./gcc/ -B/mnt/d/usr/local/cc/x86_64-elf/bin/ -B/mnt/d/usr/local/cc/x86_64-elf/lib/ -isystem /mnt/d/usr/local/cc/x86_64-elf/include -isystem /mnt/d/usr/local/cc/x86_64-elf/sys-include   '
CET_FLAGS=''
CFLAGS='-g -O2'
CPP=''
CPPFLAGS=''
DEFS=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
GREP=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
LDFLAGS=''
LIBOBJS=''
LIBS=''
LIPO='x86_64-elf-lipo'
LN_S='ln -s'
LTLIBOBJS=''
MAINT='#'
NM='/mnt/d/gcc-build-tmp/./gcc/nm'
OBJEXT=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME='GNU C Runtime Library'
PACKAGE_STRING='GNU C Runtime Library 1.0'
PACKAGE_TARNAME='libgcc'
PACKAGE_URL='http://www.gnu.org/software/libgcc/'
PACKAGE_VERSION='1.0'
PATH_SEPARATOR=':'
PICFLAG='-fpic'
RANLIB='x86_64-elf-ranlib'
SHELL='/bin/bash'
STRIP='x86_64-elf-strip'
ac_ct_CC=''
accel_dir_suffix=''
asm_hidden_op=''
bindir='${exec_prefix}/bin'
build='x86_64-pc-linux-gnu'
build_alias='x86_64-pc-linux-gnu'
build_cpu='x86_64'
build_libsubdir='build-x86_64-pc-linux-gnu'
build_os='linux-gnu'
build_subdir='build-x86_64-pc-linux-gnu'
build_vendor='pc'
cpu_type=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
decimal_float=''
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
double_type_size=''
dvidir='${docdir}'
enable_decimal_float=''
enable_execute_stack=''
enable_gcov='yes'
enable_shared='yes'
enable_vtable_verify='no'
exec_prefix='NONE'
extra_parts=''
fixed_point=''
force_explicit_eh_registry=''
get_gcc_base_ver=''
host='x86_64-pc-elf'
host_alias='x86_64-elf'
host_cpu='x86_64'
host_noncanonical='x86_64-elf'
host_os='elf'
host_subdir='.'
host_vendor='pc'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
libgcc_topdir='../../../gcc-10.2.0/libgcc/..'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
long_double_type_size=''
mandir='${datarootdir}/man'
md_unwind_header=''
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/mnt/d/usr/local/cc'
program_transform_name='s&^&x86_64-elf-&'
psdir='${docdir}'
real_host_noncanonical=''
sbindir='${exec_prefix}/sbin'
set_have_cc_tls=''
set_use_emutls=''
sfp_machine_header=''
sharedstatedir='${prefix}/com'
slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
solaris_ld_v2_maps=''
sysconfdir='${prefix}/etc'
target_alias='x86_64-elf'
target_noncanonical='x86_64-elf'
target_subdir='x86_64-elf'
thread_header=''
tm_defines=''
tm_file=''
tmake_file=''
toolexecdir='$(exec_prefix)/$(target_noncanonical)'
toolexeclibdir='$(toolexecdir)/lib'
unwind_header=''
use_tm_clone_registry=''
vis_hide=''
with_aix_soname='aix'

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME "GNU C Runtime Library"
#define PACKAGE_TARNAME "libgcc"
#define PACKAGE_VERSION "1.0"
#define PACKAGE_STRING "GNU C Runtime Library 1.0"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL "http://www.gnu.org/software/libgcc/"

configure: exit 1

环境

  • 基于WSL2的Ubuntu 20.04

关于StackOverflow的参考问题

rmbxnbpk

rmbxnbpk1#

自行解决

  • 使用--target=x86_64-elf选项从源代码手动生成binutils。

就这样了。

相关问题