This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH RFA: Adjust --enable-build-with-cxx configury
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 24 Jun 2009 13:06:35 -0700
- Subject: PATCH RFA: Adjust --enable-build-with-cxx configury
This patch adjusts the --enable-build-with-cxx configury as requested by
Joseph Myers.
* When building gcc with --enable-build-with-cxx, if HOST_LIBS is not
empty, then link with $(CC) rather than $(CXX). HOST_LIBS will be
non-empty at various times if configured with --with-host-libstdcxx,
or --with-stage1-libs, or --with-poststage1-libs. This permits full
control over how -lstdc++ is used.
* When building gcc with --enable-build-with-cxx, only set the default
post-stage1 linker flags if the post-stage1 extra libraries are not
set. This change also permits full control over how -lstdc++ is
used.
* When building gcc with --enable-build-with-cxx, if the post-stage1
extra libraries are not set, then set the post-stage1 linker flags to
include -static-libgcc as well as -static-libstdc++. There is no
general need for gcc to link dynamically against -lgcc. Actually we
might want to consider using that even without
--enable-build-with-cxx.
Bootstrapped on x86_64-unknown-linux-gnu. OK for mainline?
Ian
top level ChangeLog:
2009-06-24 Ian Lance Taylor <iant@google.com>
* configure.ac: Change default of poststage1_ldflags to be empty if
poststage1_libs is set. When poststage1_libs is empty, and
ENABLE_BUILD_WITH_CXX is set, add -static-libgcc.
* configure: Rebuild.
gcc/ChangeLog:
2009-06-24 Ian Lance Taylor <iant@google.com>
* Makefile.in (HOST_LIBS): Move higher in file.
(LINKER, LINKER_FLAGS): If ENABLE_BUILD_WITH_CXX, but $(HOST_LIBS)
is not empty, set to $(CC) and $(CFLAGS).
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in (revision 148889)
+++ gcc/Makefile.in (working copy)
@@ -206,6 +206,9 @@ NM = @NM@
RANLIB = @RANLIB@
RANLIB_FLAGS = @ranlib_flags@
+# Libraries to use on the host.
+HOST_LIBS = @HOST_LIBS@
+
# The name of the compiler to use.
ENABLE_BUILD_WITH_CXX = @ENABLE_BUILD_WITH_CXX@
ifneq ($(ENABLE_BUILD_WITH_CXX),yes)
@@ -216,8 +219,17 @@ LINKER_FLAGS = $(CFLAGS)
else
COMPILER = $(CXX)
COMPILER_FLAGS = $(CXXFLAGS)
+# If HOST_LIBS is set, then the user is controlling the libraries to
+# link against. In that case, link with $(CC) so that the -lstdc++
+# library is not introduced. If HOST_LIBS is not set, link with
+# $(CXX) to pick up -lstdc++.
+ifeq ($(HOST_LIBS),)
LINKER = $(CXX)
LINKER_FLAGS = $(CXXFLAGS)
+else
+LINKER = $(CC)
+LINKER_FLAGS = $(CFLAGS)
+endif
endif
# -------------------------------------------
@@ -288,9 +300,6 @@ write_entries_to_file = $(shell rm -f $(
# In stage2 and beyond, we force this to "-o $@" since we know we're using gcc.
OUTPUT_OPTION = @OUTPUT_OPTION@
-# Libraries to use on the host.
-HOST_LIBS = @HOST_LIBS@
-
# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is
# -I../zlib, unless we were configured with --with-system-zlib, in which
# case both are empty.
Index: configure.ac
===================================================================
--- configure.ac (revision 148889)
+++ configure.ac (working copy)
@@ -1450,21 +1450,6 @@ AC_ARG_WITH(stage1-libs,
[stage1_libs=$with_host_libstdcxx])
AC_SUBST(stage1_libs)
-# Linker flags to use for stage2 and later builds.
-AC_ARG_WITH(boot-ldflags,
-[ --with-boot-ldflags=FLAGS Linker flags for stage2 and later],
-[if test "$withval" = "no" -o "$withval" = "yes"; then
- poststage1_ldflags=
- else
- poststage1_ldflags=$withval
- fi],
-[if test "$ENABLE_BUILD_WITH_CXX" = "yes"; then
- poststage1_ldflags=-static-libstdc++
- else
- poststage1_ldflags=
- fi])
-AC_SUBST(poststage1_ldflags)
-
# Libraries to use for stage2 and later builds. This defaults to the
# argument passed to --with-host-libstdcxx.
AC_ARG_WITH(boot-libs,
@@ -1477,6 +1462,23 @@ AC_ARG_WITH(boot-libs,
[poststage1_libs=$with_host_libstdcxx])
AC_SUBST(poststage1_libs)
+# Linker flags to use for stage2 and later builds.
+AC_ARG_WITH(boot-ldflags,
+[ --with-boot-ldflags=FLAGS Linker flags for stage2 and later],
+[if test "$withval" = "no" -o "$withval" = "yes"; then
+ poststage1_ldflags=
+ else
+ poststage1_ldflags=$withval
+ fi],
+[poststage1_ldflags=
+ # With --enable-build-with-cxx, default to linking libstdc++ and
+ # libgcc statically. But if the user explicitly specified the
+ # libraries to use, trust that they are doing what they want.
+ if test "$ENABLE_BUILD_WITH_CXX" = "yes" -a "$poststage1_libs" = ""; then
+ poststage1_ldflags="-static-libstdc++ -static-libgcc"
+ fi])
+AC_SUBST(poststage1_ldflags)
+
# Check for PPL
ppl_major_version=0
ppl_minor_version=10