From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 7D49B3851C3C for ; Thu, 2 Sep 2021 15:50:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D49B3851C3C Received: by mail-pl1-x62c.google.com with SMTP id c5so569481plz.2 for ; Thu, 02 Sep 2021 08:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wJHs4R0fak7zjvP+hLnraIiv2VeGhm41hKLgXj9tijc=; b=a4D234dRfYfs2OzBMe5tpd/Xh2MJeVNS3dt3Yp/Jt1ltTqO/nsEsMyGhzN26UtJsDr xf2qwNgcCFFljvU39KpfKSuDFvhZ32/CB43u4LGZHsh3cYLxDCb5iJwFsLv+ZCR+M0Ke mE3bbIDtruLLEkSJevvVvrVvYnUZwyiBT7zjyy7ciQjrx0qJMJK+51/Eb2NbewxPaloK m/2C0FXGL0js0cssxXTeK+Div98NEF5gTPd1z3qZzsRQ7w3Wn2U7t+HOdl6/yHBZYxxy vcDVdP+M0jE2KktiyfbOFP7Y1WQIXh9rUit1miHWcAUhUMTbd3dfmX0zL1Eo6/LFgTQg kFRg== X-Gm-Message-State: AOAM531Uk5DLsUEzVRJf1FRfTfh16vdBKWodvrfoDsl2YtMWQOXyyPeo AKo/qXCyV8S7AcNg1QZb5Cj8ZiVNzBU= X-Google-Smtp-Source: ABdhPJwcpmr0oSJiJTip+GruhLCBqSl0LyWpEhodCX8OycaOoH5kCx8LDpYO8N9r9i4UePjL/HYDUg== X-Received: by 2002:a17:90a:3cc6:: with SMTP id k6mr4525285pjd.134.1630597847102; Thu, 02 Sep 2021 08:50:47 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id g16sm2930945pfj.19.2021.09.02.08.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 08:50:46 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 80DDCC05D5; Thu, 2 Sep 2021 08:50:45 -0700 (PDT) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Jeff Law , Jakub Jelinek , DJ Delorie , Xi Ruoyao , Richard Biener Subject: [PATCH v2 3/4] libffi: Integrate build with GCC Date: Thu, 2 Sep 2021 08:50:44 -0700 Message-Id: <20210902155045.2620513-4-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902155045.2620513-1-hjl.tools@gmail.com> References: <20210902155045.2620513-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3031.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2021 15:50:59 -0000 1. Integrate with GCC build. 2. Disable static trampolines by default. 3. Support multilib. * Makefile.am (AUTOMAKE_OPTIONS): Add info-in-builddir. (ACLOCAL_AMFLAGS): Set to -I .. -I ../config. (SUBDIRS): Don't add doc. (TEXINFO_TEX): New. (MAKEINFOFLAGS): Likewise. (info_TEXINFOS): Likewise. (STAMP_GENINSRC): Likewise. (STAMP_BUILD_INFO): Likewise. (all-local): Likewise. (stamp-geninsrc): Likewise. (doc/libffi.info): Likewise. (stamp-build-info:): Likewise. (CLEANFILES): Likewise. (MAINTAINERCLEANFILES): Likewise. (AM_MAKEFLAGS): Likewise. (all-recursive): Likewise. (install-recursive): Likewise. (mostlyclean-recursive): Likewise. (clean-recursive): Likewise. (distclean-recursive): Likewise. (maintainer-clean-recursive): Likewise. (LTLDFLAGS): Replace libtool-ldflags with ../libtool-ldflags. (AM_CFLAGS): Add -g -fexceptions. (libffi.map-sun): Replace make_sunver.pl with ../contrib/make_sunver.pl. (dist-hook): Removed. Include $(top_srcdir)/../multilib.am. * configure.ac: Add AM_ENABLE_MULTILIB. Remove the frv*-elf check. (AX_ENABLE_BUILDDIR): Removed. (AM_INIT_AUTOMAKE): Add [no-dist]. Add --enable-generated-files-in-srcdir. (C_CONFIG_MACRO_DIR): Removed. (AX_COMPILER_VENDOR): Likewise. (AX_CC_MAXOPT): Likewise. (AX_CFLAGS_WARN_ALL): Likewise. Remove the GCC check. (SYMBOL_UNDERSCORE): Removed. (AX_CHECK_COMPILE_FLAG): Likewise. Remove --disable-docs. (ACX_CHECK_PROG_VER): Check makeinfo. (BUILD_DOCS): Updated. (exec-static-tramp): Don't enable use of static exec trampolines by default. Remove --disable-multi-os-directory. (GCC_WITH_TOOLEXECLIBDIR): New. Support cross host. Support --enable-multilib. * include/Makefile.am (nodist_include_HEADERS): Removed. (gcc_version): New. (toollibffidir): Likewise. (toollibffi_HEADERS): Likewise. * Makefile.in: Regenerate. (GCC_BASE_VER): New. (AC_CONFIG_FILES): Remove doc/Makefile. (AC_CONFIG_LINKS): New. * aclocal.m4: Likewise. * configure: Likewise. * fficonfig.h.in: Likewise. * mdate-sh: Likewise. * include/Makefile.in: Likewise. * man/Makefile.in: Likewise. * testsuite/Makefile.in: Likewise. --- libffi/Makefile.am | 116 +- libffi/Makefile.in | 1963 ++++ libffi/aclocal.m4 | 1202 ++ libffi/configure | 19584 +++++++++++++++++++++++++++++++++ libffi/configure.ac | 130 +- libffi/fficonfig.h.in | 227 + libffi/include/Makefile.am | 6 +- libffi/include/Makefile.in | 566 + libffi/man/Makefile.in | 516 + libffi/mdate-sh | 224 + libffi/testsuite/Makefile.in | 606 + 11 files changed, 25054 insertions(+), 86 deletions(-) create mode 100644 libffi/Makefile.in create mode 100644 libffi/aclocal.m4 create mode 100755 libffi/configure create mode 100644 libffi/fficonfig.h.in create mode 100644 libffi/include/Makefile.in create mode 100644 libffi/man/Makefile.in create mode 100755 libffi/mdate-sh create mode 100644 libffi/testsuite/Makefile.in diff --git a/libffi/Makefile.am b/libffi/Makefile.am index 1b18198ad18..02e36176c67 100644 --- a/libffi/Makefile.am +++ b/libffi/Makefile.am @@ -1,18 +1,10 @@ ## Process this with automake to create Makefile.in -AUTOMAKE_OPTIONS = foreign subdir-objects +AUTOMAKE_OPTIONS = foreign subdir-objects info-in-builddir -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I .. -I ../config SUBDIRS = include testsuite man -if BUILD_DOCS -## This hack is needed because it doesn't seem possible to make a -## conditional info_TEXINFOS in Automake. At least Automake 1.14 -## either gives errors -- if this attempted in the most -## straightforward way -- or simply unconditionally tries to build the -## info file. -SUBDIRS += doc -endif EXTRA_DIST = LICENSE ChangeLog.old \ m4/libtool.m4 m4/lt~obsolete.m4 \ @@ -26,6 +18,90 @@ EXTRA_DIST = LICENSE ChangeLog.old \ # local.exp is generated by configure DISTCLEANFILES = local.exp +# Automake Documentation: +# If your package has Texinfo files in many directories, you can use the +# variable TEXINFO_TEX to tell Automake where to find the canonical +# `texinfo.tex' for your package. The value of this variable should be +# the relative path from the current `Makefile.am' to `texinfo.tex'. +TEXINFO_TEX = ../gcc/doc/include/texinfo.tex + +# Defines info, dvi, pdf and html targets +MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include +info_TEXINFOS = doc/libffi.texi + +# AM_CONDITIONAL on configure option --generated-files-in-srcdir +if GENINSRC +STAMP_GENINSRC = stamp-geninsrc +else +STAMP_GENINSRC = +endif + +# AM_CONDITIONAL on configure check ACX_CHECK_PROG_VER([MAKEINFO]) +if BUILD_DOCS +STAMP_BUILD_INFO = stamp-build-info +else +STAMP_BUILD_INFO = +endif + +all-local: $(STAMP_GENINSRC) + +stamp-geninsrc: doc/libffi.info + cp -p $(top_builddir)/doc/libffi.info $(srcdir)/doc/libffi.info + @touch $@ + +doc/libffi.info: $(STAMP_BUILD_INFO) + +stamp-build-info: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp) + $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)/doc -o doc/libffi.info $(srcdir)/doc/libffi.texi + @touch $@ + +CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) +MAINTAINERCLEANFILES = $(srcdir)/doc/libffi.info + +## ################################################################ + +## +## This section is for make and multilib madness. +## + +# Work around what appears to be a GNU make bug handling MAKEFLAGS +# values defined in terms of make variables, as is the case for CC and +# friends when we are called from the top level Makefile. +AM_MAKEFLAGS = \ + "AR_FLAGS=$(AR_FLAGS)" \ + "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ + "CFLAGS=$(CFLAGS)" \ + "CXXFLAGS=$(CXXFLAGS)" \ + "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ + "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \ + "JC1FLAGS=$(JC1FLAGS)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ + "MAKE=$(MAKE)" \ + "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ + "PICFLAG=$(PICFLAG)" \ + "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \ + "RUNTESTFLAGS=$(RUNTESTFLAGS)" \ + "SHELL=$(SHELL)" \ + "exec_prefix=$(exec_prefix)" \ + "infodir=$(infodir)" \ + "libdir=$(libdir)" \ + "mandir=$(mandir)" \ + "prefix=$(prefix)" \ + "AR=$(AR)" \ + "AS=$(AS)" \ + "CC=$(CC)" \ + "CXX=$(CXX)" \ + "LD=$(LD)" \ + "NM=$(NM)" \ + "RANLIB=$(RANLIB)" \ + "DESTDIR=$(DESTDIR)" + # Subdir rules rely on $(FLAGS_TO_PASS) FLAGS_TO_PASS = $(AM_MAKEFLAGS) @@ -104,9 +180,9 @@ libffi_convenience_la_LIBADD = $(libffi_la_LIBADD) libffi_convenience_la_DEPENDENCIES = $(libffi_la_DEPENDENCIES) nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) -LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) +LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) -AM_CFLAGS = +AM_CFLAGS = -Wall -g -fexceptions if FFI_DEBUG # Build debug. Define FFI_DEBUG on the commandline so that, when building with # MSVC, it can link against the debug CRT. @@ -121,9 +197,9 @@ endif if LIBFFI_BUILD_VERSIONED_SHLIB_SUN libffi_version_script = -Wl,-M,libffi.map-sun libffi_version_dep = libffi.map-sun -libffi.map-sun : libffi.map $(top_srcdir)/make_sunver.pl \ +libffi.map-sun : libffi.map $(top_srcdir)/../contrib/make_sunver.pl \ $(libffi_la_OBJECTS) $(libffi_la_LIBADD) - perl $(top_srcdir)/make_sunver.pl libffi.map \ + perl $(top_srcdir)/../contrib/make_sunver.pl libffi.map \ `echo $(libffi_la_OBJECTS) $(libffi_la_LIBADD) | \ sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \ > $@ || (rm -f $@ ; exit 1) @@ -144,8 +220,12 @@ libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep) AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src AM_CCASFLAGS = $(AM_CPPFLAGS) -dist-hook: - d=`(cd $(distdir); pwd)`; (cd doc; make pdf; cp *.pdf $$d/doc) - if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog - s=`awk '/was released on/{ print NR; exit}' $(top_srcdir)/README.md`; tail -n +$$(($$s-1)) $(top_srcdir)/README.md > $(distdir)/README.md +# Multilib support. Automake should provide these on its own. +all-recursive: all-multi +install-recursive: install-multi +mostlyclean-recursive: mostlyclean-multi +clean-recursive: clean-multi +distclean-recursive: distclean-multi +maintainer-clean-recursive: maintainer-clean-multi +include $(top_srcdir)/../multilib.am diff --git a/libffi/configure.ac b/libffi/configure.ac index 70f6d2c2ea4..bff5a1e7189 100644 --- a/libffi/configure.ac +++ b/libffi/configure.ac @@ -5,18 +5,30 @@ AC_PREREQ(2.68) AC_INIT([libffi], [3.4.2], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) +AM_ENABLE_MULTILIB(, ..) + AC_CANONICAL_SYSTEM target_alias=${target_alias-$host_alias} -case "${host}" in - frv*-elf) - LDFLAGS=`echo $LDFLAGS | sed "s/\-B[^ ]*libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/ - ;; -esac - -AX_ENABLE_BUILDDIR - -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([no-dist]) + +# We would like our source tree to be readonly. However when releases or +# pre-releases are generated, the flex/bison generated files as well as the +# various formats of manuals need to be included along with the rest of the +# sources. Therefore we have --enable-generated-files-in-srcdir to do +# just that. +AC_MSG_CHECKING(generated-files-in-srcdir) +AC_ARG_ENABLE(generated-files-in-srcdir, +AS_HELP_STRING([--enable-generated-files-in-srcdir], + [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]), +[case "$enableval" in + yes) enable_generated_files_in_srcdir=yes ;; + no) enable_generated_files_in_srcdir=no ;; + *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; + esac], +[enable_generated_files_in_srcdir=no]) +AC_MSG_RESULT($enable_generated_files_in_srcdir) +AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes) # The same as in boehm-gc and libstdc++. Have to borrow it from there. # We must force CC to /not/ be precious variables; otherwise @@ -39,25 +51,12 @@ AC_SUBST(CFLAGS) AM_PROG_AS AM_PROG_CC_C_O AC_PROG_LIBTOOL -AC_CONFIG_MACRO_DIR([m4]) AC_CHECK_TOOL(READELF, readelf) # Test for 64-bit build. AC_CHECK_SIZEOF([size_t]) -AX_COMPILER_VENDOR -AX_CC_MAXOPT -# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro -# compiler. -if test "$ax_cv_c_compiler_vendor" != "sun"; then - AX_CFLAGS_WARN_ALL -fi - -if test "x$GCC" = "xyes"; then - CFLAGS="$CFLAGS -fexceptions" -fi - cat > local.exp < conftest.c - if $CC $CFLAGS -c -fpic -fexceptions $libffi_cv_no_lto -o conftest.o conftest.c > /dev/null 2>&1; then + if $CC $CFLAGS -c -fpic -fexceptions -fno-lto -o conftest.o conftest.c > /dev/null 2>&1; then if $READELF -WS conftest.o | grep -q -n 'eh_frame .* WA'; then libffi_cv_ro_eh_frame=no fi @@ -306,12 +298,12 @@ if test "x$GCC" = "xyes"; then fi fi -AC_ARG_ENABLE(docs, - AC_HELP_STRING([--disable-docs], - [Disable building of docs (default: no)]), - [enable_docs=no], - [enable_docs=yes]) -AM_CONDITIONAL(BUILD_DOCS, [test x$enable_docs = xyes]) +# See if makeinfo has been installed and is modern enough +# that we can use it. +ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version], + [GNU texinfo.* \([0-9][0-9.]*\)], + [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*]) +AM_CONDITIONAL(BUILD_DOCS, test $gcc_cv_prog_makeinfo_modern = "yes") AH_BOTTOM([ #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE @@ -367,9 +359,9 @@ AC_ARG_ENABLE(raw-api, fi) AC_ARG_ENABLE(exec-static-tramp, -[ --disable-exec-static-tramp disable use of static exec trampolines (enabled by default)]) +[ --enable-exec-static-tramp enable use of static exec trampolines]) -if test "$enable_exec_static_tramp" != no; then +if test "$enable_exec_static_tramp" = yes; then case "$target" in *-cygwin*) ;; @@ -386,47 +378,51 @@ AC_ARG_ENABLE(purify-safety, AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.]) fi) -AC_ARG_ENABLE(multi-os-directory, -[ --disable-multi-os-directory - disable use of gcc --print-multi-os-directory to change the library installation directory]) - -# These variables are only ever used when we cross-build to X86_WIN32. -# And we only support this with GCC, so... -if test "x$GCC" = "xyes"; then - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - toolexecdir='${exec_prefix}'/'$(target_alias)' - toolexeclibdir='${toolexecdir}'/lib - else - toolexecdir='${libdir}'/gcc-lib/'$(target_alias)' - toolexeclibdir='${libdir}' - fi - if test x"$enable_multi_os_directory" != x"no"; then - multi_os_directory=`$CC $CFLAGS -print-multi-os-directory` - case $multi_os_directory in - .) ;; # Avoid trailing /. - ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; - esac - fi - AC_SUBST(toolexecdir) +GCC_WITH_TOOLEXECLIBDIR + +if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + toolexecdir='$(exec_prefix)/$(target_alias)' + case ${with_toolexeclibdir} in + no) + toolexeclibdir='$(toolexecdir)/lib' + ;; + *) + toolexeclibdir=${with_toolexeclibdir} + ;; + esac else - toolexeclibdir='${libdir}' + toolexecdir='$(libdir)/gcc-lib/$(target_alias)' + toolexeclibdir='$(libdir)' fi +multi_os_directory=`$CC -print-multi-os-directory` +case $multi_os_directory in + .) ;; # Avoid trailing /. + *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; +esac +AC_SUBST(toolexecdir) AC_SUBST(toolexeclibdir) +if test "${multilib}" = "yes"; then + multilib_arg="--enable-multilib" +else + multilib_arg= +fi + # Check linker support. LIBFFI_ENABLE_SYMVERS +# Determine what GCC version number to use in filesystem paths. +GCC_BASE_VER + AC_CONFIG_COMMANDS(include, [test -d include || mkdir include]) AC_CONFIG_COMMANDS(src, [ test -d src || mkdir src test -d src/$TARGETDIR || mkdir src/$TARGETDIR ], [TARGETDIR="$TARGETDIR"]) -AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile doc/Makefile libffi.pc) +AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc) -AC_OUTPUT +AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) -# Copy this file instead of using AC_CONFIG_LINK in order to support -# compiling with MSVC, which won't understand cygwin style symlinks. -cp ${srcdir}/src/$TARGETDIR/ffitarget.h include/ffitarget.h +AC_OUTPUT diff --git a/libffi/include/Makefile.am b/libffi/include/Makefile.am index 5f0d4066f4a..d7d1641f00c 100644 --- a/libffi/include/Makefile.am +++ b/libffi/include/Makefile.am @@ -6,4 +6,8 @@ DISTCLEANFILES=ffitarget.h noinst_HEADERS=ffi_common.h ffi_cfi.h tramp.h EXTRA_DIST=ffi.h.in -nodist_include_HEADERS = ffi.h ffitarget.h +# Where generated headers like ffitarget.h get installed. +gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER) +toollibffidir := $(libdir)/gcc/$(target_alias)/$(gcc_version)/include + +toollibffi_HEADERS = ffi.h ffitarget.h