-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.devcontainer: clang-based build inside the container.
This allows the `bsv.cc.compdb.generate` command in vscode to generate a valid `compile_commands.json` database, usable by clangd. Otherwise, GCC command flags used are unusable by `clangd` which we install into the devcontainer.
- Loading branch information
Showing
4 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Based on https://bazel.build/versions/6.5.0/tutorials/ccp-toolchain-config | ||
|
||
load(":cc_toolchain_config.bzl", "cc_toolchain_config") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_toolchain_suite( | ||
name = "clang_suite", | ||
toolchains = { | ||
"k8": ":k8_toolchain", | ||
}, | ||
) | ||
filegroup(name = "empty") | ||
|
||
cc_toolchain( | ||
name = "k8_toolchain", | ||
toolchain_identifier = "k8-toolchain", | ||
toolchain_config = ":k8_toolchain_config", | ||
all_files = ":empty", | ||
compiler_files = ":empty", | ||
dwp_files = ":empty", | ||
linker_files = ":empty", | ||
objcopy_files = ":empty", | ||
strip_files = ":empty", | ||
supports_param_files = 0, | ||
) | ||
cc_toolchain_config(name = "k8_toolchain_config") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Based on https://bazel.build/versions/6.5.0/tutorials/ccp-toolchain-config | ||
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") | ||
load( | ||
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", | ||
"feature", | ||
"flag_group", | ||
"flag_set", | ||
"tool_path", | ||
) | ||
|
||
all_link_actions = [ # NEW | ||
ACTION_NAMES.cpp_link_executable, | ||
ACTION_NAMES.cpp_link_dynamic_library, | ||
ACTION_NAMES.cpp_link_nodeps_dynamic_library, | ||
] | ||
|
||
def _impl(ctx): | ||
tool_paths = [ | ||
tool_path( | ||
name = "gcc", | ||
path = "/usr/bin/clang", | ||
), | ||
tool_path( | ||
name = "ld", | ||
path = "/usr/bin/ld", | ||
), | ||
tool_path( | ||
name = "ar", | ||
path = "/usr/bin/ar", | ||
), | ||
tool_path( | ||
name = "cpp", | ||
path = "/bin/false", | ||
), | ||
tool_path( | ||
name = "gcov", | ||
path = "/bin/false", | ||
), | ||
tool_path( | ||
name = "nm", | ||
path = "/bin/false", | ||
), | ||
tool_path( | ||
name = "objdump", | ||
path = "/bin/false", | ||
), | ||
tool_path( | ||
name = "strip", | ||
path = "/bin/false", | ||
), | ||
] | ||
|
||
features = [ | ||
feature( | ||
name = "default_linker_flags", | ||
enabled = True, | ||
flag_sets = [ | ||
flag_set( | ||
actions = all_link_actions, | ||
flag_groups = ([ | ||
flag_group( | ||
flags = [ | ||
"-lstdc++", | ||
"-lm", # added because floorf from glibc was missing | ||
], | ||
), | ||
]), | ||
), | ||
], | ||
), | ||
] | ||
|
||
|
||
return cc_common.create_cc_toolchain_config_info( | ||
ctx = ctx, | ||
features = features, | ||
cxx_builtin_include_directories = [ | ||
"/usr/lib/llvm-10/lib/clang/10.0.0/include", # updated to current image's version | ||
"/usr/include", | ||
], | ||
toolchain_identifier = "local", | ||
host_system_name = "local", | ||
target_system_name = "local", | ||
target_cpu = "k8", | ||
target_libc = "unknown", | ||
compiler = "clang", | ||
abi_version = "unknown", | ||
abi_libc_version = "unknown", | ||
tool_paths = tool_paths, | ||
) | ||
|
||
cc_toolchain_config = rule( | ||
implementation = _impl, | ||
attrs = {}, | ||
provides = [CcToolchainConfigInfo], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters