Compilng libgcc xgcc error
Asked Answered
K

3

13

I'm trying to install cross compiler, this tutorial, and when I want to make libgcc I just put make all-target-libgcc in my terminal. This make throws error

checking whether ln -s works... yes
checking for i586-elf-gcc...  /usr/src/build-gcc/./gcc/xgcc -B/usr/src/build-gcc/./gcc/         -B/usr/local/cross/i586-elf/bin/ -B/usr/local/cross/i586-elf/lib/ -isystem /usr/local/cross/i586-elf/include -isystem /usr/local/cross/i586-elf/sys-include   
checking for suffix of object files... configure: error: in `/usr/src/build-gcc/i586-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make: *** [configure-target-libgcc] Error 1

In config.log I found

Target: i586-elf
Configured with: ../gcc-4.8.0/configure --target=i586-elf --prefix=/usr/local/cross --        disable-nls --enable-languages=c,c++ --without-headers : (reconfigured) ../gcc-4.8.0/configure --target=i586-elf --prefix=/usr/local/cross --disable-nls --enable-languages=c,c++ --without-headers : (reconfigured) ../gcc-4.8.0/configure --target=i586-elf --prefix=/usr/local/cross --disable-nls --enable-languages=c,c++ --without-headers
Thread model: single
gcc version 4.8.0 (GCC) 
configure:3358: $? = 0
configure:3347:  /usr/src/build-gcc/./gcc/xgcc -B/usr/src/build-gcc/./gcc/ -    B/usr/local/cross/i586-elf/bin/ -B/usr/local/cross/i586-elf/lib/ -isystem /usr/local/cross/i586-elf/include -isystem /usr/local/cross/i586-elf/sys-include    -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files

In fact xgcc don't have '-V' option. I'm searching the way how to compile libgcc.

Thanks in advance

Keble answered 18/4, 2013 at 7:11 Comment(2)
Normally libgcc is part of the GCC compiler so should be built with GCC. You don't need special actions to get it built.Submission
Same error here. gcc version 4.8.1 (GCC)Bicker
S
17

Here's the problem: Before you attempted to build libgcc as you described, you built an extreme bare-bones cross compiler. Now, part of the standard tests that the configure script runs is to test the compiler to see if it will produce a working executable file under normal conditions. Your bare bones compiler can't. Fortunately, for libgcc, you don't need to produce an executable, just a static library libgcc.a . The problem is that the stupid GNU autoconf-generated script doesn't realize that.

I encountered this same problem and devised a very ugly workaround. You need to comment out a section of the libgcc/configure file in your gcc source directory. Here's the section I commented out for my version; do something similar to yours:

At line 3484:

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
# BEGIN PHILLIP EDIT
# if test -z "$ac_file"; then :
  # $as_echo "$as_me: failed program was:" >&5
# sed 's/^/| /' conftest.$ac_ext >&5

# { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
# $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
# { as_fn_set_status 77
# as_fn_error "C compiler cannot create executables
# See \`config.log' for more details." "$LINENO" 5; }; }
# fi
ac_file='a.out'
# END PHILLIP EDIT
ac_exeext=$ac_cv_exeext

Hope this helps.

Senhorita answered 7/10, 2014 at 21:9 Comment(1)
I tried several version of GCC, it's always the same. Your answer seems to be the only one that solves my problem.X
C
9

I ran into a similar problem trying to build libstdc++ by itself. The configuration options --enable-offload-target=x86_64-pc-linux-gnu resolve the issue and --disable-bootstrap saved quite a bit of compile time. After adding the former flag, make all-target-libstdc++-v3 stopped complaining about xgcc and the compiler cannot create executables. No need for the above patch, hopefully this will help someone else.

Conspiracy answered 17/4, 2018 at 21:7 Comment(0)
C
0

Commenting out the following section in the libgcc/configure file solved it for me. Look at https://mcmap.net/q/855985/-compilng-libgcc-xgcc-error for more context on the configure file.

# for ac_option in --version -v -V -qversion; do
#   { { ac_try="$ac_compiler $ac_option >&5"
# case "(($ac_try" in
#   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
#   *) ac_try_echo=$ac_try;;
# esac
# eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
# $as_echo "$ac_try_echo"; } >&5
#   (eval "$ac_compiler $ac_option >&5") 2>conftest.err
#   ac_status=$?
#   if test -s conftest.err; then
#     sed '10a\
# ... rest of stderr output deleted ...
#          10q' conftest.err >conftest.er1
#     cat conftest.er1 >&5
#     rm -f conftest.er1 conftest.err
#   fi
#   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
#   test $ac_status = 0; }
# done
Corkwood answered 15/1, 2021 at 3:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.