Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4140158rdb; Mon, 11 Dec 2023 09:55:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IE56eAW86+ouLBTeac2qZzaClvsTfVR3hseod1aoyjkekQCgSNZDtdLiImqYK72qG7Ici3s X-Received: by 2002:a05:6a20:431a:b0:18f:97c:5b82 with SMTP id h26-20020a056a20431a00b0018f097c5b82mr2340580pzk.80.1702317331289; Mon, 11 Dec 2023 09:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702317331; cv=none; d=google.com; s=arc-20160816; b=kfv+vy81TmnY19F4XrsN2xRV0cebx9Kg/r3tvxUK0T/9T4jIn0FGJFpDOBmgQgVaXq 1QS9WGVlYoVo/tgAF+mT7hKac6K3csecbg++GpA8TXoTuxc5mSV4HvWAiyL5pcHosARh Vy7oyBOqt8PrsM/oVm+3juCGYQhcSkTE+BWXPjSxT8q1YrD6MMLs9eWDXNwp/PFetAnu ZpHKcouFFSp0AWrEzI9d6dJ/X9BiesxLoVXKbJf01XEk0vX7YGJBYJ627w3cH54m+2k3 3W63RZ4FkdfEzOVm5DK3Th7fMV4WlyLN9xiAz3Q4ojCE9z1T+Foa3/XjQsFtZRaHWdJF VrJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zV3l9p/vWkVzusqWUtUhSWOWeePoqLtD76g5J1F9I2U=; fh=GJHGFDocP33N5NoeUbVYG1luqpspt2SrurdN18Q2L54=; b=ukubhZ5J0Z2Ep/0ITF+99lxBd3sp9+mPcUdQj0uqnfFeiFzx11rHDJA+w3XsCfM8fX 2EBmyo/1WX4nFWRjidjkNbXnkxJWzAVOpVHrKGHjpbApHiE5TEwSW/Cc6HAJeYZrl17q cLNygdMZPTW6rzDCSj/spRqpA92Ak3NrUWuy9XHtX+qRLSKjtevwwToKOA5Z7aImgfdJ uCTmhusPloJxcAVtQGOvSela6ZhB0BytLmxVNTETz9JeMqqr4JbwH2MT2U8kC1f3I06Y tYYNQk1wj43vxbk/ntMvtwLAWHUJGDayd1av2EY41sHo72w2HYpD+wki+qQhkmDcPx2M YsUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k8UONH8F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h9-20020a056a00170900b006cc05bcf542si6330574pfc.319.2023.12.11.09.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 09:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k8UONH8F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8A20A807514E; Mon, 11 Dec 2023 09:55:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235098AbjLKRzL (ORCPT + 99 others); Mon, 11 Dec 2023 12:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235101AbjLKRy6 (ORCPT ); Mon, 11 Dec 2023 12:54:58 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86F2DD64 for ; Mon, 11 Dec 2023 09:54:09 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3216FC433C7; Mon, 11 Dec 2023 17:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702317249; bh=Ae4/apPtu2qVDtyWUKMc0acmOcBz6ycK0QKMshewLZk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=k8UONH8Fsvpv9P6sElnOdB4OtaxmloX5YxC+LhyNZSRMQT/RqeMPedezuwG9By+Jm afGXxFlDIbkOr08f4Cws/GXwu1g0kfI4mF96RCBwikTxh/SZqeQEoc5JLyXi3+acfT I9d080O/DxQzAkCqBDltyAauDgZp1sjR7MWFi5VLPjdBOuVo0S4cFdYfp5A09k900R SWcd9+dOf7VraOr2ZRIxaslG/4DtGpoiMzOsZT+Mx5n1cmQv5bBVThR1sVnQvYK913 4CFppwji9kaeiavIM0AGPhD4LdWuQ0GTCr+hClGQBG2KUybtCyzjmJpCaXiiAG6wY4 ix2z/5I1qSAgA== Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-1efb9571b13so2919634fac.2; Mon, 11 Dec 2023 09:54:09 -0800 (PST) X-Gm-Message-State: AOJu0YzXbYIM8vBgORFmH6f9b1v181dC/VQ7q7v8W0N20CU9mJlW3WIV BjohppZMCnICQi2NQOHTugmb5WA1ez9bxxj7C68= X-Received: by 2002:a05:6870:d10a:b0:1fb:7f3:252b with SMTP id e10-20020a056870d10a00b001fb07f3252bmr4670680oac.7.1702317248614; Mon, 11 Dec 2023 09:54:08 -0800 (PST) MIME-Version: 1.0 References: <20231210070533.925534-1-xujialu@vimux.org> <20231210070533.925534-2-xujialu@vimux.org> In-Reply-To: <20231210070533.925534-2-xujialu@vimux.org> From: Masahiro Yamada Date: Tue, 12 Dec 2023 02:53:32 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] gen_compile_commands.py: fix path resolve with symlinks in it To: Jialu Xu Cc: justinstitt@google.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, morbo@google.com, nathan@kernel.org, ndesaulniers@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 09:55:28 -0800 (PST) On Sun, Dec 10, 2023 at 4:06=E2=80=AFPM Jialu Xu wrote: > > When a path contains relative symbolic links, os.path.abspath() might > not follow the symlinks and instead return the absolute path with just > the relative paths resolved, resulting in an incorrect path. > > 1. Say "drivers/hdf/" has some symlinks: > > # ls -l drivers/hdf/ > total 364 > drwxrwxr-x 2 ... 4096 ... evdev > lrwxrwxrwx 1 ... 44 ... framework -> ../../../../../../drivers/hd= f_core/framework > -rw-rw-r-- 1 ... 359010 ... hdf_macro_test.h > lrwxrwxrwx 1 ... 55 ... inner_api -> ../../../../../../drivers/hd= f_core/interfaces/inner_api > lrwxrwxrwx 1 ... 53 ... khdf -> ../../../../../../drivers/hdf_cor= e/adapter/khdf/linux > -rw-r--r-- 1 ... 74 ... Makefile > drwxrwxr-x 3 ... 4096 ... wifi > > 2. One .cmd file records that: > > # head -1 ./framework/core/manager/src/.devmgr_service.o.cmd > cmd_drivers/hdf/khdf/manager/../../../../framework/core/manager/src/d= evmgr_service.o :=3D ... \ > /path/to/src/drivers/hdf/khdf/manager/../../../../framework/core/mana= ger/src/devmgr_service.c > > 3. os.path.abspath returns "/path/to/src/framework/core/manager/src/devmg= r_service.c", not correct: > > # ./scripts/clang-tools/gen_compile_commands.py > INFO: Could not add line from ./framework/core/manager/src/.devmgr_se= rvice.o.cmd: File \ > /path/to/src/framework/core/manager/src/devmgr_service.c not foun= d > > Use os.path.realpath(), which resolves the symlinks and normalizes the pa= ths correctly. > > # cat compile_commands.json > ... > { > "command": ... > "directory": ... > "file": "/path/to/bla/drivers/hdf_core/framework/core/manager/src/d= evmgr_service.c" > }, > ... > > Also fix it in parse_arguments(). > > Signed-off-by: Jialu Xu Applied to linux-kbuild. Thanks. --=20 Best Regards Masahiro Yamada