From patchwork Wed Sep 5 13:56:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Baldwin X-Patchwork-Id: 181868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 4E47A2C0093 for ; Wed, 5 Sep 2012 23:57:14 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1347458235; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=PkBWtMY o5B0/2vQV4bB29dxgOEU=; b=PhYBh8nd0wLrxrk8Z6B8UJfCVakadF7/5utiAZj kK64G4l9+5YdJZ+I725jjSEuswppNSMvSYzCRTq8pIJOoeGybAYyyXsHTsLHlHoz Nw5XmJ6dKdVTQeWD14Ki0yC/NbqZklOXQQzNBf3cuugkjwLnCeg+mNsFly4hAyXx bSmI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=eqqqmrh6tExoe329ol7SNrWSjFLU8NwuhnnygDtyH0WGRwLwScMEmN57xDdrLz 9to7J+IfEunLYdQlGbSTpwdo3o6yelZnYY1vZHS2kI0BLM6E6QTjYIf7rBWQtY+s UnZ7Gw3a1gOAM2Z1b7LuwoDBue/9DKKqVl/NjjcP1yK2o=; Received: (qmail 21940 invoked by alias); 5 Sep 2012 13:57:01 -0000 Received: (qmail 21910 invoked by uid 22791); 5 Sep 2012 13:56:57 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD, URIBL_DBL_REDIR X-Spam-Check-By: sourceware.org Received: from mail-vb0-f73.google.com (HELO mail-vb0-f73.google.com) (209.85.212.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Sep 2012 13:56:43 +0000 Received: by vbbfn1 with SMTP id fn1so52317vbb.2 for ; Wed, 05 Sep 2012 06:56:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=fB5/WPoEZ+tQnLlDsLr5dkIef24XKKA9dgwec3yzF5s=; b=h1Bv7wjWt6hWbNjFkixP7O5zSei5AKXGYVY9JaDbutdptKib4yOy0rRK2hMTn3pwvA rqujYIZmFVZWcrwluMwU2T00q0c5DUyTC7Hl36rjjF8LFzxyVdC9aZ3aJeN/r4eNTHf1 5hc/xy9UupZ6v54R+0c0vsFVwpxSMkZu+lEq1F9MfS//67qIj0sCJ2rjDxxHWspcYxT/ WqHmriiQ/sP4JsF0z/LoXBC7xmsqilclKuEJNybF5EkPPSn47YGqcpDQYG0XbLnmpzlM u+G+uP7/qneLkXElIAh+ai2eKfTkegkCjD3pKUq8rZFetmKCQD93TeqV3hzFKyEh8Xla jtzw== Received: by 10.236.179.72 with SMTP id g48mr13816691yhm.37.1346853402584; Wed, 05 Sep 2012 06:56:42 -0700 (PDT) Received: by 10.236.179.72 with SMTP id g48mr13816465yhm.37.1346853393171; Wed, 05 Sep 2012 06:56:33 -0700 (PDT) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id l23si462722yhk.6.2012.09.05.06.56.33 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 05 Sep 2012 06:56:33 -0700 (PDT) Received: from xoom.chi.corp.google.com (xoom.chi.corp.google.com [172.31.47.91]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 1971B10006B; Wed, 5 Sep 2012 06:56:33 -0700 (PDT) Received: by xoom.chi.corp.google.com (Postfix, from userid 9603) id AA650A0D91; Wed, 5 Sep 2012 08:56:32 -0500 (CDT) To: reply@codereview.appspotmail.com,gcc-patches@gcc.gnu.org Subject: Add a configure option to disable system header canonicalizations (issue6495088) Message-Id: <20120905135632.AA650A0D91@xoom.chi.corp.google.com> Date: Wed, 5 Sep 2012 08:56:32 -0500 (CDT) From: simonb@google.com (Simon Baldwin) X-Gm-Message-State: ALoCoQkwk1zFpG7h7fPdeRq1RmLghWabAtl5iAdN8NzYHvxcGso3XTgyxtA1/J72hLb7Q5prmveHwupcCsf9wT3h1URf+pa9WPU2HVBIzzu676rtEMy4hD94ckqrBh9i8/53xDjZGKYUf10QzGSX6MdG99Ew8ZLb1r22sCZCYVzgTu7RbDgqMvgJ5GgEF9jEeKUfV6CuYLmU X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Add a configure option to disable system header canonicalizations. Libcpp may canonicalize system header paths with lrealpath() for diagnostics, dependency output, and similar. If gcc is held in a symlink farm the canonicalized paths may be meaningless to users, and will also conflict with build frameworks that (for example) disallow absolute paths to header files. This change adds --[en/dis]able-canonical-system-headers, allowing configure to select whether or not to implement r186991. See also PR c++/52974. Tested for regressions with bootstrap builds of C and C++, both with and without configure --disable-canonical-system-headers. Okay for trunk? libcpp/ChangeLog.google-integration 2012-09-05 Simon Baldwin * files.c (maybe_shorter_path): Suppress function definition if ENABLE_CANONICAL_SYSTEM_HEADERS is not defined. * (find_file_in_dir): Call maybe_shorter_path() only if ENABLE_CANONICAL_SYSTEM_HEADERS is defined. * configure.ac: Add new --enable-canonical-system-headers. * configure: Regenerate. * config.in: Regenerate. gcc/ChangeLog.google-integration 2012-09-05 Simon Baldwin * doc/install.texi: Document --enable-canonical-system-headers. --- This patch is available for review at http://codereview.appspot.com/6495088 Index: gcc/doc/install.texi =================================================================== --- gcc/doc/install.texi (revision 190968) +++ gcc/doc/install.texi (working copy) @@ -1710,6 +1710,14 @@ link time when @option{-fuse-linker-plug This linker should have plugin support such as gold starting with version 2.20 or GNU ld starting with version 2.21. See @option{-fuse-linker-plugin} for details. + +@item --enable-canonical-system-headers +@itemx --disable-canonical-system-headers +Enable system header path canonicalization for @file{libcpp}. This can +produce shorter header file paths in diagnostics and dependency output +files, but these changed header paths may conflict with some compilation +environments. Enabled by default, and may be disabled using +@option{--disable-canonical-system-headers}. @end table @subheading Cross-Compiler-Specific Options Index: libcpp/configure =================================================================== --- libcpp/configure (revision 190968) +++ libcpp/configure (working copy) @@ -700,6 +700,7 @@ enable_rpath with_libiconv_prefix enable_maintainer_mode enable_checking +enable_canonical_system_headers ' ac_precious_vars='build_alias host_alias @@ -1333,6 +1334,8 @@ Optional Features: --disable-rpath do not hardcode runtime library paths --enable-maintainer-mode enable rules only needed by maintainers --enable-checking enable expensive run-time checks + --enable-canonical-system-headers + enable or disable system headers canonicalization Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -7094,6 +7097,19 @@ $as_echo "#define ENABLE_CHECKING 1" >>c fi +# Check whether --enable-canonical-system-headers was given. +if test "${enable_canonical_system_headers+set}" = set; then : + enableval=$enable_canonical_system_headers; +else + enable_canonical_system_headers=yes +fi + +if test $enable_canonical_system_headers != no; then + +$as_echo "#define ENABLE_CANONICAL_SYSTEM_HEADERS 1" >>confdefs.h + +fi + case $target in alpha*-*-* | \ Index: libcpp/files.c =================================================================== --- libcpp/files.c (revision 190968) +++ libcpp/files.c (working copy) @@ -345,6 +345,7 @@ pch_open_file (cpp_reader *pfile, _cpp_f shorter, otherwise return NULL. This function does NOT free the memory pointed by FILE. */ +#ifdef ENABLE_CANONICAL_SYSTEM_HEADERS static char * maybe_shorter_path (const char * file) { @@ -359,6 +360,7 @@ maybe_shorter_path (const char * file) return NULL; } } +#endif /* Try to open the path FILE->name appended to FILE->dir. This is where remap and PCH intercept the file lookup process. Return true @@ -384,6 +386,7 @@ find_file_in_dir (cpp_reader *pfile, _cp char *copy; void **pp; +#ifdef ENABLE_CANONICAL_SYSTEM_HEADERS /* We try to canonicalize system headers. */ if (file->dir->sysp) { @@ -396,6 +399,7 @@ find_file_in_dir (cpp_reader *pfile, _cp path = canonical_path; } } +#endif hv = htab_hash_string (path); if (htab_find_with_hash (pfile->nonexistent_file_hash, path, hv) != NULL) Index: libcpp/configure.ac =================================================================== --- libcpp/configure.ac (revision 190968) +++ libcpp/configure.ac (working copy) @@ -132,6 +132,16 @@ if test $enable_checking != no ; then [Define if you want more run-time sanity checks.]) fi +AC_ARG_ENABLE(canonical-system-headers, +[ --enable-canonical-system-headers + enable or disable system headers canonicalization], +[], +enable_canonical_system_headers=yes) +if test $enable_canonical_system_headers != no; then + AC_DEFINE(ENABLE_CANONICAL_SYSTEM_HEADERS, + 1, [Define to enable system headers canonicalization.]) +fi + m4_changequote(,) case $target in alpha*-*-* | \ Index: libcpp/config.in =================================================================== --- libcpp/config.in (revision 190968) +++ libcpp/config.in (working copy) @@ -11,6 +11,9 @@ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA +/* Define to enable system headers canonicalization. */ +#undef ENABLE_CANONICAL_SYSTEM_HEADERS + /* Define if you want more run-time sanity checks. */ #undef ENABLE_CHECKING