[{"id":3622,"web_url":"https://patchwork.libcamera.org/comment/3622/","msgid":"<20200206203436.GD7611@pendragon.ideasonboard.com>","date":"2020-02-06T20:34:36","subject":"Re: [libcamera-devel] [PATCH 4/5] libcamera: ipa_manager: Search\n\tthe runpath for IPA libraries","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Wed, Feb 05, 2020 at 01:04:19PM +0000, Kieran Bingham wrote:\n> Expose the IPA build path through the libcamera library runpath entry in\n\ns/library runpath entry/library search path entry (DT_RUNPATH)/\n\n> the elf string table. Utilise this path to search for compiled IPA\n\ns/elf string table/ELF dynamic tags/ ?\n\n> libraries when loading the IPAManager.\n> \n> The build time path is removed during the library install phase.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/libcamera/ipa_manager.cpp | 9 +++++++++\n>  src/libcamera/meson.build     | 1 +\n>  src/meson.build               | 7 +++++++\n>  3 files changed, 17 insertions(+)\n> \n> diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\n> index 24fe709108fe..3dfe84fcf95e 100644\n> --- a/src/libcamera/ipa_manager.cpp\n> +++ b/src/libcamera/ipa_manager.cpp\n> @@ -102,6 +102,15 @@ IPAManager::IPAManager()\n>  \tif (ret > 0)\n>  \t\tipaCount += ret;\n>  \n> +\t/*\n> +\t * Utilise the Elf runpath to supply the IPA build directory, allowing\n\ns/Elf/ELF/\n\n> +\t * us to load IPA's before they are installed for testing and\n> +\t * development.\n> +\t */\n> +\tconst char *runpath = utils::get_runpath();\n> +\tif (runpath)\n> +\t\tipaCount += addPath(runpath, true);\n\nShouldn't this go after LIBCAMERA_IPA_MODULE_PATH ? If a user sets\nLIBCAMERA_IPA_MODULE_PATH, it should be considered before DT_RUNPATH.\n\nI think we also need to move IPA_MODULE_DIR after DT_RUNPATH, as the\nbuild directory should have precedence over the system directory.\n\nMaybe the above comment should be expanded to explain the load order ?\n\n\n\t/*\n\t * Load IPA modules. The IPA manager uses the following search paths to\n\t * locate the modules.\n\t *\n\t * - The directories in DT_RUNPATH. The build system sets DT_RUNPATH to\n\t *   point to the src/ipa/ subdirectory of the build directory, allowing\n\t *   finding modules in the build directory. DT_RUNPATH is stripped when\n\t *   libcamera.so is installed.\n\t *\n\t * - The directories specified in the LIBCAMERA_IPA_MODULE_PATH\n\t *   environment variable, if set.\n\t *\n\t * - The $prefix/ipa/ directory.\n\t */\n\n> +\n>  \tconst char *modulePaths = utils::secure_getenv(\"LIBCAMERA_IPA_MODULE_PATH\");\n>  \tif (!modulePaths) {\n>  \t\tif (!ipaCount)\n> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> index 68d89559b290..87c5bbbb17a4 100644\n> --- a/src/libcamera/meson.build\n> +++ b/src/libcamera/meson.build\n> @@ -107,6 +107,7 @@ libcamera = shared_library('camera',\n>                             install : true,\n>                             link_with : libcamera_link_with,\n>                             include_directories : includes,\n> +                           build_rpath : ipa_build_path,\n>                             dependencies : libcamera_deps)\n>  \n>  libcamera_dep = declare_dependency(sources : [libcamera_api, libcamera_ipa_api, libcamera_h],\n> diff --git a/src/meson.build b/src/meson.build\n> index 5adcd61fd913..42e1eb984ccd 100644\n> --- a/src/meson.build\n> +++ b/src/meson.build\n> @@ -2,6 +2,13 @@ if get_option('android')\n>      subdir('android')\n>  endif\n>  \n> +# Provide libcamera with a reference to the current build for IPA\n\ns/current build/build directory path/ ?\n\n> +# loading. This allows IPAs to be successfully loaded when tests and\n> +# applications are run from the build tree, but is stripped during the\n> +# install phase, ensuring we maintain reproducible builds.\n> +\n> +ipa_build_path = join_paths(meson.current_build_dir(), 'ipa')\n> +\n>  subdir('libcamera')\n>  subdir('ipa')\n>  subdir('cam')","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 329B060864\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2020 21:34:54 +0100 (CET)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 680599F0;\n\tThu,  6 Feb 2020 21:34:53 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581021293;\n\tbh=gAFpNRnwvXUxA9bvOYVM3wSwcMlFTsJA8jxr0Qa5TPA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=oPdPulU3UKSoPYlOXD6m7coKszDZYCAyOq4c0Mm1R10mLrCAzKRuUIVvB22bmJL58\n\tb07E3/aFQy6hKmJcYshzlgNFb9IchUGGGEAk+phl7EP8Mh60XbogCsMoQ7hGzHHMiH\n\t4oZQMV1ANCELZL2PK16tRqaG/RZojbNs0Wil3owo=","Date":"Thu, 6 Feb 2020 22:34:36 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20200206203436.GD7611@pendragon.ideasonboard.com>","References":"<20200205130420.8736-1-kieran.bingham@ideasonboard.com>\n\t<20200205130420.8736-5-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200205130420.8736-5-kieran.bingham@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 4/5] libcamera: ipa_manager: Search\n\tthe runpath for IPA libraries","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 06 Feb 2020 20:34:54 -0000"}}]