Hello, This is an update and a ping to my original patch message[1].
I've attached an updated set of patches: 1) gcc48-stage1-build-libstdc++.patch: Makefile.tpl patch portion which allowed me to build GCC 4.8.3 using GCC 8.1 2) gcc82-stage1-build-libstdc++.patch: analogous patch for GCC 8.2 potentially allowing future GCC to build GCC 8.2 (untested). These patches no longer contain the generated Makefile.in diff and have a more general comment (i.e. not specific to CXXABI_1.3.9 issue cited) since this issue might be more general. Best, Matthew Krupcale [1] https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00176.html
diff --git a/Makefile.tpl b/Makefile.tpl index 3233a788d..7faf98db5 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -294,7 +294,7 @@ BASE_TARGET_EXPORTS = \ WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \ WINDMC="$(WINDMC_FOR_TARGET)"; export WINDMC; \ @if gcc-bootstrap - $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \ + $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH_BUILD_LIBSTDC++)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \ @endif gcc-bootstrap $(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \ TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; @@ -308,6 +308,17 @@ NORMAL_TARGET_EXPORTS = \ $(BASE_TARGET_EXPORTS) \ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; +# Use the target libstdc++ only after stage1 since the build libstdc++ is +# required by some stage1 host modules (e.g. cc1, cc1plus, lto1) +POSTSTAGE1_RPATH_EXPORT = \ +@if target-libstdc++-v3-bootstrap + $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH_libstdc++-v3)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); +@endif target-libstdc++-v3-bootstrap + +# Similar, for later GCC stages. +POSTSTAGE1_TARGET_EXPORTS = \ + $(POSTSTAGE1_RPATH_EXPORT) + # Where to find GMP HOST_GMPLIBS = @gmplibs@ HOST_GMPINC = @gmpinc@ @@ -531,6 +542,10 @@ all: TARGET_LIB_PATH = [+ FOR target_modules +][+ IF lib_path +]$(TARGET_LIB_PATH_[+module+])[+ ENDIF lib_path +][+ ENDFOR target_modules +]$(HOST_LIB_PATH_gcc) +# Use the build rather than the target libstdc++ +TARGET_LIB_PATH_BUILD_LIBSTDC++ = [+ FOR target_modules +][+ + IF lib_path +][+ IF (not (= (get "module") "libstdc++-v3")) +]$(TARGET_LIB_PATH_[+module+])[+ ENDIF +][+ ENDIF lib_path +][+ + ENDFOR target_modules +]$(HOST_LIB_PATH_gcc) [+ FOR target_modules +][+ IF lib_path +] @if target-[+module+] TARGET_LIB_PATH_[+module+] = $$r/$(TARGET_SUBDIR)/[+module+]/[+lib_path+]: @@ -1275,6 +1290,7 @@ maybe-[+make_target+]-[+module+]: [+make_target+]-[+module+] [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)" check_multilibs=true exports="$(RAW_CXX_TARGET_EXPORTS)" + poststage1_exports="$(POSTSTAGE1_TARGET_EXPORTS)" host_alias=(get "host" "${target_alias}") target_alias=(get "target" "${target_alias}") args="$(TARGET_CONFIGARGS)" no-config-site=true +] @@ -1286,6 +1302,7 @@ maybe-[+make_target+]-[+module+]: [+make_target+]-[+module+] [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)" check_multilibs=true exports="$(NORMAL_TARGET_EXPORTS)" + poststage1_exports="$(POSTSTAGE1_TARGET_EXPORTS)" host_alias=(get "host" "${target_alias}") target_alias=(get "target" "${target_alias}") args="$(TARGET_CONFIGARGS)" no-config-site=true +]
diff --git a/Makefile.tpl b/Makefile.tpl index 1f23b79b4..8f048efc1 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -294,7 +294,7 @@ BASE_TARGET_EXPORTS = \ WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \ WINDMC="$(WINDMC_FOR_TARGET)"; export WINDMC; \ @if gcc-bootstrap - $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \ + $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH_BUILD_LIBSTDC++)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \ @endif gcc-bootstrap $(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \ TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; @@ -308,6 +308,17 @@ NORMAL_TARGET_EXPORTS = \ $(BASE_TARGET_EXPORTS) \ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; +# Use the target libstdc++ only after stage1 since the build libstdc++ is +# required by some stage1 host modules (e.g. cc1, cc1plus, lto1) +POSTSTAGE1_RPATH_EXPORT = \ +@if target-libstdc++-v3-bootstrap + $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH_libstdc++-v3)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); +@endif target-libstdc++-v3-bootstrap + +# Similar, for later GCC stages. +POSTSTAGE1_TARGET_EXPORTS = \ + $(POSTSTAGE1_RPATH_EXPORT) + # Where to find GMP HOST_GMPLIBS = @gmplibs@ HOST_GMPINC = @gmpinc@ @@ -538,6 +549,10 @@ all: TARGET_LIB_PATH = [+ FOR target_modules +][+ IF lib_path +]$(TARGET_LIB_PATH_[+module+])[+ ENDIF lib_path +][+ ENDFOR target_modules +]$(HOST_LIB_PATH_gcc) +# Use the build rather than the target libstdc++ +TARGET_LIB_PATH_BUILD_LIBSTDC++ = [+ FOR target_modules +][+ + IF lib_path +][+ IF (not (= (get "module") "libstdc++-v3")) +]$(TARGET_LIB_PATH_[+module+])[+ ENDIF +][+ ENDIF lib_path +][+ + ENDFOR target_modules +]$(HOST_LIB_PATH_gcc) [+ FOR target_modules +][+ IF lib_path +] @if target-[+module+] TARGET_LIB_PATH_[+module+] = $$r/$(TARGET_SUBDIR)/[+module+]/[+lib_path+]: @@ -1326,6 +1341,7 @@ maybe-[+make_target+]-[+module+]: [+make_target+]-[+module+] [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)" check_multilibs=true exports="$(RAW_CXX_TARGET_EXPORTS)" + poststage1_exports="$(POSTSTAGE1_TARGET_EXPORTS)" host_alias=(get "host" "${target_alias}") target_alias=(get "target" "${target_alias}") args="$(TARGET_CONFIGARGS)" no-config-site=true +] @@ -1337,6 +1353,7 @@ maybe-[+make_target+]-[+module+]: [+make_target+]-[+module+] [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)" check_multilibs=true exports="$(NORMAL_TARGET_EXPORTS)" + poststage1_exports="$(POSTSTAGE1_TARGET_EXPORTS)" host_alias=(get "host" "${target_alias}") target_alias=(get "target" "${target_alias}") args="$(TARGET_CONFIGARGS)" no-config-site=true +]