This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PR bootstrap/56750] implement --disable-stage1-static-libs


In this PR, the reporter is complaining that forcing -static-libstdc++ and -static-libgcc during stage1 will also force it down to all subdirectories (gdb for instance).

There is some back and forth in the PR whether this is good or not. I'm indifferent, but an alternative is to provide a flag --disable-stage1-static-libs to disable this behavior.

Tested on an x86-64 Linux system with static libraries and verifying that with --disable-stage1-static-libs we get an xgcc linked against shared libraries of libstdc++ and libgcc:

$ ldd xgcc
        linux-vdso.so.1 (0x00007ffe92084000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fec11a06000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fec116fd000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fec114e6000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fec11120000)
        /lib64/ld-linux-x86-64.so.2 (0x0000557117206000)

I also verified that without the flag or with --enable-stage1-static-libs we get no such shared libraries.

Again, I'm agnostic here. We can just as easily close the PR and tell users to specify --with-stage1-libs to override the static linking, as I've mentioned in the PR.

OK for trunk?

	PR bootstrap/56750
	* configure.ac (stage1-static-libs): New option.
	* configure: Regenerate.

gcc/

	PR bootstrap/56750
	* doc/install.texi (--enable-stage1-static-libs): New.

diff --git a/configure.ac b/configure.ac
index aae94501e48..94b540226cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -465,6 +465,12 @@ ENABLE_LIBSTDCXX=default)
   noconfigdirs="$noconfigdirs target-libstdc++-v3"
 fi]
 
+AC_ARG_ENABLE(stage1-static-libs,
+AS_HELP_STRING([--disable-stage1-static-libs],
+  [do not statically link libstdc++ and libgcc into stage1 binaries]),
+ENABLE_STAGE1_STATIC_LIBS=$enableval,
+ENABLE_STAGE1_STATIC_LIBS=yes)
+
 # If this is accelerator compiler and its target is intelmic we enable
 # target liboffloadmic by default.  If this is compiler with offloading
 # for intelmic we enable host liboffloadmic by default.  Otherwise
@@ -1619,7 +1625,7 @@ AC_ARG_WITH(stage1-ldflags,
  # In stage 1, default to linking libstdc++ and libgcc statically with GCC
  # if supported.  But if the user explicitly specified the libraries to use,
  # trust that they are doing what they want.
- if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then
+ if test "$ENABLE_STAGE1_STATIC_LIBS" = "yes" -a "$stage1_libs" = "" -a "$have_static_libs" = yes; then
    stage1_ldflags="-static-libstdc++ -static-libgcc"
  fi])
 AC_SUBST(stage1_ldflags)
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 64ad2445a33..5567daad957 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1958,10 +1958,23 @@ include and lib options directly.
 These flags are applicable to the host platform only.  When building
 a cross compiler, they will not be used to configure target libraries.
 
+@item --enable-stage1-static-libs
+@itemx --disable-stage1-static-libs
+
+Enable linking stage1 binaries with @samp{-static-libstdc++
+-static-libgcc} if available on your system.  This also enables
+linking stage1 binaries statically when not bootstrapping.  The
+default is enabled.
+
+Even with this option enabled, static libraries will only be used when
+@option{--with-stage1-libs} is not set to a value.  See option
+@option{--with-stage1-ldflags} below.
+
 @item --with-stage1-ldflags=@var{flags}
 This option may be used to set linker flags to be used when linking
 stage 1 of GCC.  These are also used when linking GCC if configured with
-@option{--disable-bootstrap}.  If @option{--with-stage1-libs} is not set to a
+@option{--disable-bootstrap}.  If @option{--enable-stage1-static-libs}
+is enabled and @option{--with-stage1-libs} is not set to a
 value, then the default is @samp{-static-libstdc++ -static-libgcc}, if
 supported.
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]