]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Don't add crtfastmath.o for -shared
authorliuhongt <hongtao.liu@intel.com>
Thu, 15 Dec 2022 01:38:08 +0000 (09:38 +0800)
committerliuhongt <hongtao.liu@intel.com>
Mon, 19 Dec 2022 08:47:21 +0000 (16:47 +0800)
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.

gcc/config/i386/gnu-user-common.h
gcc/doc/invoke.texi

index cab9be2bfb7c25527210c49ac0035521086655ca..9910cd64363dea617d6b3d5826c8693191a7f987 100644 (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}"
index c7e88e46e2834ef57a03abbce6f1453d6e4ddf43..d8a2079760355a27058a30b5e70f486342ed8be8 100644 (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