diff --git a/cuda/BUILD.bazel b/cuda/BUILD.bazel index e49fa85c..b0b2cf8a 100644 --- a/cuda/BUILD.bazel +++ b/cuda/BUILD.bazel @@ -4,6 +4,7 @@ load( "bool_flag", "string_flag", ) +load("//cuda/private:platforms.bzl", "SUPPORTED_PLATFORMS") load("//cuda/private:rules/flags.bzl", "cuda_archs_flag", "repeatable_string_flag") package(default_visibility = ["//visibility:public"]) @@ -38,6 +39,37 @@ config_setting( flag_values = {"@cuda//:valid_toolchain_found": "True"}, ) +string_flag( + name = "version", + build_setting_default = "13.0.0", +) + +string_flag( + name = "target_platform", + build_setting_default = "linux-x86_64", + values = SUPPORTED_PLATFORMS, +) + +[ + config_setting( + name = "target_platform_is_{}".format(platform.replace("-", "_")), + flag_values = {":target_platform": platform}, + ) for platform in SUPPORTED_PLATFORMS +] + +string_flag( + name = "exec_platform", + build_setting_default = "linux-x86_64", + values = SUPPORTED_PLATFORMS, +) + +[ + config_setting( + name = "exec_platform_is_{}".format(platform.replace("-", "_")), + flag_values = {":exec_platform": platform}, + ) for platform in SUPPORTED_PLATFORMS +] + # Command line flag to specify the list of CUDA architectures to compile for. # # Provides CudaArchsInfo of the list of archs to build. diff --git a/cuda/defs.bzl b/cuda/defs.bzl index e3fdbab3..c2d3ea1a 100644 --- a/cuda/defs.bzl +++ b/cuda/defs.bzl @@ -3,6 +3,7 @@ Core rules for building CUDA projects. """ load("//cuda/private:defs.bzl", _requires_cuda = "requires_cuda") +load("//cuda/private:errors.bzl", _unsupported_cuda_version = "unsupported_cuda_version", _unsupported_cuda_platform = "unsupported_cuda_platform") load("//cuda/private:macros/cuda_binary.bzl", _cuda_binary = "cuda_binary") load("//cuda/private:macros/cuda_test.bzl", _cuda_test = "cuda_test") load("//cuda/private:os_helpers.bzl", _cc_import_versioned_sos = "cc_import_versioned_sos", _if_linux = "if_linux", _if_windows = "if_windows") @@ -47,3 +48,5 @@ if_windows = _if_windows cc_import_versioned_sos = _cc_import_versioned_sos requires_cuda = _requires_cuda +unsupported_cuda_version = _unsupported_cuda_version +unsupported_cuda_platform = _unsupported_cuda_platform diff --git a/cuda/dummy/BUILD.bazel b/cuda/dummy/BUILD.bazel index c474f707..00bc8b9a 100644 --- a/cuda/dummy/BUILD.bazel +++ b/cuda/dummy/BUILD.bazel @@ -6,13 +6,19 @@ cc_binary( defines = ["TOOLNAME=nvcc"], ) +cc_binary( + name = "cicc", + srcs = ["dummy.cpp"], + defines = ["TOOLNAME=cicc"], +) + cc_binary( name = "nvlink", srcs = ["dummy.cpp"], defines = ["TOOLNAME=nvlink"], ) -exports_files(["link.stub"]) +exports_files(["link.stub", "libdevice.10.bc"]) cc_binary( name = "bin2c", @@ -25,3 +31,10 @@ cc_binary( srcs = ["dummy.cpp"], defines = ["TOOLNAME=fatbinary"], ) + +# Empty cc_library that provides CcInfo for components not available in this CUDA version. +cc_library( + name = "dummy", + srcs = [], + hdrs = [], +) diff --git a/cuda/dummy/libdevice.10.bc b/cuda/dummy/libdevice.10.bc new file mode 100644 index 00000000..ae4819a4 --- /dev/null +++ b/cuda/dummy/libdevice.10.bc @@ -0,0 +1 @@ +#error libdevice.10.bc of cuda toolkit does not exist diff --git a/cuda/extensions.bzl b/cuda/extensions.bzl index 4eb5211d..86fde7fc 100644 --- a/cuda/extensions.bzl +++ b/cuda/extensions.bzl @@ -2,6 +2,7 @@ load("//cuda/private:redist_json_helper.bzl", "redist_json_helper") load("//cuda/private:repositories.bzl", "cuda_component", "cuda_toolkit") +load("//cuda:platform_alias_extension.bzl", "platform_alias_repo") cuda_component_tag = tag_class(attrs = { "name": attr.string(mandatory = True, doc = "Repo name for the deliverable cuda_component"), @@ -53,6 +54,9 @@ cuda_redist_json_tag = tag_class(attrs = { "URLs are tried in order until one succeeds, so you should list local mirrors first. " + "If all downloads fail, the rule will fail.", ), + "platforms": attr.string_list( + doc = "A list of platforms to generate components for.", + ), "version": attr.string( doc = "Generate a URL by using the specified version." + "This URL will be tried after all URLs specified in the `urls` attribute.", @@ -95,17 +99,20 @@ def _module_tag_to_dict(t): def _redist_json_impl(module_ctx, attr): url, json_object = redist_json_helper.get(module_ctx, attr) redist_ver = redist_json_helper.get_redist_version(module_ctx, attr, json_object) - component_specs = redist_json_helper.collect_specs(module_ctx, attr, json_object, url) - mapping = {} - for spec in component_specs: - repo_name = redist_json_helper.get_repo_name(module_ctx, spec) - mapping[spec["component_name"]] = "@" + repo_name + platform_mapping = {} + for platform in attr.platforms: + component_specs = redist_json_helper.collect_specs(module_ctx, attr, platform, json_object, url) + mapping = {} + for spec in component_specs: + repo_name = redist_json_helper.get_repo_name(module_ctx, spec) + mapping[spec["component_name"]] = repo_name - attr = {key: value for key, value in spec.items()} - attr["name"] = repo_name - cuda_component(**attr) - return redist_ver, mapping + component_attr = {key: value for key, value in spec.items()} + component_attr["name"] = repo_name + "_" + platform.replace("-", "_") + "_" + redist_ver.replace(".", "_") + cuda_component(**component_attr) + platform_mapping[platform] = mapping + return redist_ver, platform_mapping def _impl(module_ctx): # Toolchain configuration is only allowed in the root module, or in rules_cuda. @@ -121,18 +128,47 @@ def _impl(module_ctx): components = rules_cuda.tags.component redist_jsons = rules_cuda.tags.redist_json toolkits = rules_cuda.tags.toolkit - for component in components: cuda_component(**_module_tag_to_dict(component)) - if len(redist_jsons) > 1: - fail("Using multiple cuda.redist_json is not supported yet.") - redist_version = None components_mapping = None - for redist_json in redist_jsons: - redist_version, components_mapping = _redist_json_impl(module_ctx, redist_json) + redist_versions = [] + redist_components_mapping = {} + # Track all versioned repositories for each component and platform. + versioned_repos = {} + for redist_json in redist_jsons: + components_mapping = {} + redist_version, platform_mapping = _redist_json_impl(module_ctx, redist_json) + redist_versions.append(redist_version) + for platform in platform_mapping.keys(): + for component_name, repo_name in platform_mapping[platform].items(): + redist_components_mapping[component_name] = repo_name + + # Track the versioned repo name for this component/platform/version. + if component_name not in versioned_repos: + versioned_repos[component_name] = {} + if platform not in versioned_repos[component_name]: + versioned_repos[component_name][platform] = {} + versioned_repos[component_name][platform][redist_version] = repo_name + "_" + platform.replace("-", "_") + "_" + redist_version.replace(".", "_") + + for component_name in redist_components_mapping.keys(): + # Build dictionaries mapping versions to repo names for each platform. + x86_64_repos = {ver: versioned_repos[component_name]["linux-x86_64"][ver] for ver in redist_versions if "linux-x86_64" in versioned_repos[component_name] and ver in versioned_repos[component_name]["linux-x86_64"]} + aarch64_repos = {ver: versioned_repos[component_name]["linux-aarch64"][ver] for ver in redist_versions if "linux-aarch64" in versioned_repos[component_name] and ver in versioned_repos[component_name]["linux-aarch64"]} + sbsa_repos = {ver: versioned_repos[component_name]["linux-sbsa"][ver] for ver in redist_versions if "linux-sbsa" in versioned_repos[component_name] and ver in versioned_repos[component_name]["linux-sbsa"]} + + platform_alias_repo( + name = redist_components_mapping[component_name], + repo_name = redist_components_mapping[component_name], + component_name = component_name, + linux_x86_64_repos = x86_64_repos, + linux_aarch64_repos = aarch64_repos, + linux_sbsa_repos = sbsa_repos, + versions = redist_versions, + ) + components_mapping[component_name] = "@" + redist_components_mapping[component_name] registrations = {} for toolkit in toolkits: if toolkit.name in registrations.keys(): @@ -148,7 +184,16 @@ def _impl(module_ctx): for _, toolkit in registrations.items(): if components_mapping != None: - cuda_toolkit(name = toolkit.name, components_mapping = components_mapping, version = redist_version) + # Always use the maximum version so the toolkit includes all components. + # Components that don't exist in older versions will fall back to dummy. + toolkit_version = redist_versions[0] + for ver in redist_versions: + ver_parts = [int(x) for x in ver.split(".")] + tv_parts = [int(x) for x in toolkit_version.split(".")] + if ver_parts > tv_parts: + toolkit_version = ver + + cuda_toolkit(name = toolkit.name, components_mapping = components_mapping, version = toolkit_version) else: cuda_toolkit(**_module_tag_to_dict(toolkit)) diff --git a/cuda/platform_alias_extension.bzl b/cuda/platform_alias_extension.bzl new file mode 100644 index 00000000..bd1742b3 --- /dev/null +++ b/cuda/platform_alias_extension.bzl @@ -0,0 +1,160 @@ +"""Module extension for creating platform-specific aliases for external dependencies. + +This extension creates repositories with alias targets that select between x86_64 and ARM64 +repositories based on the build platform. It also selects between versions of the component. +""" + +load("//cuda/private:platforms.bzl", "SUPPORTED_PLATFORMS") +load("//cuda/private:templates/registry.bzl", "REGISTRY") + +# Use REGISTRY as the source of truth for component targets +TARGET_MAPPING = REGISTRY + +def _platform_alias_repo_impl(ctx): + """Implementation of the platform_alias_repo repository rule. + + Args: + ctx: Repository context with attributes x86_repo, arm64_repo, and targets. + """ + + # Generate BUILD.bazel content with platform-specific aliases + build_content = ["# Generated by platform_alias_repo rule", ""] + + # Add load statement for alias + build_content.append('load("@rules_cuda//cuda:defs.bzl", "unsupported_cuda_version", "unsupported_cuda_platform")') + build_content.append("") + + build_content.append("[") + build_content.append(" config_setting(") + build_content.append(' name = "version_is_{}".format(version.replace(".", "_")),') + build_content.append(' flag_values = {"@rules_cuda//cuda:version": "{}".format(version)},') + build_content.append(" )") + build_content.append(" for version in {}".format(ctx.attr.versions)) + build_content.append("]") + build_content.append("") + + build_content.append('unsupported_cuda_version(name = "unsupported_cuda_version", component = "{}", available_versions = {})'.format(ctx.attr.component_name, ctx.attr.versions)) + build_content.append("") + + # Build a target for the name of the repo (only if at least one platform is available). + platform_type = "exec" if ctx.attr.component_name in ["nvcc", "nvvm"] else "target" + + # Check which platforms are available (have at least one version). + platforms_available = [] + if len(ctx.attr.linux_x86_64_repos) > 0: + platforms_available.append("linux-x86_64") + if len(ctx.attr.linux_sbsa_repos) > 0: + platforms_available.append("linux-sbsa") + if len(ctx.attr.linux_aarch64_repos) > 0: + platforms_available.append("linux-aarch64") + + # Always create unsupported_cuda_platform target - it's used as the default case + # in select() when no platform condition matches. + build_content.append('unsupported_cuda_platform(name = "unsupported_cuda_platform", component = "{}", available_platforms = {})'.format(ctx.attr.component_name, platforms_available)) + build_content.append("") + + # Only generate target aliases if this component is in TARGET_MAPPING. + if ctx.attr.component_name not in TARGET_MAPPING: + # Write the BUILD.bazel file with just the main alias. + ctx.file("BUILD.bazel", "\n".join(build_content)) + return + + for target in TARGET_MAPPING[ctx.attr.component_name]: + # Create alias for each target with platform selection. + # Always add conditions for ALL platforms so that builds on any platform + # have a matching select condition. Platforms where the component doesn't + # exist will use a dummy target. + target_name = target if target.find("/") == -1 else target.split("/")[-1] + + # Determine appropriate dummy target based on the target name. + dummy_target = "@rules_cuda//cuda/dummy:dummy" + if target_name == "cicc": + dummy_target = "@rules_cuda//cuda/dummy:cicc" + elif target_name == "libdevice.10.bc": + dummy_target = "@rules_cuda//cuda/dummy:libdevice.10.bc" + + build_content.append("alias(") + build_content.append(' name = "{}",'.format(target_name)) + build_content.append(" actual = select({") + # Add conditions for ALL platforms, using dummy for unavailable ones. + for platform in SUPPORTED_PLATFORMS: + platform_suffix = platform.replace("-", "_") + build_content.append(' "@rules_cuda//cuda:{}_platform_is_{}":'.format(platform_type, platform_suffix)) + if platform in platforms_available: + build_content.append(' ":{}_{}",'.format(platform_suffix, target_name)) + else: + # Platform doesn't have this component, use dummy target. + build_content.append(' "{}",'.format(dummy_target)) + build_content.append(' "//conditions:default": ":unsupported_cuda_platform",') + build_content.append(" }),") + build_content.append(' visibility = ["//visibility:public"],') + build_content.append(")") + build_content.append("") + + # Generate platform-specific aliases for ALL platforms. + # Platforms where the component exists get version-based selection. + # Platforms where it doesn't exist get dummy targets for all versions. + # This ensures builds on any platform have matching select conditions. + + platform_repos_map = { + "linux-x86_64": ctx.attr.linux_x86_64_repos, + "linux-sbsa": ctx.attr.linux_sbsa_repos, + "linux-aarch64": ctx.attr.linux_aarch64_repos, + } + + for platform in SUPPORTED_PLATFORMS: + platform_suffix = platform.replace("-", "_") + repos_dict = platform_repos_map[platform] + platform_available = platform in platforms_available + + build_content.append("alias(") + build_content.append(' name = "{}_{}",'.format(platform_suffix, target_name)) + build_content.append(" actual = select({") + + for version in ctx.attr.versions: + build_content.append(' ":version_is_{}": '.format(version.replace(".", "_"))) + if platform_available and version in repos_dict: + repo_name = repos_dict[version] + build_content.append(' "@{}//{}",'.format(repo_name, target if target.find(":") != -1 else ":" + target)) + else: + # Platform doesn't have this component for this version, use dummy. + build_content.append(' "{}",'.format(dummy_target)) + build_content.append(' "//conditions:default": ":unsupported_cuda_version",') + + build_content.append(" }),") + build_content.append(' visibility = ["//visibility:public"],') + build_content.append(")") + build_content.append("") + + # Write the BUILD.bazel file + ctx.file("BUILD.bazel", "\n".join(build_content)) + +platform_alias_repo = repository_rule( + implementation = _platform_alias_repo_impl, + attrs = { + "repo_name": attr.string( + mandatory = True, + doc = "Original name of the repository", + ), + "component_name": attr.string( + mandatory = True, + doc = "Name of the component", + ), + "linux_x86_64_repos": attr.string_dict( + default = {}, + doc = "Dictionary mapping versions to x86_64 repository names", + ), + "linux_aarch64_repos": attr.string_dict( + default = {}, + doc = "Dictionary mapping versions to ARM64/Jetpack repository names", + ), + "linux_sbsa_repos": attr.string_dict( + default = {}, + doc = "Dictionary mapping versions to SBSA repository names", + ), + "versions": attr.string_list( + mandatory = True, + doc = "List of versions to create aliases for", + ), + }, +) diff --git a/cuda/private/errors.bzl b/cuda/private/errors.bzl new file mode 100644 index 00000000..8d358721 --- /dev/null +++ b/cuda/private/errors.bzl @@ -0,0 +1,27 @@ +def _unsupported_cuda_version_impl(ctx): + fail("CUDA component '{}' is not available for the selected CUDA version. Available versions: {}".format( + ctx.attr.component, + ", ".join(ctx.attr.available_versions) + )) + +unsupported_cuda_version = rule( + implementation = _unsupported_cuda_version_impl, + attrs = { + "component": attr.string(mandatory = True), + "available_versions": attr.string_list(mandatory = True), + }, +) + +def _unsupported_cuda_platform_impl(ctx): + fail("CUDA component '{}' is not available for the selected platform. Available platforms: {}".format( + ctx.attr.component, + ", ".join(ctx.attr.available_platforms) + )) + +unsupported_cuda_platform = rule( + implementation = _unsupported_cuda_platform_impl, + attrs = { + "component": attr.string(mandatory = True), + "available_platforms": attr.string_list(mandatory = True), + }, +) diff --git a/cuda/private/platforms.bzl b/cuda/private/platforms.bzl new file mode 100644 index 00000000..c4816db3 --- /dev/null +++ b/cuda/private/platforms.bzl @@ -0,0 +1,9 @@ +"""Platform constants for CUDA toolkit support.""" + +# Platforms supported by the CUDA redistribution and alias system. +# These are the platforms for which we generate component aliases. +SUPPORTED_PLATFORMS = [ + "linux-x86_64", + "linux-sbsa", + "linux-aarch64", +] diff --git a/cuda/private/redist_json_helper.bzl b/cuda/private/redist_json_helper.bzl index decdc48d..b9a7f998 100644 --- a/cuda/private/redist_json_helper.bzl +++ b/cuda/private/redist_json_helper.bzl @@ -27,9 +27,21 @@ def _get(ctx, attr): if len(urls) == 0: fail("`urls` or `version` must be specified.") + # Use the name of the repository or tag to avoid collisions when multiple + # redist_json are defined. + name = getattr(attr, "name", None) + if not name and hasattr(ctx, "name"): + name = ctx.name + + # In case name is still not found (unlikely), use a default + if not name: + name = "default" + + output_filename = "redist_{}.json".format(name) + for url in urls: ret = ctx.download( - output = "redist.json", + output = output_filename, integrity = attr.integrity, sha256 = attr.sha256, url = url, @@ -41,7 +53,7 @@ def _get(ctx, attr): if the_url == None: fail("Failed to retrieve the redist json file.") - return the_url, json.decode(ctx.read("redist.json")) + return the_url, json.decode(ctx.read(output_filename)) def _get_redist_version(ctx, attr, redist): """Get version string. @@ -58,7 +70,7 @@ def _get_redist_version(ctx, attr, redist): return redist_ver -def _collect_specs(ctx, attr, redist, the_url): +def _collect_specs(ctx, attr, platform, redist, the_url): """Convert redistrib_.json content to the specs for instantiating cuda_component repos. List of specs, aka, list of dicts with cuda_component attrs. @@ -66,19 +78,12 @@ def _collect_specs(ctx, attr, redist, the_url): Args: ctx: repository_ctx | module_ctx attr: cuda_component repo attr or cuda_redist_json_tag + platform: string, the platform for which we are collecting specs redist: json object, read from the redistrib_.json file. the_url: string, the very unique url from which we get the redistrib_.json file. """ specs = [] - os = None - if _is_linux(ctx): - os = "linux" - elif _is_windows(ctx): - os = "windows" - - arch = "x86_64" # TODO: support cross compiling - platform = "{os}-{arch}".format(os = os, arch = arch) all_components_on_platform = [k for k, v in FULL_COMPONENT_NAME.items() if v in redist and platform in redist[v]] components = attr.components if attr.components else all_components_on_platform @@ -111,10 +116,6 @@ def _get_repo_name(ctx, spec): """ repo_name = "cuda_" + spec["component_name"] - version = spec.get("version", None) - if version != None: - repo_name = repo_name + "_v" + version - return repo_name redist_json_helper = struct( diff --git a/cuda/private/repositories.bzl b/cuda/private/repositories.bzl index 04d0bdd6..affa29f6 100644 --- a/cuda/private/repositories.bzl +++ b/cuda/private/repositories.bzl @@ -111,18 +111,18 @@ def _detect_deliverable_cuda_toolkit(repository_ctx): nvcc_repo = repository_ctx.attr.components_mapping["nvcc"] bin_ext = ".exe" if _is_windows(repository_ctx) else "" - nvcc = "{}//:nvcc/bin/nvcc{}".format(nvcc_repo, bin_ext) - nvlink = "{}//:nvcc/bin/nvlink{}".format(nvcc_repo, bin_ext) - link_stub = "{}//:nvcc/bin/crt/link.stub".format(nvcc_repo) - bin2c = "{}//:nvcc/bin/bin2c{}".format(nvcc_repo, bin_ext) - fatbinary = "{}//:nvcc/bin/fatbinary{}".format(nvcc_repo, bin_ext) + nvcc = "{}//:nvcc{}".format(nvcc_repo, bin_ext) + nvlink = "{}//:nvlink{}".format(nvcc_repo, bin_ext) + link_stub = "{}//:link.stub".format(nvcc_repo) + bin2c = "{}//:bin2c{}".format(nvcc_repo, bin_ext) + fatbinary = "{}//:fatbinary{}".format(nvcc_repo, bin_ext) cicc = None libdevice = None if int(cuda_version_major) >= 13: nvvm_repo = repository_ctx.attr.components_mapping["nvvm"] - cicc = "{}//:nvvm/nvvm/bin/cicc{}".format(nvvm_repo, bin_ext) # TODO: can we use @cuda//:cicc? - libdevice = "{}//:nvvm/nvvm/libdevice/libdevice.10.bc".format(nvvm_repo) # TODO: can we use @cuda//:libdevice? + cicc = "{}//:cicc{}".format(nvvm_repo, bin_ext) + libdevice = "{}//:libdevice.10.bc".format(nvvm_repo) return struct( path = None, # scattered components diff --git a/cuda/private/template_helper.bzl b/cuda/private/template_helper.bzl index feaec41c..e5e1c2ff 100644 --- a/cuda/private/template_helper.bzl +++ b/cuda/private/template_helper.bzl @@ -28,13 +28,16 @@ def _expand_lctk_cuda(repository_ctx, components): def _expand_dctk_cuda(repository_ctx, components): tpl_label = Label("//cuda/private:templates/BUILD.dctk_cuda") - all_files_srcs_line = [comp + "_all_files" for comp in components.keys()] + # Filter out components with empty REGISTRY entries + valid_components = [comp for comp in components.keys() if len(REGISTRY[comp]) > 0] + + all_files_srcs_line = [comp + "_all_files" for comp in valid_components] all_files_srcs_line = "srcs = " + repr(all_files_srcs_line) - license_srcs_line = [comp + "_license" for comp in components.keys()] + license_srcs_line = [comp + "_license" for comp in valid_components] license_srcs_line = "srcs = " + repr(license_srcs_line) - headers_deps_line = [comp + "_headers" for comp in components.keys()] + headers_deps_line = [comp + "_headers" for comp in valid_components] headers_deps_line = "deps = " + repr(headers_deps_line) substitutions = { diff --git a/cuda/private/templates/BUILD.cufile b/cuda/private/templates/BUILD.cufile index e69de29b..7a64f29b 100644 --- a/cuda/private/templates/BUILD.cufile +++ b/cuda/private/templates/BUILD.cufile @@ -0,0 +1,19 @@ +cc_import_versioned_sos( + name = "cufile_so", + shared_library = "%{component_name}/%{libpath}/libcufile.so", +) + +cc_import_versioned_sos( + name = "cufile_rdma_so", + shared_library = "%{component_name}/%{libpath}/libcufile_rdma.so", +) + +cc_library( + name = "cufile", + deps = [ + ":%{component_name}_headers", + ":cufile_so", + ":cufile_rdma_so", + ], + target_compatible_with = ["@platforms//os:linux"], +) diff --git a/cuda/private/templates/BUILD.nvcc b/cuda/private/templates/BUILD.nvcc index 5f71863f..75bf0c4c 100644 --- a/cuda/private/templates/BUILD.nvcc +++ b/cuda/private/templates/BUILD.nvcc @@ -1,3 +1,38 @@ +# Export individual executables as simple target names +exports_files([ + "%{component_name}/bin/nvcc", + "%{component_name}/bin/nvlink", + "%{component_name}/bin/bin2c", + "%{component_name}/bin/fatbinary", + "%{component_name}/bin/crt/link.stub", +], visibility = ["//visibility:public"]) + +# Create aliases with simple names for toolchain compatibility +alias( + name = "nvcc", + actual = "%{component_name}/bin/nvcc", +) + +alias( + name = "nvlink", + actual = "%{component_name}/bin/nvlink", +) + +alias( + name = "bin2c", + actual = "%{component_name}/bin/bin2c", +) + +alias( + name = "fatbinary", + actual = "%{component_name}/bin/fatbinary", +) + +alias( + name = "link.stub", + actual = "%{component_name}/bin/crt/link.stub", +) + filegroup( name = "compiler_root", srcs = [":nvcc"], diff --git a/cuda/private/templates/BUILD.nvvm b/cuda/private/templates/BUILD.nvvm index e69de29b..d55f10b4 100644 --- a/cuda/private/templates/BUILD.nvvm +++ b/cuda/private/templates/BUILD.nvvm @@ -0,0 +1,23 @@ +# Export individual files as simple target names +exports_files([ + "%{component_name}/nvvm/bin/cicc", + "%{component_name}/nvvm/libdevice/libdevice.10.bc", +], visibility = ["//visibility:public"]) + +# Create aliases with simple names for toolchain compatibility +alias( + name = "cicc", + actual = "%{component_name}/nvvm/bin/cicc", +) + +alias( + name = "libdevice.10.bc", + actual = "%{component_name}/nvvm/libdevice/libdevice.10.bc", +) + +# Alias for generic libdevice name +alias( + name = "libdevice", + actual = ":libdevice.10.bc", +) + diff --git a/cuda/private/templates/registry.bzl b/cuda/private/templates/registry.bzl index f31ef825..7ba9c958 100644 --- a/cuda/private/templates/registry.bzl +++ b/cuda/private/templates/registry.bzl @@ -1,14 +1,14 @@ # map short component name to consumable targets REGISTRY = { "cudart": ["cudart_all_files", "cudart_license", "cudart_headers", "cuda", "cuda_runtime", "cuda_runtime_static"], - "nvcc": ["nvcc_all_files", "nvcc_license", "nvcc_headers", "compiler_root", "compiler_deps", "nvptxcompiler"], - "nvvm": ["nvvm_all_files", "nvvm_license", "nvvm_headers", "cicc", "libdevice"], + "nvcc": ["nvcc_all_files", "nvcc_license", "nvcc_headers", "compiler_root", "compiler_deps", "nvptxcompiler", "nvcc", "nvlink", "bin2c", "fatbinary", "link.stub"], + "nvvm": ["nvvm_all_files", "nvvm_license", "nvvm_headers", "cicc", "libdevice", "libdevice.10.bc"], "cccl": ["cccl_all_files", "cccl_license", "cccl_headers", "libcudacxx", "cub", "thrust"], "crt": ["crt_all_files", "crt_license", "crt_headers", "crt"], - "culibos": ["culibos_all_files", "culibos_license", "culibos_a"], # culibos_a is not for end users + "culibos": ["culibos_all_files", "culibos_license", "culibos_headers", "culibos_a"], # culibos_a is not for end users. "cublas": ["cublas_all_files", "cublas_license", "cublas_headers", "cublas"], "cufft": ["cufft_all_files", "cufft_license", "cufft_headers", "cufft", "cufft_static"], - "cufile": [], + "cufile": ["cufile", "cufile_all_files", "cufile_header_files", "cufile_headers", "cufile_license"], "cupti": ["cupti_all_files", "cupti_license", "cupti_headers", "cupti", "nvperf_host", "nvperf_target"], "curand": ["curand_all_files", "curand_license", "curand_headers", "curand"], "cusolver": ["cusolver_all_files", "cusolver_license", "cusolver_headers", "cusolver"],