From patchwork Wed Sep 20 11:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 142375 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4082200vqi; Wed, 20 Sep 2023 05:04:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcbnlAgIE5f0+qlnwVOurEB2jOazQA+YDYw7MvjdhFsQKA+IENotv+sTM1t8GHiTrYTFOn X-Received: by 2002:a17:907:7885:b0:99c:55ac:3a61 with SMTP id ku5-20020a170907788500b0099c55ac3a61mr1926430ejc.56.1695211447342; Wed, 20 Sep 2023 05:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695211447; cv=none; d=google.com; s=arc-20160816; b=Jq5nMPoRavOXi2EOhm7PDUoWD4T3utbdFznGL3p3AAggoGF/T3+4YXeFMIOtFvLK9s +hT2bd+k62eV1Z1pgjrQLaP7a08A18jFW7JRZkT50ZnohPzey1W0i8z7uW+nlE3mQDTM 2d7+UzPt1HGQ8z/t4bU9n/43fppbJNVtyC7YF6XS2xt9Tcz4JO3Xx95Dl6xxv6TCyJH7 NOiDquSMUQDvjGEVLOcyLV5XWZ7itleKDnXSXrEu7qc6bKe1oNfBnvgS8EUZBtfE8uMC 7K3Tn7m86PPG5gKh+UxKh8sqJ5Vxqwa6hBOufgyNWG8XBwa1fbwaHgyRq13IhZbhOkaF 8XRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=0IrGLzGi1C3xCFPvhguXJdXBknbPu+QMPO2VRXRcWOw=; fh=s1GzlUPo1djGkCl3rkRJI30hDOSCVwGp0RAbVwQ8dxQ=; b=qwap9mIXw30B1LfoaeARRz+KXkcPlNRW9tD5YNtccCo0LN+zOLAZKztEp8SOkE8ZMb 3X8bGyklu4GAcG9i2Z4vFchfcr18g8Jd0HuodlMj05wab6wXnKoWgbeoopK7kIFCmH8x K19Yq+eRqNZZ18Wdjosw37FYPboUCCR35CKLrXE2CaMiW7C0fCvbkSwLCZjJPkph3bmm QIFfw/rkhuYpLXRgmCF5lz3+phZ6eLkSJmCs+QCKSQThsPs9XnuyLX5BFkKRtlds7+Xg d2U35OXqsOx4N7ZiBhfgQwv2gUpCNHRlaDKyM+5vnOCOs6RDDPM7faMj4mSDF5Q4VugT zGcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Fqqo7sx6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id pk10-20020a170906d7aa00b00992d2630d08si11549972ejb.788.2023.09.20.05.04.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 05:04:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Fqqo7sx6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 489CA3861822 for ; Wed, 20 Sep 2023 12:03:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 364543858407 for ; Wed, 20 Sep 2023 12:02:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 364543858407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-405082a8c77so35776475e9.0 for ; Wed, 20 Sep 2023 05:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1695211377; x=1695816177; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0IrGLzGi1C3xCFPvhguXJdXBknbPu+QMPO2VRXRcWOw=; b=Fqqo7sx6IiBTsrrz/WZV00IIsDurwMdXMy8/B/SnD1BnEjp20f/iUQGvXUvtXTToLB ufz93oZN4pn7XgpgkG+j4DBcoaPY8Ah3FX0Z2CukSD9/VSmKY29Y3GNtdZ9H4k0ERC4y DEduV3O/SfkBgp5W1WbJMuOMqxlIbx8wnYAzU7cDUmhSiMfhhMTAalsuvr3KE0rwSu/D MHW+tIJ7gu6Lh8RVW2nj/TpyRc5+YirKQ2nKp6SjxxTL7fte5wk5f+x5I7SAR2VjbVfZ mGGbRrtI3vv+l8YrfMhnlLXxwTNmfYd09+EE/JXk5DhTvrjfge8iYf64kjFIW8vA2Xsz 2r+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695211377; x=1695816177; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0IrGLzGi1C3xCFPvhguXJdXBknbPu+QMPO2VRXRcWOw=; b=Fir0i90JZyZK/MC2Yv4skCg66nxwTfvkTZV2IdEVXdamPiwOsN98nvkG6fFyKj2ODt /aEAIruoLKIl19JfWsjb0NslZjz5lFrEQO6MTNFeeT0ncuJHMFfo9NlposRUzPlS35xz ogcjeWNaqUPFgwxiPWk3jN0fa9nbgcHabQbhjDKx87AnLjniiYRnl94Sabd9IP6DG7o8 v9CFdgl5tQ/mIOQ5juMQ3cv5YwNECca/1Yj5DznKRJtR7ssmDymEwudsHT7PmNR/exLe E+vvnRovs61c7cdCykj0JfNlUgnX0yJ2hVPNpM6aJ4H0A01vMfgW3vp3xHzJEGd6Ollx 6POg== X-Gm-Message-State: AOJu0YwaKRx6YLjs3P11Jx5k64/f+aR5u5OozVJc/Rhk8Af4yFcqrgEz AmMQf4f7PPydYqYN1+v6It5ukMwRphIrxW1HhHTa X-Received: by 2002:a7b:cd9a:0:b0:3fe:5053:1a0b with SMTP id y26-20020a7bcd9a000000b003fe50531a0bmr2100916wmj.11.1695211376241; Wed, 20 Sep 2023 05:02:56 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c6-20020a7bc846000000b003fe29dc0ff2sm1782020wml.21.2023.09.20.05.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 05:02:55 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry Subject: [PATCH 1/3] librust: Add libproc_macro and build system Date: Wed, 20 Sep 2023 13:59:51 +0200 Message-ID: <20230920120311.14892-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777558038776637536 X-GMAIL-MSGID: 1777558038776637536 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? This first commit adds a simple `libgrust` folder with on top of which the full library will be built. 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 = 1.8 foreign + +SUFFIXES = .c .rs .def .o .lo .a + +ACLOCAL_AMFLAGS = -I . -I .. -I ../config + +AM_CFLAGS = -I $(srcdir)/../libgcc -I $(MULTIBUILDTOP)../../gcc/include + +TOP_GCCDIR := $(shell cd $(top_srcdir) && cd .. && pwd) + +GCC_DIR = $(TOP_GCCDIR)/gcc +RUST_SRC = $(GCC_DIR)/rust + +toolexeclibdir=@toolexeclibdir@ +toolexecdir=@toolexecdir@ + +SUBDIRS = libproc_macro + +RUST_BUILDDIR := $(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 = \ + "GCC_DIR=$(GCC_DIR)" \ + "RUST_SRC=$(RUST_SRC)" \ + "AR_FLAGS=$(AR_FLAGS)" \ + "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ + "CC_FOR_TARGET=$(CC_FOR_TARGET)" \ + "RUST_FOR_TARGET=$(RUST_FOR_TARGET)" \ + "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)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ + "MAKE=$(MAKE)" \ + "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ + "PICFLAG=$(PICFLAG)" \ + "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \ + "SHELL=$(SHELL)" \ + "RUNTESTFLAGS=$(RUNTESTFLAGS)" \ + "exec_prefix=$(exec_prefix)" \ + "infodir=$(infodir)" \ + "libdir=$(libdir)" \ + "includedir=$(includedir)" \ + "prefix=$(prefix)" \ + "tooldir=$(tooldir)" \ + "gxx_include_dir=$(gxx_include_dir)" \ + "AR=$(AR)" \ + "AS=$(AS)" \ + "LD=$(LD)" \ + "RANLIB=$(RANLIB)" \ + "NM=$(NM)" \ + "NM_FOR_BUILD=$(NM_FOR_BUILD)" \ + "NM_FOR_TARGET=$(NM_FOR_TARGET)" \ + "DESTDIR=$(DESTDIR)" \ + "WERROR=$(WERROR)" \ + "TARGET_LIB_PATH=$(TARGET_LIB_PATH)" \ + "TARGET_LIB_PATH_librust=$(TARGET_LIB_PATH_librust)" \ + "LIBTOOL=$(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=${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 libraries should be installed in a compiler-specific directory ], +[case "$enableval" in + yes) version_specific_libs=yes ;; + no) version_specific_libs=no ;; + *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; + esac], +[version_specific_libs=no]) +AC_MSG_RESULT($version_specific_libs) + +toolexecdir=no +toolexeclibdir=no + +# 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='$(libdir)/gcc/$(target_noncanonical)' + toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' + ;; + no) + if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + # Install a library built with a cross compiler in tooldir, not libdir. + toolexecdir='$(exec_prefix)/$(target_noncanonical)' + toolexeclibdir='$(toolexecdir)/lib' + else + toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)' + toolexeclibdir='$(libdir)' + fi + multi_os_directory=`$CC -print-multi-os-directory` + case $multi_os_directory in + .) ;; # Avoid trailing /. + *) toolexeclibdir=$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 =' >> $ac_file + ml_norecursion=yes + 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 = .cc .o .a .lo .la + +ACLOCAL_AMFLAGS = -I .. -I ../../config + +toolexeclibdir=@toolexeclibdir@ +toolexecdir=@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 = \ + "AR_FLAGS=$(AR_FLAGS)" \ + "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ + "CC_FOR_TARGET=$(CC_FOR_TARGET)" \ + "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)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ + "MAKE=$(MAKE)" \ + "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ + "PICFLAG=$(PICFLAG)" \ + "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \ + "SHELL=$(SHELL)" \ + "RUNTESTFLAGS=$(RUNTESTFLAGS)" \ + "exec_prefix=$(exec_prefix)" \ + "infodir=$(infodir)" \ + "libdir=$(libdir)" \ + "includedir=$(includedir)" \ + "prefix=$(prefix)" \ + "tooldir=$(tooldir)" \ + "gxx_include_dir=$(gxx_include_dir)" \ + "AR=$(AR)" \ + "AS=$(AS)" \ + "LD=$(LD)" \ + "RANLIB=$(RANLIB)" \ + "NM=$(NM)" \ + "NM_FOR_BUILD=$(NM_FOR_BUILD)" \ + "NM_FOR_TARGET=$(NM_FOR_TARGET)" \ + "DESTDIR=$(DESTDIR)" \ + "WERROR=$(WERROR)" \ + "TARGET_LIB_PATH=$(TARGET_LIB_PATH)" \ + "TARGET_LIB_PATH_libgm2=$(TARGET_LIB_PATH_libgm2)" + +toolexeclib_LTLIBRARIES = libproc_macro.la + +libproc_macro_la_SOURCES = \ + proc_macro.cc + +include_HEADERS = \ + proc_macro.h + diff --git a/libgrust/libproc_macro/proc_macro.cc b/libgrust/libproc_macro/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 */