Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matte1/bazel 7 #170

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ build:rbe --jobs=32
# BuildBuddy remote exec
build:rbe --remote_executor=grpcs://remote.buildbuddy.io

# Disable bazelmod
common --noenable_bzlmod


try-import %workspace%/.bazelrc.user
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.0
7.0.2
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "aspect_gcc_toolchain")
workspace(name = "gcc_toolchain")

load("//toolchain:repositories.bzl", "gcc_toolchain_dependencies")

Expand Down
2 changes: 1 addition & 1 deletion docs/defs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions toolchain/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ _FEATURE_ATTRS = {
),
"gcc_toolchain_workspace_name": attr.string(
doc = "The name given to the gcc-toolchain repository, if the default was not used.",
default = "aspect_gcc_toolchain",
default = "gcc_toolchain",
),
"includes": attr.string_list(
doc = "Extra includes for compiling C and C++." +
Expand Down Expand Up @@ -157,60 +157,61 @@ gcc_toolchain = repository_rule(

def _render_tool_paths(rctx, repository_name, toolchain_files_repository_name, binary_prefix):
relative_tool_paths = {
"ar": "external/{repository_name}/bin/{binary_prefix}-linux-ar".format(
"ar": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-ar".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"as": "external/{repository_name}/bin/{binary_prefix}-linux-as".format(
"as": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-as".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"cpp": "external/{repository_name}/bin/{binary_prefix}-linux-cpp".format(
"cpp": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-cpp".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"g++": "external/{repository_name}/bin/{binary_prefix}-linux-g++".format(
"g++": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-g++".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"gcc": "external/{repository_name}/bin/{binary_prefix}-linux-gcc".format(
"gcc": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-gcc".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"gcov": "external/{repository_name}/bin/{binary_prefix}-linux-gcov".format(
"gcov": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-gcov".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"gfortran": "external/{repository_name}/bin/{binary_prefix}-linux-gfortran".format(
"gfortran": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-gfortran".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"ld": "external/{repository_name}/bin/{binary_prefix}-linux-ld".format(
"ld": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-ld".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"nm": "external/{repository_name}/bin/{binary_prefix}-linux-nm".format(
"nm": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-nm".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"objcopy": "external/{repository_name}/bin/{binary_prefix}-linux-objcopy".format(
"objcopy": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-objcopy".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"objdump": "external/{repository_name}/bin/{binary_prefix}-linux-objdump".format(
"objdump": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-objdump".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
"strip": "external/{repository_name}/bin/{binary_prefix}-linux-strip".format(
"strip": "bazel-working-directory/gcc_toolchain/external/{repository_name}/bin/{binary_prefix}-linux-strip".format(
repository_name = toolchain_files_repository_name,
binary_prefix = binary_prefix,
),
}

path_env = ":".join([
"${{EXECROOT}}/external/{}/bin".format(repository)
"${{EXECROOT}}/bazel-working-directory/gcc_toolchain/external/{}/bin".format(repository)
for repository in [repository_name, toolchain_files_repository_name]
])
print(path_env)

tool_paths = {}
for name, tool_path in relative_tool_paths.items():
Expand Down
14 changes: 14 additions & 0 deletions toolchain/wrapper.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ set -o errexit -o nounset -o pipefail
# symlinks of the BASH_SOURCE[0] is more reliable than navigating to the
# execroot from $PWD. This is due to the fact that the Bazel C++ toolchain can
# be called from different working directories (e.g. rules_foreign_cc rules).
# EXECROOT="${EXECROOT:-"$(realpath "$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../")"}"
EXECROOT="${EXECROOT:-"$(realpath "$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../../..")"}"

echo "EXECROOT: ${EXECROOT}"
# ls -lh "${EXECROOT}"
# ls -lh "${EXECROOT}/bazel-execroot/gcc_toolchain"
# ls -lh "${EXECROOT}/bazel-source-roots"
# ls -lh "${EXECROOT}/bazel-working-directory/gcc_toolchain/external"
# ls -lh "${EXECROOT}/bazel-working-directory/gcc-toolchain"
# echo "BINARY: __binary__"
# echo "Running: ${EXECROOT}/__binary__ ${args[@]}"
echo "PATH = __PATH__"
# ls -lh /tmp/external/

export EXECROOT
export PATH="__PATH__"
args=("$@")
Expand All @@ -44,4 +57,5 @@ for i in "${!args[@]}"; do
fi
done


exec "${EXECROOT}/__binary__" "${args[@]}"
Loading