From 91b1dffa6c70f101f54d9414c721d09daeeab5ff Mon Sep 17 00:00:00 2001 From: Pawel Rutka Date: Fri, 21 Nov 2025 11:50:24 +0100 Subject: [PATCH] qnx: do not relay on /proc/self --- toolchains/qcc/cc_toolchain_config.bzl | 13 ++++++++++--- toolchains/qcc/toolchain.BUILD | 1 + toolchains/rules.bzl | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/toolchains/qcc/cc_toolchain_config.bzl b/toolchains/qcc/cc_toolchain_config.bzl index 30b05c8..5058053 100644 --- a/toolchains/qcc/cc_toolchain_config.bzl +++ b/toolchains/qcc/cc_toolchain_config.bzl @@ -433,6 +433,10 @@ def _impl(ctx): ], ) + base_path = "/proc/self/cwd/" + if ctx.attr.workspace_root_hint: + base_path = ctx.attr.workspace_root_hint + sdp_env_feature = feature( name = "sdp_env", enabled = True, @@ -440,8 +444,9 @@ def _impl(ctx): env_set( actions = all_compile_actions + all_link_actions, env_entries = [ - env_entry(key = "QNX_HOST", value = "/proc/self/cwd/" + ctx.file.qnx_host.path), - env_entry(key = "QNX_TARGET", value = "/proc/self/cwd/" + ctx.file.qnx_target.path), + + env_entry(key = "QNX_HOST", value = base_path + ctx.file.qnx_host.path), + env_entry(key = "QNX_TARGET", value = base_path + ctx.file.qnx_target.path), env_entry(key = "QNX_CONFIGURATION_EXCLUSIVE", value = "/var/tmp/.qnx"), env_entry(key = "QNX_SHARED_LICENSE_FILE", value = "/opt/score_qnx/license/licenses"), ], @@ -468,7 +473,7 @@ def _impl(ctx): ] cxx_builtin_include_directories = [ - "/proc/self/cwd/{}".format(include_directory.path) + "{}{}".format(base_path, include_directory.path) for include_directory in ctx.files.cxx_builtin_include_directories ] @@ -503,5 +508,7 @@ cc_toolchain_config = rule( "qcc_version": attr.string(default = "12.2.0"), "gcc_variant": attr.string(mandatory = True), "gcc_variant_cxx": attr.string(mandatory = True), + "workspace_root_hint": attr.string(), + }, ) diff --git a/toolchains/qcc/toolchain.BUILD b/toolchains/qcc/toolchain.BUILD index 6e4dd3d..4909f99 100644 --- a/toolchains/qcc/toolchain.BUILD +++ b/toolchains/qcc/toolchain.BUILD @@ -93,6 +93,7 @@ cc_toolchain_config( qcc_version = "12.2.0", gcc_variant = "gcc_ntoaarch64le", gcc_variant_cxx = "gcc_ntoaarch64le_cxx", + workspace_root_hint = "%{build_workspace_root}", ) diff --git a/toolchains/rules.bzl b/toolchains/rules.bzl index e003ec2..e7ff034 100644 --- a/toolchains/rules.bzl +++ b/toolchains/rules.bzl @@ -11,11 +11,14 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* def _qcc_toolchain_impl(rctx): + sandbox_dir = rctx.workspace_root.realpath.get_child("bazel-out").realpath.get_child("..").realpath + rctx.template( "BUILD", rctx.attr._cc_tolchain_build, { "%{toolchain_sdp}": rctx.attr.sdp_repo, + "%{build_workspace_root}": str(sandbox_dir) + "/", }, )