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: 24931 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E83152054E for ; Wed, 19 Feb 2014 07:45:58 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf67367pab.11 for ; Tue, 18 Feb 2014 23:45:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:from:to:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:content-type; bh=gpuWu/chtN3IYaddIvvQ761ihuzYzcX9S8F2vM6Puzw=; b=KB3p4QT/E7eZKucTURInhk+S4lpiHheKy/0M2pFLXCaRgxqNDTuAcF7Y3T8DBd+PuR s1sn0pSdp5zaMCZLO6KFsDbPnIIQYfCC3QCWBNgmli7vR/P7v1NiEJIkstvePXpS5iNV Sq3Vm5qQ1gC9j/K5ZlWwupl/6/zIn1Uq+ulYoF6nBUXHKXVoXNrYCJ8dqV/1DwmugZWf jQMPqhTb4/6+ZmgR+1A5Nc8Ut6XQBupOqZyqQWJlDh1rApiPVFdR1YsDAnrNYezWDRDL XtAHaihjy7cO+XxmarGigecQY9N8HL/JDfYntRbjsr424DA0RdP6k8uqBk0D8Ixjpgzl xT/g== X-Gm-Message-State: ALoCoQnSp6e1Weh7Ne59KaEiQbAWP4PgKexrFyTnXPJTxwUsgktFlxhNVJ/1+c+/S9KWbEg50KNB X-Received: by 10.69.16.98 with SMTP id fv2mr193442pbd.7.1392795958135; Tue, 18 Feb 2014 23:45:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.102 with SMTP id l93ls3615qge.93.gmail; Tue, 18 Feb 2014 23:45:57 -0800 (PST) X-Received: by 10.53.0.230 with SMTP id bb6mr7497902vdd.39.1392795957886; Tue, 18 Feb 2014 23:45:57 -0800 (PST) Received: from mail-ve0-x22d.google.com (mail-ve0-x22d.google.com [2607:f8b0:400c:c01::22d]) by mx.google.com with ESMTPS id j20si6485965vcx.19.2014.02.18.23.45.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 23:45:57 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22d; Received: by mail-ve0-f173.google.com with SMTP id jw12so24970veb.32 for ; Tue, 18 Feb 2014 23:45:57 -0800 (PST) X-Received: by 10.52.160.233 with SMTP id xn9mr362617vdb.48.1392795957561; Tue, 18 Feb 2014 23:45:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp277714vcz; Tue, 18 Feb 2014 23:45:56 -0800 (PST) X-Received: by 10.66.149.37 with SMTP id tx5mr544810pab.81.1392795956445; Tue, 18 Feb 2014 23:45:56 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id gx4si20923562pbc.351.2014.02.18.23.45.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Feb 2014 23:45:56 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-361985-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 10232 invoked by alias); 19 Feb 2014 07:45:45 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 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 X-Original-Sender: joey.ye@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 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);