x86: Don't add crtfastmath.o for -shared

Don't add crtfastmath.o for -shared to avoid changing the MXCSR register
when loading a shared library.  crtfastmath.o will be used only when
building executables.

	PR target/55522
	* config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC):
	Don't add crtfastmath.o for -shared.
	* doc/invoke.texi (-shared): Add related documentation.
This commit is contained in:
liuhongt 2022-12-15 09:38:08 +08:00
parent e433739862
commit 88b531d032
2 changed files with 3 additions and 2 deletions

View file

@ -47,7 +47,7 @@ along with GCC; see the file COPYING3. If not see
/* Similar to standard GNU userspace, but adding -ffast-math support. */
#define GNU_USER_TARGET_MATHFILE_SPEC \
"%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
"%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
%{mpc80:crtprec80.o%s}"

View file

@ -17693,7 +17693,8 @@ needs to build supplementary stub code for constructors to work. On
multi-libbed systems, @samp{gcc -shared} must select the correct support
libraries to link against. Failing to supply the correct flags may lead
to subtle defects. Supplying them in cases where they are not necessary
is innocuous.}
is innocuous. For x86, crtfastmath.o will not be added when
@option{-shared} is specified. }
@item -shared-libgcc
@itemx -static-libgcc