From gcc-patches-return-423889-listarch-gcc-patches=gcc.gnu.org@gcc.gnu.org Mon Mar 28 12:44:35 2016 From: Bernd Edlinger To: "gcc-patches@gcc.gnu.org" , Richard Biener CC: Marc Glisse Subject: [PATCH] Fix in-tree gmp/mpfr/mpc generation (PR 67728) Date: Mon, 28 Mar 2016 12:44:16 +0000 Message-ID: Hi, as described in the tracker we have bootstrap problems with in-tree gmp-6.1.0 on certain targets, and also a linker issue with check-mpc due to the changed mpfr library path. These are triggered by overriding CFLAGS and LDFLAGS in in-tree builds. It did not happen with the gmp/mpfr/mpc versions that download_prerequisites installs, but the currently latest version of these libraries use CFLAGS to pass -DNO_ASM which is overridden by gcc and causes the gmp-6.1.0 to be mis-compiled. And the mpc issue is triggered by overriding LDFLAGS and the changed mpfr library path. So this started with mpfr v3.1.0 which moved the sources into a src sub-directory. The proposed patch fixes these problems by passing -DNO_ASM in AM_CFLAGS, and adding both possible mpfr library paths to HOST_LIB_PATH_mpfr. I've also adjusted HOST_LIB_PATH_mpc although it did not yet create problems. Boot-strapped and regression tested on x86_64-pc-linux-gnu, with different gmp versions including the latest snapshot. I have additionally built arm cross compilers, which was not working before. Is this OK for trunk? Thanks Bernd. --- gcc-4.9.1/Makefile.def.orig 2014-04-05 05:53:48.000000000 +0900 +++ gcc-4.9.1/Makefile.def 2016-03-28 21:44:16.000000000 +0900 @@ -47,6 +47,7 @@ host_modules= { module= gcc; bootstrap=t extra_make_flags="$(EXTRA_GCC_FLAGS)"; }; host_modules= { module= gmp; lib_path=.libs; bootstrap=true; extra_configure_flags='--disable-shared'; + extra_make_flags='AM_CFLAGS="-DNO_ASM"'; no_install= true; // none-*-* disables asm optimizations, bootstrap-testing // the compiler more thoroughly. @@ -54,10 +55,10 @@ host_modules= { module= gmp; lib_path=.l // gmp's configure will complain if given anything // different from host for target. target="none-${host_vendor}-${host_os}"; }; -host_modules= { module= mpfr; lib_path=.libs; bootstrap=true; +host_modules= { module= mpfr; lib_path=.libs; lib_path2=src/.libs; bootstrap=true; extra_configure_flags='--disable-shared @extra_mpfr_configure_flags@'; no_install= true; }; -host_modules= { module= mpc; lib_path=.libs; bootstrap=true; +host_modules= { module= mpc; lib_path=src/.libs; bootstrap=true; extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@'; no_install= true; }; host_modules= { module= isl; lib_path=.libs; bootstrap=true; --- gcc-4.9.1/Makefile.in.orig 2014-04-05 05:53:48.000000000 +0900 +++ gcc-4.9.1/Makefile.in 2016-03-28 21:44:16.000000000 +0900 @@ -630,12 +630,12 @@ HOST_LIB_PATH_gmp = \ @if mpfr HOST_LIB_PATH_mpfr = \ - $$r/$(HOST_SUBDIR)/mpfr/.libs:$$r/$(HOST_SUBDIR)/prev-mpfr/.libs: + $$r/$(HOST_SUBDIR)/mpfr/src/.libs:$$r/$(HOST_SUBDIR)/mpfr/.libs:$$r/$(HOST_SUBDIR)/prev-mpfr/.libs: @endif mpfr @if mpc HOST_LIB_PATH_mpc = \ - $$r/$(HOST_SUBDIR)/mpc/.libs:$$r/$(HOST_SUBDIR)/prev-mpc/.libs: + $$r/$(HOST_SUBDIR)/mpc/src/.libs:$$r/$(HOST_SUBDIR)/prev-mpc/src/.libs: @endif mpc @if isl @@ -11094,7 +11094,7 @@ all-gmp: configure-gmp s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ (cd $(HOST_SUBDIR)/gmp && \ - $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \ + $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \ $(TARGET-gmp)) @endif gmp @@ -11123,7 +11123,7 @@ all-stage1-gmp: configure-stage1-gmp CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \ LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \ $(EXTRA_HOST_FLAGS) \ - $(STAGE1_FLAGS_TO_PASS) \ + $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \ TFLAGS="$(STAGE1_TFLAGS)" \ $(TARGET-stage1-gmp) @@ -11138,7 +11138,7 @@ clean-stage1-gmp: fi; \ cd $(HOST_SUBDIR)/gmp && \ $(MAKE) $(EXTRA_HOST_FLAGS) \ - $(STAGE1_FLAGS_TO_PASS) clean + $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean @endif gmp-bootstrap @@ -11165,7 +11165,7 @@ all-stage2-gmp: configure-stage2-gmp CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \ LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \ - $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \ + $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \ TFLAGS="$(STAGE2_TFLAGS)" \ $(TARGET-stage2-gmp) @@ -11179,7 +11179,7 @@ clean-stage2-gmp: $(MAKE) stage2-start; \ fi; \ cd $(HOST_SUBDIR)/gmp && \ - $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean + $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean @endif gmp-bootstrap @@ -11206,7 +11206,7 @@ all-stage3-gmp: configure-stage3-gmp CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \ LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \ - $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \ + $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \ TFLAGS="$(STAGE3_TFLAGS)" \ $(TARGET-stage3-gmp) @@ -11220,7 +11220,7 @@ clean-stage3-gmp: $(MAKE) stage3-start; \ fi; \ cd $(HOST_SUBDIR)/gmp && \ - $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean + $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean @endif gmp-bootstrap @@ -11247,7 +11247,7 @@ all-stage4-gmp: configure-stage4-gmp CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \ LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \ - $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \ + $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \ TFLAGS="$(STAGE4_TFLAGS)" \ $(TARGET-stage4-gmp) @@ -11261,7 +11261,7 @@ clean-stage4-gmp: $(MAKE) stage4-start; \ fi; \ cd $(HOST_SUBDIR)/gmp && \ - $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean + $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean @endif gmp-bootstrap @@ -11288,7 +11288,7 @@ all-stageprofile-gmp: configure-stagepro CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \ LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \ - $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \ + $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \ TFLAGS="$(STAGEprofile_TFLAGS)" \ $(TARGET-stageprofile-gmp) @@ -11302,7 +11302,7 @@ clean-stageprofile-gmp: $(MAKE) stageprofile-start; \ fi; \ cd $(HOST_SUBDIR)/gmp && \ - $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean + $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean @endif gmp-bootstrap @@ -11329,7 +11329,7 @@ all-stagefeedback-gmp: configure-stagefe CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \ LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \ - $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \ + $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \ TFLAGS="$(STAGEfeedback_TFLAGS)" \ $(TARGET-stagefeedback-gmp) @@ -11343,7 +11343,7 @@ clean-stagefeedback-gmp: $(MAKE) stagefeedback-start; \ fi; \ cd $(HOST_SUBDIR)/gmp && \ - $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean + $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean @endif gmp-bootstrap @@ -11361,7 +11361,7 @@ check-gmp: s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ (cd $(HOST_SUBDIR)/gmp && \ - $(MAKE) $(FLAGS_TO_PASS) check) + $(MAKE) $(FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" check) @endif gmp @@ -11396,7 +11396,7 @@ info-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing info in gmp" ; \ @@ -11421,7 +11421,7 @@ dvi-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing dvi in gmp" ; \ @@ -11446,7 +11446,7 @@ pdf-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing pdf in gmp" ; \ @@ -11471,7 +11471,7 @@ html-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing html in gmp" ; \ @@ -11496,7 +11496,7 @@ TAGS-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing TAGS in gmp" ; \ @@ -11522,7 +11522,7 @@ install-info-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing install-info in gmp" ; \ @@ -11548,7 +11548,7 @@ install-pdf-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing install-pdf in gmp" ; \ @@ -11574,7 +11574,7 @@ install-html-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing install-html in gmp" ; \ @@ -11599,7 +11599,7 @@ installcheck-gmp: \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing installcheck in gmp" ; \ @@ -11623,7 +11623,7 @@ mostlyclean-gmp: r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing mostlyclean in gmp" ; \ @@ -11647,7 +11647,7 @@ clean-gmp: r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing clean in gmp" ; \ @@ -11671,7 +11671,7 @@ distclean-gmp: r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing distclean in gmp" ; \ @@ -11695,7 +11695,7 @@ maintainer-clean-gmp: r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(HOST_EXPORTS) \ - for flag in $(EXTRA_HOST_FLAGS) ; do \ + for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ done; \ echo "Doing maintainer-clean in gmp" ; \ --- gcc-4.9.1/Makefile.tpl.orig 2014-03-07 21:58:27.000000000 +0900 +++ gcc-4.9.1/Makefile.tpl 2016-03-28 21:44:16.000000000 +0900 @@ -554,7 +554,8 @@ HOST_LIB_PATH_gcc = $$r/$(HOST_SUBDIR)/g [+ FOR host_modules +][+ IF lib_path +] @if [+module+] HOST_LIB_PATH_[+module+] = \ - $$r/$(HOST_SUBDIR)/[+module+]/[+lib_path+]:[+ IF bootstrap + [+ IF lib_path2 +]$$r/$(HOST_SUBDIR)/[+module+]/[+lib_path2+]:[+ ENDIF + lib_path2 +]$$r/$(HOST_SUBDIR)/[+module+]/[+lib_path+]:[+ IF bootstrap +]$$r/$(HOST_SUBDIR)/prev-[+module+]/[+lib_path+]:[+ ENDIF bootstrap +] @endif [+module+] [+ ENDIF lib_path +][+ ENDFOR host_modules +]