From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 784183858D35; Tue, 26 Sep 2023 11:43:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 784183858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c147b96af8so101414601fa.0; Tue, 26 Sep 2023 04:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695728583; x=1696333383; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9LUrNBSbP2wrP2m3P9KYLJ0mfKIzUsAmsr4fL07gUNA=; b=HtBSNNie//qx0dTUsypLY3VAi1fjP+43kAldCnhc9dHyrmXrT3PlltYTfrdG/Afjh9 robmHpi9kXIRkdaQE4+oapZikcjiNRdb98BnAU9rE/VhtqltfYT0xuT5FMoArqjt1R2V gJ+/ZZogAzPYNHA4sUWDpObWJbVCw+JiGZzvMneg3ZXkHLhEv8uiBq0WoTfduvV+9DGT LwBvT8GUi2Ic8iu1tnkuePNoVyVOWCJnDm1paL0RqnVHXplgfLpO4iycH7osT6QrX8+2 AWUzMH7D4ZljJvakI3kvZ8CrSBdlLyfsE7SJCHVYIUIDAfKouwMEpk6CHie6ebrF6pvL +w+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695728583; x=1696333383; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9LUrNBSbP2wrP2m3P9KYLJ0mfKIzUsAmsr4fL07gUNA=; b=in4iTL7f6Zgk0I0DXojIIv3N03JToSuTArU6I/VjDmqgGvpCeC1RdZ0KgW/h5YdZUt w1PFdImFCSeFr4gRH0l/WiGGB41k7qXEnfPdQQyQHYiq0QpEkBemGDmEHmHmF/PCzht4 tfXrOVKD8ls92l1Sx90vyLgSm033jLs5T53DXCrLKG9C13VXhVv8h3YHLmu+WNvXyZqx T8pnr84B24snsapW/DGUmBf/i6G9s78guu7bCYrO1Ji+uKpk/AHd3OqZ4EyQwXYsFYDu X67PIpuGZmWiYeEpl8oGPvSBCuJy4FIGFJ9EpWZ+uLwzsTftHgUZXq8Fl88EVpQzExcp 9HSw== X-Gm-Message-State: AOJu0YyUYA9c2h7cMkUQl83ZLHKjz1aJEbsVpLxDSS6Fc8Wr9Xtdi4Bk p/3Lg1zNs0/+Mg/JNgi4wDmXIAu0FPoBKlvTZGHVfeu8 X-Google-Smtp-Source: AGHT+IGV1KNfo9hHm5I2nkREHew5xuo1GhPbUqKXy7t09ma/pE504TagLxC/VejlnLVWMMQ/Dlwne6gLC2FWpvGeI84= X-Received: by 2002:a2e:910a:0:b0:2bc:39f5:ecb4 with SMTP id m10-20020a2e910a000000b002bc39f5ecb4mr8022669ljg.25.1695728582690; Tue, 26 Sep 2023 04:43:02 -0700 (PDT) MIME-Version: 1.0 References: <20230920120311.14892-1-arthur.cohen@embecosm.com> In-Reply-To: <20230920120311.14892-1-arthur.cohen@embecosm.com> From: Richard Biener Date: Tue, 26 Sep 2023 13:40:40 +0200 Message-ID: Subject: Re: [PATCH 1/3] librust: Add libproc_macro and build system To: Arthur Cohen Cc: gcc-patches@gcc.gnu.org, gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Sep 20, 2023 at 2:04=E2=80=AFPM Arthur Cohen wrote: > > From: Pierre-Emmanuel Patry > > This patch series adds the build system changes to allow the Rust > frontend to develop and distribute its own libraries. The first library > we have been working on is the `proc_macro` library, comprised of a C++ > library as well as a user-facing Rust library. > > Follow up commits containing the actual library code will be committed. > Should I submit patches to the MAINTAINERS file to allow Philip and I to > commit to this folder without first approval? I think the Rust language frontend maintainership implicitly includes the rust runtime libraries. > This first commit adds a simple `libgrust` folder with on top of which th= e > full library will be built. OK. > All the best, > > Arthur > > ----- > > Add some dummy files in libproc_macro along with it's build system. > > ChangeLog: > > * libgrust/Makefile.am: New file. > * libgrust/configure.ac: New file. > * libgrust/libproc_macro/Makefile.am: New file. > * libgrust/libproc_macro/proc_macro.cc: New file. > * libgrust/libproc_macro/proc_macro.h: New file. > > Signed-off-by: Pierre-Emmanuel Patry > --- > libgrust/Makefile.am | 68 ++++++++++++++++ > libgrust/configure.ac | 113 +++++++++++++++++++++++++++ > libgrust/libproc_macro/Makefile.am | 58 ++++++++++++++ > libgrust/libproc_macro/proc_macro.cc | 7 ++ > libgrust/libproc_macro/proc_macro.h | 7 ++ > 5 files changed, 253 insertions(+) > create mode 100644 libgrust/Makefile.am > create mode 100644 libgrust/configure.ac > create mode 100644 libgrust/libproc_macro/Makefile.am > create mode 100644 libgrust/libproc_macro/proc_macro.cc > create mode 100644 libgrust/libproc_macro/proc_macro.h > > diff --git a/libgrust/Makefile.am b/libgrust/Makefile.am > new file mode 100644 > index 00000000000..8e5274922c5 > --- /dev/null > +++ b/libgrust/Makefile.am > @@ -0,0 +1,68 @@ > +AUTOMAKE_OPTIONS =3D 1.8 foreign > + > +SUFFIXES =3D .c .rs .def .o .lo .a > + > +ACLOCAL_AMFLAGS =3D -I . -I .. -I ../config > + > +AM_CFLAGS =3D -I $(srcdir)/../libgcc -I $(MULTIBUILDTOP)../../gcc/includ= e > + > +TOP_GCCDIR :=3D $(shell cd $(top_srcdir) && cd .. && pwd) > + > +GCC_DIR =3D $(TOP_GCCDIR)/gcc > +RUST_SRC =3D $(GCC_DIR)/rust > + > +toolexeclibdir=3D@toolexeclibdir@ > +toolexecdir=3D@toolexecdir@ > + > +SUBDIRS =3D libproc_macro > + > +RUST_BUILDDIR :=3D $(shell pwd) > + > +# 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 =3D \ > + "GCC_DIR=3D$(GCC_DIR)" \ > + "RUST_SRC=3D$(RUST_SRC)" \ > + "AR_FLAGS=3D$(AR_FLAGS)" \ > + "CC_FOR_BUILD=3D$(CC_FOR_BUILD)" \ > + "CC_FOR_TARGET=3D$(CC_FOR_TARGET)" \ > + "RUST_FOR_TARGET=3D$(RUST_FOR_TARGET)" \ > + "CFLAGS=3D$(CFLAGS)" \ > + "CXXFLAGS=3D$(CXXFLAGS)" \ > + "CFLAGS_FOR_BUILD=3D$(CFLAGS_FOR_BUILD)" \ > + "CFLAGS_FOR_TARGET=3D$(CFLAGS_FOR_TARGET)" \ > + "INSTALL=3D$(INSTALL)" \ > + "INSTALL_DATA=3D$(INSTALL_DATA)" \ > + "INSTALL_PROGRAM=3D$(INSTALL_PROGRAM)" \ > + "INSTALL_SCRIPT=3D$(INSTALL_SCRIPT)" \ > + "LDFLAGS=3D$(LDFLAGS)" \ > + "LIBCFLAGS=3D$(LIBCFLAGS)" \ > + "LIBCFLAGS_FOR_TARGET=3D$(LIBCFLAGS_FOR_TARGET)" \ > + "MAKE=3D$(MAKE)" \ > + "MAKEINFO=3D$(MAKEINFO) $(MAKEINFOFLAGS)" \ > + "PICFLAG=3D$(PICFLAG)" \ > + "PICFLAG_FOR_TARGET=3D$(PICFLAG_FOR_TARGET)" \ > + "SHELL=3D$(SHELL)" \ > + "RUNTESTFLAGS=3D$(RUNTESTFLAGS)" \ > + "exec_prefix=3D$(exec_prefix)" \ > + "infodir=3D$(infodir)" \ > + "libdir=3D$(libdir)" \ > + "includedir=3D$(includedir)" \ > + "prefix=3D$(prefix)" \ > + "tooldir=3D$(tooldir)" \ > + "gxx_include_dir=3D$(gxx_include_dir)" \ > + "AR=3D$(AR)" \ > + "AS=3D$(AS)" \ > + "LD=3D$(LD)" \ > + "RANLIB=3D$(RANLIB)" \ > + "NM=3D$(NM)" \ > + "NM_FOR_BUILD=3D$(NM_FOR_BUILD)" \ > + "NM_FOR_TARGET=3D$(NM_FOR_TARGET)" \ > + "DESTDIR=3D$(DESTDIR)" \ > + "WERROR=3D$(WERROR)" \ > + "TARGET_LIB_PATH=3D$(TARGET_LIB_PATH)" \ > + "TARGET_LIB_PATH_librust=3D$(TARGET_LIB_PATH_librust)" \ > + "LIBTOOL=3D$(RUST_BUILDDIR)/libtool" > + > +include $(top_srcdir)/../multilib.am > diff --git a/libgrust/configure.ac b/libgrust/configure.ac > new file mode 100644 > index 00000000000..7aed489a643 > --- /dev/null > +++ b/libgrust/configure.ac > @@ -0,0 +1,113 @@ > +AC_INIT([libgrust], version-unused,,librust) > +AC_CONFIG_SRCDIR(Makefile.am) > +AC_CONFIG_FILES([Makefile]) > + > +# AM_ENABLE_MULTILIB(, ..) > + > +# Do not delete or change the following two lines. For why, see > +# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html > +AC_CANONICAL_SYSTEM > +target_alias=3D${target_alias-$host_alias} > +AC_SUBST(target_alias) > + > +# Automake should never attempt to rebuild configure > +AM_MAINTAINER_MODE > + > +AM_INIT_AUTOMAKE([1.15.1 foreign no-dist -Wall]) > + > +# Make sure we don't test executables when making cross-tools. > +GCC_NO_EXECUTABLES > + > + > +# Add the ability to change LIBTOOL directory > +GCC_WITH_TOOLEXECLIBDIR > + > +# Use system specific extensions > +AC_USE_SYSTEM_EXTENSIONS > + > + > +# Checks for header files. > +AC_HEADER_STDC > +AC_HEADER_SYS_WAIT > +AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h \ > + time.h sys/stat.h wchar.h) > + > +# Check for tools > +AM_PROG_AR > +AC_PROG_CC > +AC_PROG_CXX > +AM_PROG_AS > +AC_PROG_MAKE_SET > +AC_PROG_INSTALL > + > +# Enable libtool > +LT_INIT > + > +# target_noncanonical variables... > +AC_CANONICAL_HOST > +ACX_NONCANONICAL_HOST > +ACX_NONCANONICAL_TARGET > +GCC_TOPLEV_SUBDIRS > + > +AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) > +AC_ARG_ENABLE(version-specific-runtime-libs, > +[ --enable-version-specific-runtime-libs Specify that runtime librar= ies should be installed in a compiler-specific directory ], > +[case "$enableval" in > + yes) version_specific_libs=3Dyes ;; > + no) version_specific_libs=3Dno ;; > + *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific = libs]);; > + esac], > +[version_specific_libs=3Dno]) > +AC_MSG_RESULT($version_specific_libs) > + > +toolexecdir=3Dno > +toolexeclibdir=3Dno > + > +# Calculate toolexeclibdir > +# Also toolexecdir, though it's only used in toolexeclibdir > +case ${version_specific_libs} in > + yes) > + # Need the gcc compiler version to know where to install libraries > + # and header files if --enable-version-specific-runtime-libs option > + # is selected. > + toolexecdir=3D'$(libdir)/gcc/$(target_noncanonical)' > + toolexeclibdir=3D'$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' > + ;; > + no) > + if test -n "$with_cross_host" && > + test x"$with_cross_host" !=3D x"no"; then > + # Install a library built with a cross compiler in tooldir, not li= bdir. > + toolexecdir=3D'$(exec_prefix)/$(target_noncanonical)' > + toolexeclibdir=3D'$(toolexecdir)/lib' > + else > + toolexecdir=3D'$(libdir)/gcc-lib/$(target_noncanonical)' > + toolexeclibdir=3D'$(libdir)' > + fi > + multi_os_directory=3D`$CC -print-multi-os-directory` > + case $multi_os_directory in > + .) ;; # Avoid trailing /. > + *) toolexeclibdir=3D$toolexeclibdir/$multi_os_directory ;; > + esac > + ;; > +esac > + > +AC_SUBST(toolexecdir) > +AC_SUBST(toolexeclibdir) > + > + > +AC_CONFIG_FILES(AC_FOREACH([DIR], [libproc_macro], [DIR/Makefile ]), > + [ cat > vpsed$$ << \_EOF > +s!`test -f '$<' || echo '$(srcdir)/'`!! > +_EOF > + sed -f vpsed$$ $ac_file > tmp$$ > + mv tmp$$ $ac_file > + rm vpsed$$ > + echo 'MULTISUBDIR =3D' >> $ac_file > + ml_norecursion=3Dyes > + AS_UNSET([ml_norecursion]) > +]) > + > + > +AC_MSG_NOTICE([librust has been configured.]) > + > +AC_OUTPUT > diff --git a/libgrust/libproc_macro/Makefile.am b/libgrust/libproc_macro/= Makefile.am > new file mode 100644 > index 00000000000..1e61d12e506 > --- /dev/null > +++ b/libgrust/libproc_macro/Makefile.am > @@ -0,0 +1,58 @@ > +SUFFIXES =3D .cc .o .a .lo .la > + > +ACLOCAL_AMFLAGS =3D -I .. -I ../../config > + > +toolexeclibdir=3D@toolexeclibdir@ > +toolexecdir=3D@toolexecdir@ > + > +# 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 =3D \ > + "AR_FLAGS=3D$(AR_FLAGS)" \ > + "CC_FOR_BUILD=3D$(CC_FOR_BUILD)" \ > + "CC_FOR_TARGET=3D$(CC_FOR_TARGET)" \ > + "CFLAGS=3D$(CFLAGS)" \ > + "CXXFLAGS=3D$(CXXFLAGS)" \ > + "CFLAGS_FOR_BUILD=3D$(CFLAGS_FOR_BUILD)" \ > + "CFLAGS_FOR_TARGET=3D$(CFLAGS_FOR_TARGET)" \ > + "INSTALL=3D$(INSTALL)" \ > + "INSTALL_DATA=3D$(INSTALL_DATA)" \ > + "INSTALL_PROGRAM=3D$(INSTALL_PROGRAM)" \ > + "INSTALL_SCRIPT=3D$(INSTALL_SCRIPT)" \ > + "LDFLAGS=3D$(LDFLAGS)" \ > + "LIBCFLAGS=3D$(LIBCFLAGS)" \ > + "LIBCFLAGS_FOR_TARGET=3D$(LIBCFLAGS_FOR_TARGET)" \ > + "MAKE=3D$(MAKE)" \ > + "MAKEINFO=3D$(MAKEINFO) $(MAKEINFOFLAGS)" \ > + "PICFLAG=3D$(PICFLAG)" \ > + "PICFLAG_FOR_TARGET=3D$(PICFLAG_FOR_TARGET)" \ > + "SHELL=3D$(SHELL)" \ > + "RUNTESTFLAGS=3D$(RUNTESTFLAGS)" \ > + "exec_prefix=3D$(exec_prefix)" \ > + "infodir=3D$(infodir)" \ > + "libdir=3D$(libdir)" \ > + "includedir=3D$(includedir)" \ > + "prefix=3D$(prefix)" \ > + "tooldir=3D$(tooldir)" \ > + "gxx_include_dir=3D$(gxx_include_dir)" \ > + "AR=3D$(AR)" \ > + "AS=3D$(AS)" \ > + "LD=3D$(LD)" \ > + "RANLIB=3D$(RANLIB)" \ > + "NM=3D$(NM)" \ > + "NM_FOR_BUILD=3D$(NM_FOR_BUILD)" \ > + "NM_FOR_TARGET=3D$(NM_FOR_TARGET)" \ > + "DESTDIR=3D$(DESTDIR)" \ > + "WERROR=3D$(WERROR)" \ > + "TARGET_LIB_PATH=3D$(TARGET_LIB_PATH)" \ > + "TARGET_LIB_PATH_libgm2=3D$(TARGET_LIB_PATH_libgm2)" > + > +toolexeclib_LTLIBRARIES =3D libproc_macro.la > + > +libproc_macro_la_SOURCES =3D \ > + proc_macro.cc > + > +include_HEADERS =3D \ > + proc_macro.h > + > diff --git a/libgrust/libproc_macro/proc_macro.cc b/libgrust/libproc_macr= o/proc_macro.cc > new file mode 100644 > index 00000000000..d13276294aa > --- /dev/null > +++ b/libgrust/libproc_macro/proc_macro.cc > @@ -0,0 +1,7 @@ > +#include "proc_macro.h" > + > +int > +test () > +{ > + return 0; > +} > diff --git a/libgrust/libproc_macro/proc_macro.h b/libgrust/libproc_macro= /proc_macro.h > new file mode 100644 > index 00000000000..2c96b3de685 > --- /dev/null > +++ b/libgrust/libproc_macro/proc_macro.h > @@ -0,0 +1,7 @@ > +#ifndef PROC_MACRO_H > +#define PROC_MACRO_H > + > +int > +test (); > + > +#endif /* ! PROC_MACRO_H */ > -- > 2.42.0 >