diff --git a/.github/workflows/aarch64-ebclfsa.yml b/.github/workflows/aarch64-ebclfsa.yml new file mode 100644 index 0000000..f73c201 --- /dev/null +++ b/.github/workflows/aarch64-ebclfsa.yml @@ -0,0 +1,41 @@ +# ******************************************************************************* +# Copyright (c) 2026 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +name: Bazel Build (Aarch64-Linux)(ebclfsa) +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + merge_group: + types: [checks_requested] + workflow_call: +jobs: + aarch64-ebclfsa: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./examples + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.18.0 + with: + bazelisk-cache: true + disk-cache: ${{ github.job }} + repository-cache: true + cache-save: ${{ github.event_name == 'push' }} + - name: Bazel Build (basic) + run: | + bazel build --config aarch64-ebclfsa -- //:main_cpp diff --git a/examples/MODULE.bazel.lock b/examples/MODULE.bazel.lock index 7202b55..e53d196 100644 --- a/examples/MODULE.bazel.lock +++ b/examples/MODULE.bazel.lock @@ -1044,8 +1044,8 @@ }, "@@score_bazel_cpp_toolchains+//extensions:gcc.bzl%gcc": { "general": { - "bzlTransitiveDigest": "NgSSI3Z2Tp2MR9xVR97IgNx7nuKEeeKGBJwH7YvG+YE=", - "usagesDigest": "RizhCPQB+WoV0RjCPAlGIY/zqeVSxIzHUAWi8W4qV34=", + "bzlTransitiveDigest": "TzOSvaP+r8IKPGkVGHmuI71W8WaOYcU99BEHlKf57XA=", + "usagesDigest": "/wUYFdM1xKTzS24yegCMuIO8ZBNPa2xMLcpzqWVKLWw=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, @@ -1150,6 +1150,7 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "", "sdp_version": "", + "tc_compiler_library_search_paths": [], "tc_cpu": "x86_64", "tc_identifier": "gcc_12.2.0", "tc_os": "linux", @@ -1174,6 +1175,7 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "", "sdp_version": "", + "tc_compiler_library_search_paths": [], "tc_cpu": "x86_64", "tc_identifier": "gcc_12.2.0", "tc_os": "linux", @@ -1198,6 +1200,7 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "", "sdp_version": "", + "tc_compiler_library_search_paths": [], "tc_cpu": "aarch64", "tc_identifier": "gcc_12.2.0", "tc_os": "linux", @@ -1224,6 +1227,7 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "", "sdp_version": "", + "tc_compiler_library_search_paths": [], "tc_cpu": "x86_64", "tc_identifier": "gcc_12.2.0", "tc_os": "linux", @@ -1248,6 +1252,7 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "", "sdp_version": "8.0.0", + "tc_compiler_library_search_paths": [], "tc_cpu": "x86_64", "tc_identifier": "sdp_8.0.0", "tc_os": "qnx", @@ -1272,6 +1277,7 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "", "sdp_version": "8.0.0", + "tc_compiler_library_search_paths": [], "tc_cpu": "aarch64", "tc_identifier": "sdp_8.0.0", "tc_os": "qnx", @@ -1332,6 +1338,7 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "", "sdp_version": "", + "tc_compiler_library_search_paths": [], "tc_cpu": "x86_64", "tc_identifier": "", "tc_os": "linux", @@ -1405,6 +1412,10 @@ "license_path": "/opt/score_qnx/license/licenses", "sdk_version": "0.1.0", "sdp_version": "", + "tc_compiler_library_search_paths": [ + "external/%{toolchain_pkg}%/usr/lib/x86_64-linux-gnu", + "external/%{toolchain_pkg}%/lib/x86_64-linux-gnu" + ], "tc_cpu": "aarch64", "tc_identifier": "sdk_0.1.0", "tc_os": "linux", diff --git a/extensions/gcc.bzl b/extensions/gcc.bzl index b9ef410..0dd2fbe 100644 --- a/extensions/gcc.bzl +++ b/extensions/gcc.bzl @@ -187,6 +187,7 @@ def _get_toolchains(tags): "sdk_version": tag.sdk_version, "sdp_to_link": tag.sdp_to_link, "sdp_version": tag.sdp_version, + "tc_compiler_library_search_paths": [], "tc_cpu": tag.target_cpu, "tc_extra_c_compile_flags": tag.extra_c_compile_flags, "tc_extra_compile_flags": tag.extra_compile_flags, @@ -232,6 +233,8 @@ def _create_and_link_sdp(toolchain_info): toolchain_info["tc_extra_link_flags"] = matrix["extra_link_flags"] if "gcc_version" in matrix and not toolchain_info["gcc_version"]: toolchain_info["gcc_version"] = matrix["gcc_version"] + if "compiler_library_search_paths" in matrix: + toolchain_info["tc_compiler_library_search_paths"] = matrix["compiler_library_search_paths"] return { "build_file": matrix["build_file"], @@ -324,6 +327,7 @@ def _impl(mctx): license_path = toolchain_info["tc_license_path"], sdk_version = toolchain_info["sdk_version"], sdp_version = toolchain_info["sdp_version"], + tc_compiler_library_search_paths = toolchain_info["tc_compiler_library_search_paths"], tc_cpu = toolchain_info["tc_cpu"], tc_identifier = toolchain_info["tc_identifier"], tc_os = toolchain_info["tc_os"], diff --git a/packages/linux/aarch64/autosd/10.0/autosd.BUILD b/packages/linux/aarch64/autosd/10.0/autosd.BUILD index 2508de0..daedfc5 100644 --- a/packages/linux/aarch64/autosd/10.0/autosd.BUILD +++ b/packages/linux/aarch64/autosd/10.0/autosd.BUILD @@ -50,11 +50,6 @@ filegroup( srcs = ["usr/bin/strip"], ) -filegroup( - name = "ld_library_paths", - srcs = [], -) - # The sysroot for AutoSD is the entire extracted directory # since it contains usr/ and lib64/ at the root filegroup( diff --git a/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD b/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD index 3195214..d909382 100644 --- a/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD +++ b/packages/linux/aarch64/ebclfsa/0.1.0/ebclfsa.BUILD @@ -17,7 +17,18 @@ package(default_visibility = ["//visibility:public"]) filegroup( name = "all_files", - srcs = glob(["*/**/*"], exclude = ["usr/share/ca-certificates/**","usr/lib/ssl/certs/**", "lib/ssl/certs/**", "etc/ssl/certs/**", "usr/share/man/**", "usr/share/perl/**", "var/lib/**"]), + srcs = glob( + ["*/**/*"], + exclude = [ + "usr/share/ca-certificates/**", + "usr/lib/ssl/certs/**", + "lib/ssl/certs/**", + "etc/ssl/certs/**", + "usr/share/man/**", + "usr/share/perl/**", + "var/lib/**", + ], + ), ) filegroup( @@ -55,11 +66,6 @@ filegroup( srcs = ["usr/bin/lisa-elf-enabler"], ) -filegroup( - name = "ld_library_paths", - srcs = ["usr/lib/x86_64-linux-gnu", "lib/x86_64-linux-gnu"], -) - # The sysroot for EBcLfSA is the entire extracted directory filegroup( name = "sysroot_dir", diff --git a/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD b/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD index b733d0b..4725a73 100644 --- a/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD +++ b/packages/linux/aarch64/gcc/12.2.0/gcc.BUILD @@ -50,12 +50,7 @@ filegroup( srcs = ["bin/aarch64-unknown-linux-gnu-strip"], ) -filegroup( - name = "ld_library_paths", - srcs = [], -) - filegroup( name = "sysroot_dir", srcs = ["aarch64-unknown-linux-gnu/sysroot"], -) \ No newline at end of file +) diff --git a/packages/linux/x86_64/autosd/10.0/autosd.BUILD b/packages/linux/x86_64/autosd/10.0/autosd.BUILD index 17fef90..d80d7c2 100644 --- a/packages/linux/x86_64/autosd/10.0/autosd.BUILD +++ b/packages/linux/x86_64/autosd/10.0/autosd.BUILD @@ -50,11 +50,6 @@ filegroup( srcs = ["usr/bin/strip"], ) -filegroup( - name = "ld_library_paths", - srcs = [], -) - # The sysroot for AutoSD is the entire extracted directory # since it contains usr/ and lib64/ at the root filegroup( @@ -67,10 +62,10 @@ filegroup( filegroup( name = "cxx_builtin_include_directories", srcs = [ - "usr/lib/gcc/x86_64-redhat-linux/14/include", "usr/include", "usr/include/c++/14", - "usr/include/c++/14/x86_64-redhat-linux", "usr/include/c++/14/backward", + "usr/include/c++/14/x86_64-redhat-linux", + "usr/lib/gcc/x86_64-redhat-linux/14/include", ], ) diff --git a/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD b/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD index 32b547b..dc6fbb1 100644 --- a/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD +++ b/packages/linux/x86_64/gcc/12.2.0/gcc.BUILD @@ -50,12 +50,7 @@ filegroup( srcs = ["bin/x86_64-unknown-linux-gnu-strip"], ) -filegroup( - name = "ld_library_paths", - srcs = [], -) - filegroup( name = "sysroot_dir", srcs = ["x86_64-unknown-linux-gnu/sysroot"], -) \ No newline at end of file +) diff --git a/packages/version_matrix.bzl b/packages/version_matrix.bzl index 568d46d..3b01de9 100644 --- a/packages/version_matrix.bzl +++ b/packages/version_matrix.bzl @@ -178,6 +178,10 @@ VERSION_MATRIX = { "-static", "--no-canonical-prefixes", ], + "compiler_library_search_paths": [ + "external/%{toolchain_pkg}%/usr/lib/x86_64-linux-gnu", + "external/%{toolchain_pkg}%/lib/x86_64-linux-gnu", + ], "strip_prefix": "fastdev-sdk-ubuntu-ebclfsa-ebcl-qemuarm64", "sha256": "f44286c28d831dc40acdac08ef49f38a2e9cbb057bea38c25834964693785287", "url": "https://github.com/Elektrobit/eb_corbos_toolkit/releases/download/v2.0.0-beta1/fastdev-sdk-ubuntu-ebclfsa-ebcl-qemuarm64.tar.gz", diff --git a/rules/gcc.bzl b/rules/gcc.bzl index 8c9ee02..48a98a0 100644 --- a/rules/gcc.bzl +++ b/rules/gcc.bzl @@ -50,7 +50,6 @@ cc_toolchain_config( cxx_binary = "@{tc_pkg_repo}//:cxx", gcov_binary = "@{tc_pkg_repo}//:gcov", strip_binary = "@{tc_pkg_repo}//:strip", - ld_library_path_dirs = "@{tc_pkg_repo}//:ld_library_paths", sysroot = "@{tc_pkg_repo}//:sysroot_dir", target_cpu = "{tc_cpu}", target_os = "{tc_os}", @@ -157,8 +156,11 @@ def _impl(rctx): extra_c_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_c_compile_flags)) extra_cxx_compile_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_cxx_compile_flags)) extra_link_flags = get_flag_groups(replace_placeholder(rctx.attr.extra_link_flags)) + compiler_library_search_paths = replace_placeholder(rctx.attr.tc_compiler_library_search_paths) template_dict = { + "%{compiler_library_search_paths_switch}": "True" if len(rctx.attr.tc_compiler_library_search_paths) else "False", + "%{compiler_library_search_paths}": ":".join(["/proc/self/cwd/" + entry for entry in compiler_library_search_paths]), "%{extra_c_compile_flags_switch}": "True" if len(rctx.attr.extra_c_compile_flags) else "False", "%{extra_c_compile_flags}": extra_c_compile_flags, "%{extra_compile_flags_switch}": "True" if len(rctx.attr.extra_compile_flags) else "False", @@ -230,6 +232,7 @@ gcc_toolchain = repository_rule( "license_path": attr.string(doc = "Lincese path"), "sdk_version": attr.string(doc = "SDK version string"), "sdp_version": attr.string(doc = "SDP version string"), + "tc_compiler_library_search_paths": attr.string_list(doc = "Additional search path which compiler needs."), "tc_cpu": attr.string(doc = "Target platform CPU."), "tc_identifier": attr.string(doc = "Constraint to be used for toolchain definition (e.g. gcc_12.2.0)."), "tc_os": attr.string(doc = "Target platform OS."), diff --git a/templates/linux/cc_toolchain_config.bzl.template b/templates/linux/cc_toolchain_config.bzl.template index 20bac1e..65769be 100644 --- a/templates/linux/cc_toolchain_config.bzl.template +++ b/templates/linux/cc_toolchain_config.bzl.template @@ -160,6 +160,21 @@ def _impl(ctx): strip_action, ] + # Set LD_LIBRARY_PATH environment variable for all actions + # This is needed by some toolchains since these libraries are not in `rpath` of compiler binary + # which are needed to run it. + compiler_library_search_paths = "%{compiler_library_search_paths}" + compiler_library_search_paths_feature = feature( + name = "compiler_library_search_paths", + enabled = %{compiler_library_search_paths_switch}, + env_sets = [ + env_set( + actions = all_actions, + env_entries = [env_entry(key = "LD_LIBRARY_PATH", value = compiler_library_search_paths)] if compiler_library_search_paths != "" else [], + ), + ], + ) + unfiltered_compile_flags_feature = feature( name = "unfiltered_compile_flags", enabled = True, @@ -617,6 +632,7 @@ def _impl(ctx): # after a command line parameter from a feature at the beginning of the list. features = [ + compiler_library_search_paths_feature, sanitizer_feature, asan_feature, lsan_feature, @@ -657,26 +673,6 @@ def _impl(ctx): if ctx.attr.sysroot != None: sysroot = ctx.attr.sysroot[DefaultInfo].files.to_list()[0].path - # Get ld_library_paths from attribute if provided and set LD_LIBRARY_PATH environment variable for actions - if hasattr(ctx.attr, "ld_library_path_dirs") and ctx.attr.ld_library_path_dirs and ctx.attr.ld_library_path_dirs[DefaultInfo].files.to_list(): - values = ["/proc/self/cwd/" + entry.path for entry in ctx.attr.ld_library_path_dirs[DefaultInfo].files.to_list()] - ld_library_path = ":".join(values) - - sdk_env_feature = feature( - name = "sdk_env", - enabled = True, - env_sets = [ - env_set( - actions = all_actions, - env_entries = [ - env_entry(key = "LD_LIBRARY_PATH", value = ld_library_path), - ], - ), - ], - ) - - features.append(sdk_env_feature) - return cc_common.create_cc_toolchain_config_info( ctx = ctx, abi_version = "%{tc_abi_version}", @@ -709,6 +705,5 @@ cc_toolchain_config = rule( "host_dir": attr.label(default = None), "target_dir": attr.label(default = None), "cxx_builtin_include_directories": attr.label(allow_files = True, default = None), - "ld_library_path_dirs": attr.label(allow_files = True, default = None), }, ) \ No newline at end of file