{"id":808941,"url":"http://patchwork.ozlabs.org/api/patches/808941/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/87ziae2rrp.fsf_-_@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<87ziae2rrp.fsf_-_@redhat.com>","list_archive_url":null,"date":"2017-09-01T18:33:14","name":"[v2,libcc1] Rename C{,P}_COMPILER_NAME and remove triplet from them","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"274c4dc02455166f0abd171a04ae9844a3e9038e","submitter":{"id":10371,"url":"http://patchwork.ozlabs.org/api/people/10371/?format=json","name":"Sergio Durigan Junior","email":"sergiodj@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/87ziae2rrp.fsf_-_@redhat.com/mbox/","series":[{"id":1094,"url":"http://patchwork.ozlabs.org/api/series/1094/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=1094","date":"2017-09-01T18:33:14","name":"[v2,libcc1] Rename C{,P}_COMPILER_NAME and remove triplet from them","version":2,"mbox":"http://patchwork.ozlabs.org/series/1094/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808941/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808941/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461325-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461325-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"wM8GwVaN\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=sergiodj@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkSYl6fbsz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 04:33:46 +1000 (AEST)","(qmail 3607 invoked by alias); 1 Sep 2017 18:33:29 -0000","(qmail 3583 invoked by uid 89); 1 Sep 2017 18:33:27 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tFri, 01 Sep 2017 18:33:17 +0000","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.13])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id B76CC7EA9F;\n\tFri,  1 Sep 2017 18:33:15 +0000 (UTC)","from localhost (unused-10-15-17-193.yyz.redhat.com\n\t[10.15.17.193])\tby smtp.corp.redhat.com (Postfix) with ESMTPS\n\tid 5AA5C7835E; Fri,  1 Sep 2017 18:33:15 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:from\n\t:to:cc:subject:references:date:in-reply-to:message-id\n\t:mime-version:content-type; q=dns; s=default; b=Mth+DtXn8Qh37+7B\n\tB5caZaqoiOuUtyP14C/DjyytAtV4aW9VNlCTUa/JqwL0Kfl6RNYfvxG36mzoA68Q\n\te68kgpTYAuDtj+3+EXoppq6p7ZAYZNhiu46/I67WrVLpIz0V/pHmim1kkwgSOfA5\n\tZAu1IMPVFkNZWm5t7Maum1sWn0s=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:from\n\t:to:cc:subject:references:date:in-reply-to:message-id\n\t:mime-version:content-type; s=default; bh=QB6qvN/CBTQiiZ8JjE49TN\n\t+l1uc=; b=wM8GwVaN1A+AiC9XO+0raWgRZ1fg/M63P9qbMdZeUlrZNk2ufaZ96W\n\tvM1sAzn9S8422NFnPUoVLcf0l0go0iIXsJPVLjAcQpl3vac8SZK/N37FOW4J0puM\n\t+kf4sPhxGnqeWBuPdWXL0EhPha8yPhEKhygfT7X0fkBwWvl6MfnmE=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=T, awareness","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com B76CC7EA9F","From":"Sergio Durigan Junior <sergiodj@redhat.com>","To":"Pedro Alves <palves@redhat.com>","Cc":"GDB Patches <gdb-patches@sourceware.org>,\n\tGCC Patches <gcc-patches@gcc.gnu.org>,\n\tTom Tromey <tom@tromey.com>, Keith Seitz <keiths@redhat.com>,\n\tPhil Muldoon <pmuldoon@redhat.com>, Alexandre Oliva <aoliva@redhat.com>","Subject":"[PATCH v2] [libcc1] Rename C{,\n\tP}_COMPILER_NAME and remove triplet from them","References":"<87mv6qhq9u.fsf@redhat.com>\t<af151878-0195-dd4b-06ea-9c1c05b6903e@redhat.com>","Date":"Fri, 01 Sep 2017 14:33:14 -0400","In-Reply-To":"<af151878-0195-dd4b-06ea-9c1c05b6903e@redhat.com> (Pedro\n\tAlves's\tmessage of \"Wed, 23 Aug 2017 19:18:29 +0100\")","Message-ID":"<87ziae2rrp.fsf_-_@redhat.com>","User-Agent":"Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)","MIME-Version":"1.0","Content-Type":"text/plain","X-IsSubscribed":"yes"},"content":"On Wednesday, August 23 2017, Pedro Alves wrote:\n\n> On 08/23/2017 05:17 AM, Sergio Durigan Junior wrote:\n>> Hi there,\n>> \n>> This is a series of two patches, one for GDB and one for GCC, which aims\n>> to improve the detection and handling of triplets present on compiler\n>> names.  The motivation for this series was mostly the fact that GDB's\n>> \"compile\" command is broken on Debian unstable, as can be seen here:\n>> \n>>   <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851146>\n>> \n>> The reason for the failure is the fact that Debian compiles GCC using\n>> the --program-{prefix,suffix} options from configure in order to name\n>> the compiler using the full triplet (i.e., Debian's GCC is not merely\n>> named \"gcc\", but e.g. \"x86_64-linux-gnu-gcc-7\"), which end up naming the\n>> C_COMPILER_NAME and CP_COMPILER_NAME defines with the specified prefix\n>> and suffix.  Therefore, the regexp being used to match the compiler name\n>> is wrong because it doesn't take into account the fact that the defines\n>> may already contain the triplets.\n>\n> As discussed on IRC, I think the problem is that C_COMPILER_NAME\n> in libcc1 includes the full triplet in the first place.  I think\n> that it shouldn't.  I think that C_COMPILER_NAME should always\n> be \"gcc\".\n>\n> The problem is in bootstrapping code, before there's a plugin\n> yet -- i.e.., in the code that libcc1 uses to find the compiler (which\n> then loads a plugin that libcc1 talks with).\n>\n> Please bear with me while I lay down my rationale, so that we're\n> in the same page.\n>\n> C_COMPILER_NAME seems to include the prefix currently in an attempt\n> to support cross debugging, or more generically, --enable-targets=all\n> in gdb, but the whole thing doesn't really work as intended if\n> C_COMPILER_NAME already includes a target prefix.\n>\n> IIUC the libcc1/plugin design, a single \"libcc1.so\" (what gdb loads,\n> not the libcc1plugin compiler plugin) should work with any compiler in\n> the PATH, in case you have several in the system.  E.g., one for\n> each arch.\n>\n> Let me expand.\n>\n> The idea is that gdb always dlopens \"libcc1.so\", by that name exactly.\n> Usually that'll open the libcc1.so installed in the system, e.g.,\n> \"/usr/lib64/libcc1.so\", which for convenience was originally built from the\n> same source tree as the systems's compiler was built.  You could force gdb to\n> load some other libcc1.so, e.g., by tweaking LD_LIBRARY_PATH of course,\n> but you shouldn't need to.\n>\n> libcc1.so is responsible for finding a compiler that targets the\n> architecture of the inferior that the user is debugging in gdb.\n> E.g., say you're cross debugging for arm-none-eabi, on a\n> x86-64 Fedora host.  GDB knows the target inferior's architecture, and passes\n> down to (the system) libcc1 a triplet regex like \"arm*-*eabi*\" or\n> similar to libcc1,.  libcc1 appends \"-\" + C_COMPILER_NAME to that regex,\n> generating something like \"arm*-*eabi*-gcc\", and then looks for binaries\n> in PATH that match that regex.  When one is found, e.g., \"arm-none-eabi-gcc\",\n> libcc1 forks/execs that compiler, passing it \"-fplugin=libcc1plugin\".\n> libcc1 then communicates with that compiler's libcc1plugin plugin\n> via a socket.\n>\n> In this scheme, \"libcc1.so\", the library that gdb loads, has no\n> target-specific logic at all.  It should work with any compiler\n> in the system, for any target/arch.  All it does is marshall the gcc/gdb\n> interface between the gcc plugin and gdb, it is not linked against gcc.\n> That boundary is versioned, and ABI-stable.  So as long as the\n> libcc1.so that gdb loads understands the same API version of the gcc/gdb\n> interface API as gdb understands, it all should work.  (The APIs\n> are always extended keeping backward compatibility.)\n>\n> So in this scheme, having the \"C_COMPILER_NAME\" macro in libcc1\n> include the target prefix for the --target that the plugin that\n> libcc1 is built along with, seems to serve no real purpose, AFAICT.\n> It's just getting in the way.\n>\n> I.e., something like:\n>\n>   \"$gdb_specified_triplet_re\" + \"-\" + C_COMPILER_NAME\n>\n> works if C_COMPILER_NAME is exactly \"gcc\", but not if C_COMPILER_NAME is already:\n>\n>   \"$whatever_triplet_libcc1_happened_to_be_built_with\" + \"-gcc\"\n>\n> because we end up with:\n>\n>   \"$gdb_specified_triplet_re\" + \"-\" \"$whatever_triplet_libcc1_happened_to_be_built_with\" +  \"-gcc\"\n>\n> which is the problem case.\n>\n> In sum, I think the libcc1.so (not the plugin) should _not_ have baked\n> in target awareness, and thus C_COMPILER_NAME should always be \"gcc\", and\n> then libcc1's regex should be adjusted to also tolerate a suffix in\n> the final compiler binary name regex.\n>\n> WDYT?\n\nAs I replied before, I agree with Pedro's rationale here and his idea\nactually makes my initial patch much simpler.  By renaming\nC_COMPILER_NAME (and the new CP_COMPILER_NAME) to just \"gcc\" (or \"g++\"),\nthe Debian bug I was fixing is solved and we don't have to bother with\nbreaking compatibility with older gdb's packaged by the distros, because\nthey will also keep working with this change.\n\nSo I would like to propose this new patch, only for GCC, which makes\nC_COMPILER_NAME and CP_COMPILER_NAME have \"gcc\" and \"g++\" as hardcoded\nnames, respectively.  In the commit log, I intend to include Pedro's\nrationale (above).\n\nWhat do you guys think of this new version?  It doesn't need any GDB\npatch, and works with both Fedora and Debian.\n\nThanks,","diff":"diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am\nindex 5e61a92a26b..cdba5a50b23 100644\n--- a/libcc1/Makefile.am\n+++ b/libcc1/Makefile.am\n@@ -45,24 +45,6 @@ plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la\n cc1lib_LTLIBRARIES = libcc1.la\n endif\n \n-BUILT_SOURCES = c-compiler-name.h cp-compiler-name.h\n-MOSTLYCLEANFILES = c-compiler-name.h cp-compiler-name.h\n-\n-# Put this in a header so we don't run sed for each compilation.  This\n-# is also simpler to debug as one can easily see the constant.\n-# FIXME: compute it in configure.ac and output it in config.status, or\n-# introduce timestamp files for some indirection to avoid rebuilding it\n-# every time.\n-c-compiler-name.h: Makefile\n-\t-rm -f $@T\n-\techo \"#define C_COMPILER_NAME \\\"`echo gcc | sed '$(transform)'`\\\"\" > $@T\n-\tmv $@T $@ # $(SHELL) $(srcdir)/../move-if-change $@T $@\n-\n-cp-compiler-name.h: Makefile\n-\t-rm -f $@T\n-\techo \"#define CP_COMPILER_NAME \\\"`echo g++ | sed '$(transform)'`\\\"\" > $@T\n-\tmv $@T $@ # $(SHELL) $(srcdir)/../move-if-change $@T $@\n-\n shared_source = callbacks.cc callbacks.hh connection.cc connection.hh \\\n     marshall.cc marshall.hh rpc.hh status.hh\n \ndiff --git a/libcc1/Makefile.in b/libcc1/Makefile.in\nindex 54babb02a49..47be10025ad 100644\n--- a/libcc1/Makefile.in\n+++ b/libcc1/Makefile.in\n@@ -307,8 +307,6 @@ plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin\n cc1libdir = $(libdir)/$(libsuffix)\n @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la\n @ENABLE_PLUGIN_TRUE@cc1lib_LTLIBRARIES = libcc1.la\n-BUILT_SOURCES = c-compiler-name.h cp-compiler-name.h\n-MOSTLYCLEANFILES = c-compiler-name.h cp-compiler-name.h\n shared_source = callbacks.cc callbacks.hh connection.cc connection.hh \\\n     marshall.cc marshall.hh rpc.hh status.hh\n \n@@ -344,7 +342,7 @@ libcc1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \\\n \t$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \\\n \t$(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LTLDFLAGS) -o $@\n \n-all: $(BUILT_SOURCES) cc1plugin-config.h\n+all: cc1plugin-config.h\n \t$(MAKE) $(AM_MAKEFLAGS) all-am\n \n .SUFFIXES:\n@@ -567,15 +565,13 @@ GTAGS:\n distclean-tags:\n \t-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags\n check-am: all-am\n-check: $(BUILT_SOURCES)\n-\t$(MAKE) $(AM_MAKEFLAGS) check-am\n+check: check-am\n all-am: Makefile $(LTLIBRARIES) cc1plugin-config.h\n installdirs:\n \tfor dir in \"$(DESTDIR)$(cc1libdir)\" \"$(DESTDIR)$(plugindir)\"; do \\\n \t  test -z \"$$dir\" || $(MKDIR_P) \"$$dir\"; \\\n \tdone\n-install: $(BUILT_SOURCES)\n-\t$(MAKE) $(AM_MAKEFLAGS) install-am\n+install: install-am\n install-exec: install-exec-am\n install-data: install-data-am\n uninstall: uninstall-am\n@@ -595,7 +591,6 @@ install-strip:\n \t    \"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'\" install; \\\n \tfi\n mostlyclean-generic:\n-\t-test -z \"$(MOSTLYCLEANFILES)\" || rm -f $(MOSTLYCLEANFILES)\n \n clean-generic:\n \n@@ -606,7 +601,6 @@ distclean-generic:\n maintainer-clean-generic:\n \t@echo \"This command is intended for maintainers to use\"\n \t@echo \"it deletes files that may require special tools to rebuild.\"\n-\t-test -z \"$(BUILT_SOURCES)\" || rm -f $(BUILT_SOURCES)\n clean: clean-am\n \n clean-am: clean-cc1libLTLIBRARIES clean-generic clean-libtool \\\n@@ -681,7 +675,7 @@ ps-am:\n \n uninstall-am: uninstall-cc1libLTLIBRARIES uninstall-pluginLTLIBRARIES\n \n-.MAKE: all check install install-am install-strip\n+.MAKE: all install-am install-strip\n \n .PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \\\n \tclean-cc1libLTLIBRARIES clean-generic clean-libtool \\\n@@ -702,21 +696,6 @@ uninstall-am: uninstall-cc1libLTLIBRARIES uninstall-pluginLTLIBRARIES\n override CXXFLAGS := $(filter-out -fsanitize=address,$(CXXFLAGS))\n override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS))\n \n-# Put this in a header so we don't run sed for each compilation.  This\n-# is also simpler to debug as one can easily see the constant.\n-# FIXME: compute it in configure.ac and output it in config.status, or\n-# introduce timestamp files for some indirection to avoid rebuilding it\n-# every time.\n-c-compiler-name.h: Makefile\n-\t-rm -f $@T\n-\techo \"#define C_COMPILER_NAME \\\"`echo gcc | sed '$(transform)'`\\\"\" > $@T\n-\tmv $@T $@ # $(SHELL) $(srcdir)/../move-if-change $@T $@\n-\n-cp-compiler-name.h: Makefile\n-\t-rm -f $@T\n-\techo \"#define CP_COMPILER_NAME \\\"`echo g++ | sed '$(transform)'`\\\"\" > $@T\n-\tmv $@T $@ # $(SHELL) $(srcdir)/../move-if-change $@T $@\n-\n # Tell versions [3.59,3.63) of GNU make to not export all variables.\n # Otherwise a system limit (for SysV at least) may be exceeded.\n .NOEXPORT:\ndiff --git a/libcc1/compiler-name.hh b/libcc1/compiler-name.hh\nnew file mode 100644\nindex 00000000000..30cdc41838b\n--- /dev/null\n+++ b/libcc1/compiler-name.hh\n@@ -0,0 +1,29 @@\n+/* The names of the compilers we use.\n+   Copyright (C) 2017 Free Software Foundation, Inc.\n+\n+This file is part of GCC.\n+\n+GCC is free software; you can redistribute it and/or modify it under\n+the terms of the GNU General Public License as published by the Free\n+Software Foundation; either version 3, or (at your option) any later\n+version.\n+\n+GCC is distributed in the hope that it will be useful, but WITHOUT ANY\n+WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n+for more details.\n+\n+You should have received a copy of the GNU General Public License\n+along with GCC; see the file COPYING3.  If not see\n+<http://www.gnu.org/licenses/>.  */\n+\n+#ifndef COMPILER_NAME_H\n+#define COMPILER_NAME_H\n+\n+// C compiler name.\n+#define C_COMPILER_NAME \"gcc\"\n+\n+// C++ compiler name.\n+#define CP_COMPILER_NAME \"g++\"\n+\n+#endif // ! COMPILER_NAME_H\ndiff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc\nindex 0ef6c112dae..1a20dd941a4 100644\n--- a/libcc1/libcc1.cc\n+++ b/libcc1/libcc1.cc\n@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.  If not see\n #include \"libiberty.h\"\n #include \"xregex.h\"\n #include \"findcomp.hh\"\n-#include \"c-compiler-name.h\"\n+#include \"compiler-name.hh\"\n #include \"intl.h\"\n \n struct libcc1;\ndiff --git a/libcc1/libcp1.cc b/libcc1/libcp1.cc\nindex bbd8488af93..b4f9710e0e2 100644\n--- a/libcc1/libcp1.cc\n+++ b/libcc1/libcp1.cc\n@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.  If not see\n #include \"libiberty.h\"\n #include \"xregex.h\"\n #include \"findcomp.hh\"\n-#include \"cp-compiler-name.h\"\n+#include \"compiler-name.hh\"\n #include \"intl.h\"\n \n struct libcp1;\n","prefixes":["v2","libcc1"]}