My long-term goal is to get all "libsubdir" and similar logic out of the build systems for the runtime libraries themselves, and instead move it to the "meta build system". The idea is the runtime library builds shouldn't just be given the locations they are to install stuff in, and don't need to know or care how those locations were calculated --- it is just better separation of concerns.
Another motivation is for the new Nixpkgs packaging of GCC I am working on. Nix already installs everything to separate prefixes, so the libsubdir logic that GCC is doing is redundant --- we already have no conflicts by construction and are passing many -B flags to make things go anyways. This separation of concerns makes it easier to build runtime libraries (which are already doing separately in the new packaging) with "normal" libdir/subdir. This current patch doesn't go as far as removing all such subdir logic from the libgcc build --- rather, as an intermediate goal, it moves it out of the Makefiles and into the configure script. That is to say, in the makefiles there is no longer any more libsubdir, and everything just uses libdir/includedir, while in the configure script, the original libdir is assigned to a temporary (non-substituted) org_libdir variable, and then libdir and includedir are redefined to be the proper subdirs of org_libdir. For what it's worth, this intermediate goal does match how slibdir, toolexecdir, and toolexeclibdir are also calculated in the configure script from flags and "standard" autoconf directory variables. So even though the main goal is not fully realized, I do think the patch is already lending the build system a bit more consistency as an added benefit. libgcc/ChangeLog: * Makefile.in: Use regular libdir/includedir, no more libsubdir etc. * config/t-slibgcc-vms: Use regular libdir, no more libsubdir. * configure: Regenerate. * configure.ac: Stash away the passed libdir as orig_libdir, and define libdir and includedir to matches what Makefile.in use to do. Signed-off-by: John Ericson <g...@johnericson.me> --- libgcc/Makefile.in | 17 +++++++---------- libgcc/config/t-slibgcc-vms | 2 +- libgcc/configure | 19 ++++++++++--------- libgcc/configure.ac | 17 ++++++++++------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index f7b48dceb06..3a6e31543fd 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -31,6 +31,7 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ libdir = @libdir@ shlib_slibdir = @slibdir@ +includedir= @includedir@ SHELL = @SHELL@ @@ -53,7 +54,6 @@ sfp_machine_header = @sfp_machine_header@ thread_header = @thread_header@ host_noncanonical = @host_noncanonical@ -real_host_noncanonical = @real_host_noncanonical@ target_noncanonical = @target_noncanonical@ # List of extra object files that should be compiled for this target machine. @@ -109,7 +109,7 @@ FLAGS_TO_PASS = \ "prefix=$(prefix)" \ "exec_prefix=$(exec_prefix)" \ "libdir=$(libdir)" \ - "libsubdir=$(libsubdir)" \ + "includedir=$(includedir)" \ "tooldir=$(tooldir)" # Dependencies for "all" are set later in the file. @@ -199,8 +199,6 @@ RANLIB_FOR_TARGET = $(RANLIB) STRIP = @STRIP@ STRIP_FOR_TARGET = $(STRIP) -# Directory in which the compiler finds libraries etc. -libsubdir = $(libdir)/gcc/$(real_host_noncanonical)/$(version)@accel_dir_suffix@ # Used to install the shared libgcc. slibdir = @slibdir@ # Maybe used for DLLs on Windows targets. @@ -222,7 +220,6 @@ export LIPO_FOR_TARGET export NM_FOR_TARGET export STRIP_FOR_TARGET export RANLIB_FOR_TARGET -export libsubdir export slibdir export toolexecdir export toolexeclibdir @@ -310,7 +307,7 @@ MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory) MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory) MULTIOSSUBDIR := $(shell if test "$(MULTIOSDIR)" != .; then echo /$(MULTIOSDIR); fi) -inst_libdir = $(libsubdir)$(MULTISUBDIR) +inst_libdir = $(libdir)$(MULTISUBDIR) inst_slibdir = $(slibdir)$(MULTIOSSUBDIR) gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS) $(CFLAGS-$(<F)) @@ -1137,14 +1134,14 @@ install-unwind_h-forbuild: unwind.h # This is however useful for "install-no-fixincludes" case, when only the gcc # internal headers are copied by gcc's install. install-unwind_h: - $(mkinstalldirs) $(DESTDIR)$(libsubdir)/include - $(INSTALL_DATA) unwind.h $(DESTDIR)$(libsubdir)/include + $(mkinstalldirs) $(DESTDIR)$(includedir) + $(INSTALL_DATA) unwind.h $(DESTDIR)$(includedir) all: install-unwind_h-forbuild install-gcov_h: - $(mkinstalldirs) $(DESTDIR)$(libsubdir)/include - $(INSTALL_DATA) $(srcdir)/gcov.h $(DESTDIR)$(libsubdir)/include + $(mkinstalldirs) $(DESTDIR)$(includedir) + $(INSTALL_DATA) $(srcdir)/gcov.h $(DESTDIR)$(includedir) # Documentation targets (empty). .PHONY: info html dvi pdf install-info install-html install-pdf diff --git a/libgcc/config/t-slibgcc-vms b/libgcc/config/t-slibgcc-vms index c3059758752..8274d24360f 100644 --- a/libgcc/config/t-slibgcc-vms +++ b/libgcc/config/t-slibgcc-vms @@ -5,7 +5,7 @@ SHLIB_EXT = .exe SHLIB_OBJS = @shlib_objs@ SHLIB_NAME = @shlib_base_name@.exe SHLIB_MULTILIB = -SHLIB_INSTALL = $(INSTALL_DATA) $(SHLIB_NAME) $(DESTDIR)$(libsubdir)/$(SHLIB_NAME) +SHLIB_INSTALL = $(INSTALL_DATA) $(SHLIB_NAME) $(DESTDIR)$(libdir)/$(SHLIB_NAME) SHLIB_SYMVEC = \ grep -F -e "\$$BSS\$$" -e "\$$DATA\$$" -e " sdata " -e " data.rel " -e " data.rel.ro " -e " sbss " \ -e "\$$LINK\$$" -e "\$$READONLY\$$" | \ diff --git a/libgcc/configure b/libgcc/configure index 18418336c9b..cc84f52529e 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -604,8 +604,6 @@ set_use_emutls set_have_cc_tls vis_hide solaris_ld_v2_maps -real_host_noncanonical -accel_dir_suffix use_tm_clone_registry force_explicit_eh_registry CET_FLAGS @@ -2461,6 +2459,8 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5 $as_echo "$version_specific_libs" >&6; } +orig_libdir=$libdir + # Check whether --with-toolexeclibdir was given. if test "${with_toolexeclibdir+set}" = set; then : @@ -2483,7 +2483,7 @@ if test "${with_slibdir+set}" = set; then : withval=$with_slibdir; slibdir="$with_slibdir" else if test "${version_specific_libs}" = yes; then - slibdir='$(libsubdir)' + slibdir='$(libdir)' elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then case ${with_toolexeclibdir} in no) @@ -2494,7 +2494,7 @@ elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then ;; esac else - slibdir='$(libdir)' + slibdir=$orig_libdir fi fi @@ -2730,7 +2730,7 @@ case ${version_specific_libs} in # Need the gcc compiler version to know where to install libraries # and header files if --enable-version-specific-runtime-libs option # is selected. - toolexecdir='$(libdir)/gcc/$(target_noncanonical)' + toolexecdir=$orig_libdir'/gcc/$(target_noncanonical)' toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' ;; no) @@ -2747,8 +2747,8 @@ case ${version_specific_libs} in ;; esac else - toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)' - toolexeclibdir='$(libdir)' + toolexecdir=$orig_libdir'/gcc-lib/$(target_noncanonical)' + toolexeclibdir=$orig_libdir fi multi_os_directory=`$CC -print-multi-os-directory` case $multi_os_directory in @@ -5291,8 +5291,9 @@ if test x"$enable_as_accelerator_for" != x; then accel_dir_suffix=/accel/${target_noncanonical} real_host_noncanonical=${enable_as_accelerator_for} fi - - +# Directory in which the compiler finds libraries etc. +libdir=${orig_libdir}/gcc/${real_host_noncanonical}/'$(version)'${accel_dir_suffix} +includedir=${libdir}/include if test x"$enable_offload_targets" != x; then extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o" diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 85e4f1bc48b..5fdac5d95f2 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -109,13 +109,15 @@ AC_ARG_ENABLE(version-specific-runtime-libs, [version_specific_libs=no]) AC_MSG_RESULT($version_specific_libs) +orig_libdir=$libdir + GCC_WITH_TOOLEXECLIBDIR AC_ARG_WITH(slibdir, [ --with-slibdir=DIR shared libraries in DIR [LIBDIR]], slibdir="$with_slibdir", [if test "${version_specific_libs}" = yes; then - slibdir='$(libsubdir)' + slibdir='$(libdir)' elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then case ${with_toolexeclibdir} in no) @@ -126,7 +128,7 @@ elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then ;; esac else - slibdir='$(libdir)' + slibdir=$orig_libdir fi]) AC_SUBST(slibdir) @@ -177,7 +179,7 @@ case ${version_specific_libs} in # Need the gcc compiler version to know where to install libraries # and header files if --enable-version-specific-runtime-libs option # is selected. - toolexecdir='$(libdir)/gcc/$(target_noncanonical)' + toolexecdir=$orig_libdir'/gcc/$(target_noncanonical)' toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' ;; no) @@ -194,8 +196,8 @@ case ${version_specific_libs} in ;; esac else - toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)' - toolexeclibdir='$(libdir)' + toolexecdir=$orig_libdir'/gcc-lib/$(target_noncanonical)' + toolexeclibdir=$orig_libdir fi multi_os_directory=`$CC -print-multi-os-directory` case $multi_os_directory in @@ -477,8 +479,9 @@ if test x"$enable_as_accelerator_for" != x; then accel_dir_suffix=/accel/${target_noncanonical} real_host_noncanonical=${enable_as_accelerator_for} fi -AC_SUBST(accel_dir_suffix) -AC_SUBST(real_host_noncanonical) +# Directory in which the compiler finds libraries etc. +libdir=${orig_libdir}/gcc/${real_host_noncanonical}/'$(version)'${accel_dir_suffix} +includedir=${libdir}/include if test x"$enable_offload_targets" != x; then extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o" -- 2.47.2