Bug 47836 - Some Cross Compiler can't build target-libiberty or target-zlib
Summary: Some Cross Compiler can't build target-libiberty or target-zlib
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: regression (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-21 14:44 UTC by th.r.klein
Modified: 2012-02-02 08:16 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-02-22 22:28:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description th.r.klein 2011-02-21 14:44:56 UTC
With upcoming 4.6 building of target-libiberty and target-zlib is enabled (at most platforms) per default.
It should be possible to disable this behavior e.g. with switches like:
--without-target-libiberty
--without-target-zlib

Previous versions did not try to build these libraries for cross compilers.


Index: configure.ac
===================================================================
--- configure.ac        (revision 170359)
+++ configure.ac        (working copy)
@@ -262,6 +262,16 @@ skipdirs=
 # Noconfigdirs are removed loudly.
 noconfigdirs=""
 
+# Make sure we don't let target-libiberty be added if we didn't want it.
+if test x$with_target_libiberty = xno ; then
+  noconfigdirs="$noconfigdirs target-libiberty"
+fi
+
+# Make sure we don't let target-zlib be added if we didn't want it.
+if test x$with_target_zlib = xno ; then
+  noconfigdirs="$noconfigdirs target-zlib"
+fi
+
 use_gnu_ld=
 # Make sure we don't let GNU ld be added if we didn't want it.
 if test x$with_gnu_ld = xno ; then
Index: configure
===================================================================
--- configure   (revision 170359)
+++ configure   (working copy)
@@ -2801,6 +2801,16 @@ skipdirs=
 # Noconfigdirs are removed loudly.
 noconfigdirs=""
 
+# Make sure we don't let target-libiberty be added if we didn't want it.
+if test x$with_target_libiberty = xno ; then
+  noconfigdirs="$noconfigdirs target-libiberty"
+fi
+
+# Make sure we don't let target-zlib be added if we didn't want it.
+if test x$with_target_zlib = xno ; then
+  noconfigdirs="$noconfigdirs target-zlib"
+fi
+
 use_gnu_ld=
 # Make sure we don't let GNU ld be added if we didn't want it.
 if test x$with_gnu_ld = xno ; then
Comment 1 Andrew Pinski 2011-02-21 19:20:20 UTC
Why does these libraries fail?
Comment 2 th.r.klein 2011-02-22 19:39:27 UTC
For example a microcontroller do not need to have any kind of standard C-Library files or its header files.
So it is not possible to build e.g. zlib or libiberty for this target platforms.
Additional I might to take a decision not to build this library, even if it is possible to build it.

The build process failed here.
Comment 3 Andrew Pinski 2011-02-22 22:28:10 UTC
I meant how does it fail?

>For example a microcontroller do not need to have any kind of standard C-Library files or its header files.

I don't think that is true. Most targets even microcontrollers one have a standard C library.  


Also how are you configuring GCC?  If you really only want GCC and libgcc, the easiest way to do that is:
make all-gcc && make all-target-libgcc
make install-gcc && make install-target-libgcc
Comment 4 th.r.klein 2011-02-23 17:56:54 UTC
The original failing process was:

../../env/src/configure --prefix=${HOME}/local --with-mpc=${HOME}/local --with-mpfr=${HOME}/local --with-gmp=${HOME}/local --with-ppl=${HOME}/local --with-cloog=${HOME}/local --with-libelf=${HOME}/local --target=arm-elf-eabi --enable-target-optspace --disable-nls --disable-werror --enable-target-static --disable-target-shared --enable-languages=c,c++ --with-float=soft --without-headers --enable-multilib --enable-tls --enable-lto --with-libexpat-prefix=/usr/local --with-expat=/usr/local --with-python=/usr/local --enable-gold --enable-ld

gmake
...<skip messages>...
gmake[2]: Leaving directory `/usr/home/thomas/work/build/env_eabi/arm-elf-eabi/libgcc'
Checking multilib configuration for libiberty...
mkdir arm-elf-eabi/libiberty
Configuring in arm-elf-eabi/libiberty
configure: creating cache ./config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking for makeinfo... makeinfo --split-size=5000000
checking for perl... perl
checking build system type... x86_64-unknown-freebsd8.1
checking host system type... arm-elf-eabi
checking for arm-elf-eabi-ar... /usr/home/thomas/work/build/env_eabi/./binutils/ar
checking for arm-elf-eabi-ranlib... /usr/home/thomas/work/build/env_eabi/./binutils/ranlib
checking for arm-elf-eabi-gcc... /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld   
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    accepts -g... yes
checking for /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    option to accept ISO C89... unsupported
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... unknown
checking for _LARGE_FILES value needed for large files... unknown
checking how to run the C preprocessor... /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    -E
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    supports -W... yes
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    supports -Wall... yes
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    supports -Wwrite-strings... yes
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    supports -Wc++-compat... yes
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    supports -Wstrict-prototypes... yes
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    supports -pedantic ... yes
checking whether /usr/home/thomas/work/build/env_eabi/./gcc/xgcc -B/usr/home/thomas/work/build/env_eabi/./gcc/ -B/usr/home/thomas/local/arm-elf-eabi/bin/ -B/usr/home/thomas/local/arm-elf-eabi/lib/ -isystem /usr/home/thomas/local/arm-elf-eabi/include -isystem /usr/home/thomas/local/arm-elf-eabi/sys-include -L/usr/home/thomas/work/build/env_eabi/./ld    and cc understand -c and -o together... yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... no
checking for sys/types.h... no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... no
checking whether byte ordering is bigendian... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for sys/file.h... no
checking for sys/param.h... no
checking for limits.h... yes
checking for stdlib.h... (cached) no
checking for malloc.h... no
checking for string.h... (cached) no
checking for unistd.h... (cached) no
checking for strings.h... (cached) no
checking for sys/time.h... no
checking for time.h... no
checking for sys/resource.h... no
checking for sys/stat.h... (cached) no
checking for sys/mman.h... no
checking for fcntl.h... no
checking for alloca.h... no
checking for sys/pstat.h... no
checking for sys/sysmp.h... no
checking for sys/sysinfo.h... no
checking for machine/hal_sysinfo.h... no
checking for sys/table.h... no
checking for sys/sysctl.h... no
checking for sys/systemcfg.h... no
checking for stdint.h... (cached) no
checking for stdio_ext.h... no
checking for process.h... no
checking for sys/prctl.h... no
checking for sys/wait.h that is POSIX.1 compatible... no
checking whether time.h and sys/time.h may both be included... no
checking whether errno must be declared... yes
checking size of int... 0
checking for a 64-bit type... unsigned long long
checking for intptr_t... no
checking for uintptr_t... no
checking for ssize_t... no
checking for pid_t... no
checking for library containing strerror... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
gmake[1]: *** [configure-target-libiberty] Error 1
gmake[1]: Leaving directory `/usr/home/thomas/work/build/env_eabi'
gmake: *** [all] Error 2



As far as I could see you (by meaning GCC) disabling target-libiberty at specific systems like netbsd rtems vxworks or specific machine types like avr, m68hc11, too.


I was able to build a cross compiler (without having a target libc) this way at least for version 4.4.3 and 4.5.2 .

Don't get me wrong. Building of target-libiberty and target-zlib per default can be usefull. Only for special cases it should be possible to change this behavior.
Comment 5 Andrew Pinski 2011-02-23 20:11:09 UTC
>--enable-languages=c,c++

Where you really able to build libstdc++ without libc?  I doubt that.  Try just enabling C first and then build newlib.  Or are you building a combined compiler?
Comment 6 th.r.klein 2011-02-24 19:42:39 UTC
Since I did not need to have libc I also did not need to have libstdc++-v3, too.
Also I did not need to have libgomp, libmudflap, libffi, libssp, libquadmath,
boehm-gc ..
But this is not a real problem. 
As long as those directories are not present in the source directory there was no try to generate these target libraries.
So all these libraries are never build for the target I used.

(At some platforms like avr, building of target-libstdc++ is disabled per default)

There is always a lot of hand work before gcc can be build.
Collecting the required gmp, mpfr, mpc, libelf, binutils etc. installing or merging parts into the source tree.
Ah, also I did not use rda, gprof, sid, cgen, utils, libgloss, newlib, ...
So removing of unneeded directories did not hurt.

How ever, it would be nice if those target libraries can be disabled per switch, too, but this would be an other feature request and it is not this bug.

Here the major problem is, libiberty and zlib is required by gcc itself.
And so those directories can not be simply removed.
Comment 7 Ralf Wildenhues 2011-02-26 15:34:12 UTC
It should generally work to pass --disable-target-zlib, and similar for other target directories, as workarounds.  If it doesn't work, that's worth a bug report (please open a separate one in that case, and link from this one).  Thanks.
Comment 8 th.r.klein 2011-02-27 09:23:44 UTC
Exactly this is the current problem, there is neither a working switch like
--disable-target-zlib nor a working --disable-target-libiberty.

(sorry if confusing you by using of "without" instead of "disable", but this was only an example.)
Comment 9 Andrew Pinski 2011-02-27 22:31:48 UTC
> have libstdc++-v3, too.

Then you cannot use the C++ compiler really.  So why compile it?
Comment 10 th.r.klein 2011-02-28 19:52:12 UTC
If you can't imagine how to get a usable C++ compiler without libstdc++-v3 (and libc), please stop wasting your time in thinking about it.
Here is no C++ problem at all.
If it helps you, think the C compiler will be build with --enable-languages=c switch instead.
Assume there will be no libc for the target architecture.
Especially there is no malloc or free, nor any kind of the other useful toys.
How ever, there will be functions doing similar things, but with different names and different interfaces.
In this situation it is currently impossible for gcc to build the target-zlib or the target-libiberty library.

Again, in 4.6 the generation of those libraries is now enabled per default (previously disabled per default).
On most targets this might make sense, but there must be a way to disable the generation of those libraries, too.

If you think there is already such a mechanism, then this mechanism did not work.
Comment 11 Ralf Wildenhues 2011-03-02 05:57:38 UTC
The automatic enabling of zlib was turned on by revision 152434, a merge of the lto branch.  It seems you can use --disable-lto or --with-system-zlib to disable a target zlib from being built.

Haven't looked at libiberty yet.
Comment 12 joseph@codesourcery.com 2011-03-02 16:50:20 UTC
I do not believe any component of the GCC or src tree uses a target 
libiberty.  Thus, I do not think such a target libiberty should be built 
or installed by default.  I also think host libiberty should not be 
installed by default, but that's a separate matter.

http://gcc.gnu.org/ml/gcc/2010-03/msg00012.html
http://gcc.gnu.org/ml/gcc-patches/2010-12/msg01231.html
Comment 13 Hans-Peter Nilsson 2011-06-22 20:17:55 UTC
Author: hp
Date: Wed Jun 22 20:17:47 2011
New Revision: 175307

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175307
Log:
	PR regression/47836
	PR bootstrap/23656
	PR other/47733
	PR bootstrap/49247
	* configure.ac (target_libraries): Remove target-libiberty.
	Remove case-statement setting skipdirs=target-libiberty for
	multiple targets.  Remove checking target_configdirs and
	removing target-libiberty but keeping target-libgcc if
	otherwise empty.
	* Makefile.def (target_modules): Don't add libiberty.
	(dependencies): Remove all traces of target-libiberty.
	* configure, Makefile.in: Regenerate.
(fixing PR annotations in the ChangeLog entry)

Modified:
    trunk/ChangeLog
Comment 14 Hans-Peter Nilsson 2011-06-22 21:30:24 UTC
Author: hp
Date: Wed Jun 22 21:30:19 2011
New Revision: 175316

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175316
Log:
	PR regression/47836
	PR bootstrap/23656
	PR other/47733
	PR bootstrap/49247
	PR c/48825
	* configure.ac (target_libraries): Remove target-libiberty.
	Remove case-statement setting skipdirs=target-libiberty for
	multiple targets.  Remove checking target_configdirs and
	removing target-libiberty but keeping target-libgcc if
	otherwise empty.
	* Makefile.def (target_modules): Don't add libiberty.
	(dependencies): Remove all traces of target-libiberty.
	* configure, Makefile.in: Regenerate.
(add missing PR annotation in the ChangeLog entry)

Modified:
    trunk/ChangeLog
Comment 15 th.r.klein 2011-06-24 11:10:27 UTC
The commit helps suppress building of target-libiberty.
But there is still a try to build target-zlib.
Isn't it possible to add a manual switch to prevent building of such target libraries by adding them to
'noconfigdirs' with eg. --disable-target-zlib?

For a possible implementation see (http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00374.html)
or below.

Index: configure.ac
===================================================================
--- configure.ac	(revision 175346)
+++ configure.ac	(working copy)
@@ -1880,6 +1880,28 @@ case ,${enable_languages},:${enable_objc_gc} in
     ;;
 esac
 
+# a user defined "--disable-target-.." was given
+# add this to the ingnore list if not already present
+for target_lib_var in $target_libraries
+do
+  var=`$as_echo "$target_lib_var" | sed 's/[[-+.]]/_/g'`
+  eval is_enabled=\$enable_$var
+  if test x$is_enabled = xno ; then
+    append_var=yes
+    for var in $noconfigdirs $skipdirs
+    do
+      if test x$var = x$target_lib_var ; then
+        append_var=no
+	break
+      fi
+    done
+    if test x$append_var = xyes ; then
+      noconfigdirs="$noconfigdirs $target_lib_var"
+      echo "add $target_lib_var to noconfigdirs"
+    fi
+  fi
+done
+
 # Remove the entries in $skipdirs and $noconfigdirs from $configdirs,
 # $build_configdirs and $target_configdirs.
 # If we have the source for $noconfigdirs entries, add them to $notsupp.
Comment 16 Hans-Peter Nilsson 2011-06-27 20:55:03 UTC
Author: hp
Date: Mon Jun 27 20:54:59 2011
New Revision: 175560

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175560
Log:
	PR regression/47836
	PR bootstrap/23656
	PR other/47733
	PR bootstrap/49247
	PR c/48825
	* configure.ac (target_libraries): Remove target-libiberty.
	Remove all target-specific settings adding target-libiberty to
	skipdirs and noconfigdirs.  Remove checking target_configdirs
	and removing target-libiberty but keeping target-libgcc if
	otherwise empty.
	* Makefile.def (target_modules): Don't add libiberty.
	(dependencies): Remove all traces of target-libiberty.
	* configure, Makefile.in: Regenerate.

Modified:
    branches/gcc-4_6-branch/ChangeLog
    branches/gcc-4_6-branch/Makefile.def
    branches/gcc-4_6-branch/Makefile.in
    branches/gcc-4_6-branch/configure
    branches/gcc-4_6-branch/configure.ac
Comment 17 Hans-Peter Nilsson 2011-06-27 21:02:59 UTC
Author: hp
Date: Mon Jun 27 21:02:53 2011
New Revision: 175564

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175564
Log:
	PR regression/47836
	PR bootstrap/23656
	PR other/47733
	PR bootstrap/49247
	PR c/48825
	* configure.ac (target_libraries): Remove target-libiberty.
	Remove all target-specific settings adding target-libiberty to
	skipdirs and noconfigdirs.  Remove checking target_configdirs
	and removing target-libiberty but keeping target-libgcc if
	otherwise empty.
	* Makefile.def (target_modules): Don't add libiberty.
	(dependencies): Remove all traces of target-libiberty.
	* configure, Makefile.in: Regenerate.

Modified:
    branches/gcc-4_5-branch/ChangeLog
    branches/gcc-4_5-branch/Makefile.def
    branches/gcc-4_5-branch/Makefile.in
    branches/gcc-4_5-branch/configure
    branches/gcc-4_5-branch/configure.ac
Comment 18 Roger Meyer 2011-10-07 04:25:24 UTC
full ack to th.r.klein, it makes sense to add a flag to --disable-target-zlib.

it is possible that one wants to use lto, but doesn't need target-zlib built.
especially with --disable-bootstrap.

it is failing here as well, disregarding the fact that building it without needing it eats my valuable time.
Comment 19 Andrew Pinski 2012-02-02 08:16:23 UTC
libiberty has been removed as a target library.
And zlib as a target library is only built when building with java and java support needs a full C library anyways.

So this is not really a bug and closing as such.