From patchwork Wed Feb 19 07:45:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Ye X-Patchwork-Id: 321761 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 97AE12C00B7 for ; Wed, 19 Feb 2014 18:45:51 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=AwXzEfSQ/pHsTP/TnQaKuN1bvYQcM1LCUw8/CbckCKp2Ce2a6miad 1L6N188Nzetn+QPeoP6k3DuacJbk7ZuGsO2fZuM9vGMW7SM1zoreXSxIC6ggXqpk O2ntNzngOfNErzfwf4GacLT/ja9Rbxv/NTTVug9uOEIaWUARO/s768= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=e1gwyGHwWYWZOPRxg+D2ku9LaAA=; b=nBXI3kWiHUX0s3JtlLRz j/Fpbf4sDZmgaMB3v7WrhvbllGItaYPACj00uC3oV2abgOffbmA3Wx/1KtQkamYt 8UM9+VIjk5BNbypWEBGENGmv9cqUiMC94WcUELZ3S3yFgyaCZ/RLzVhw7kigl0OB 08hpnJTlwrHorljmXOiAYGY= Received: (qmail 10232 invoked by alias); 19 Feb 2014 07:45:45 -0000 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 Received: (qmail 10222 invoked by uid 89); 19 Feb 2014 07:45:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Feb 2014 07:45:43 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 19 Feb 2014 07:45:39 +0000 Received: from E103005 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 19 Feb 2014 07:45:38 +0000 From: "Joey Ye" To: , "Ian Lance Taylor" Subject: [patch] Shorten Windows path Date: Wed, 19 Feb 2014 15:45:10 +0800 Message-ID: <000001cf2d46$85948ee0$90bdaca0$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114021907453900201 Max length of path on Windows is 255, which is easy to exceed in a complicated project. Ultimate solution may be complex but canonizing the path and skipping the ".."s in path is helpful. Relative discussion in gcc-patches: http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00582.html OK to trunk stage 1? ChangeLog.libcpp: * files.c (find_file_in_dir): Always try to shorten for DOS. if (canonical_path) diff --git a/libcpp/files.c b/libcpp/files.c index 7e88778..9dcc71f 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -386,9 +386,18 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) hashval_t hv; char *copy; void **pp; + bool do_canonical; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + /* For DOS based file system, we always try to shorten file path + * to as it has a shorter constraint on max path length. */ + do_canonical = true; +#else /* We try to canonicalize system headers. */ - if (CPP_OPTION (pfile, canonical_system_headers) && file->dir->sysp) + do_canonical = (CPP_OPTION (pfile, canonical_system_headers) + && file->dir->sysp); +#endif + if ( do_canonical ) { char * canonical_path = maybe_shorter_path (path);