diff mbox series

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

Message ID 4d4e66a4-73c2-50bb-48d0-9319effb6830@redhat.com
State New
Headers show
Series [PR,bootstrap/56750] implement --disable-stage1-static-libs | expand

Commit Message

Aldy Hernandez Feb. 8, 2018, 11:42 a.m. UTC
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?

Comments

Jeff Law Feb. 8, 2018, 11 p.m. UTC | #1
On 02/08/2018 04:42 AM, Aldy Hernandez wrote:
> 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?
> 
> curr.patch
> 
> 
> 
> 	PR bootstrap/56750
> 	* configure.ac (stage1-static-libs): New option.
> 	* configure: Regenerate.
> 
> gcc/
> 
> 	PR bootstrap/56750
> 	* doc/install.texi (--enable-stage1-static-libs): New.
You are a brave soul.

Every time I look at 56750 I shake my head and say it's not worth the
pain to untangle (sorry Mike).

There's no single solution here that will satisfy everyone that I'm
aware of.   Given that there is a workaround that I think will work for
the problems Mike is trying to address, I think this is a WONTFIX.
Another configury option just adds more complexity here that we're not
likely to test and is likely to bitrot over time.

Go ahead with WONTFIX and if Mike complains, point him at me :-)

jeff
Aldy Hernandez Feb. 9, 2018, 7:49 a.m. UTC | #2
On Thu, Feb 8, 2018 at 6:00 PM, Jeff Law <law@redhat.com> wrote:
> On 02/08/2018 04:42 AM, Aldy Hernandez wrote:

> You are a brave soul.

I would've preferred to close as WONTFIX from the gun, but no one
commented, so  I tried my hand at a patch :).

>
> Every time I look at 56750 I shake my head and say it's not worth the
> pain to untangle (sorry Mike).
>
> There's no single solution here that will satisfy everyone that I'm
> aware of.   Given that there is a workaround that I think will work for
> the problems Mike is trying to address, I think this is a WONTFIX.
> Another configury option just adds more complexity here that we're not
> likely to test and is likely to bitrot over time.
>
> Go ahead with WONTFIX and if Mike complains, point him at me :-)

No complaints from me.  The less overlapping options the better.

Thanks for looking at this.
Aldy
diff mbox series

Patch



	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.