Generate bindings for C++ standard library
This cl implements a new bindings_for_toolchain_headers rule that generates bindings for the C++ standard library headers. The list of headers that we consider public is located under devtools/rust/cc_interop/rs_bindings_from_cc/BUILD. I'll expand it in a followup cl.
Currently the grte headers are considered to be non-public headers that are part of the C++ standard library. We'll create a separate target for them in a followup cl.
We will not be generating bindings for the clang builtin headers.
PiperOrigin-RevId: 426237240
diff --git a/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_aspect.bzl b/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_aspect.bzl
index bb0a46f..cb588fa 100644
--- a/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_aspect.bzl
+++ b/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_aspect.bzl
@@ -7,14 +7,10 @@
)
load(
"//rs_bindings_from_cc/bazel_support:rust_bindings_from_cc_utils.bzl",
- "GeneratedBindingsInfo",
"RustBindingsFromCcInfo",
"bindings_attrs",
- "compile_cc",
- "compile_rust",
+ "generate_and_compile_bindings",
)
-load("//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
-load("//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
# buildifier: disable=bzl-visibility
load("//third_party/bazel_rules/rules_rust/rust/private:providers.bzl", "DepVariantInfo")
@@ -63,6 +59,10 @@
if ctx.executable._generator.basename == "fake_rust_bindings_from_cc":
return []
+ # If this target already provides bindings, we don't need to run the bindings generator.
+ if RustBindingsFromCcInfo in target:
+ return []
+
# This is not a C++ rule
if CcInfo not in target:
return []
@@ -89,6 +89,9 @@
t[RustBindingsFromCcInfo].targets_and_headers
for t in ctx.rule.attr.deps
if RustBindingsFromCcInfo in t
+ ] + [
+ # TODO(b/217667751): This is a huge list of headers; pass it as a file instead;
+ ctx.attr._std[RustBindingsFromCcInfo].targets_and_headers,
],
)
@@ -100,117 +103,46 @@
targets_and_headers = targets_and_headers,
)
- hdrs_command_line = []
- if public_hdrs:
- hdrs_command_line.append("--public_headers=" + (",".join([x.short_path for x in public_hdrs])))
-
header_includes = []
for hdr in public_hdrs:
header_includes.append("-include")
header_includes.append(hdr.short_path)
- cc_toolchain = find_cpp_toolchain(ctx)
-
- feature_configuration = cc_common.configure_features(
- ctx = ctx,
- cc_toolchain = cc_toolchain,
- requested_features = ctx.features,
- unsupported_features = ctx.disabled_features + ["module_maps"],
- )
-
- cc_output = ctx.actions.declare_file(ctx.label.name + "_rust_api_impl.cc")
- rs_output = ctx.actions.declare_file(ctx.label.name + "_rust_api.rs")
-
stl = ctx.attr._stl[CcInfo].compilation_context
compilation_context = target[CcInfo].compilation_context
- variables = cc_common.create_compile_variables(
- feature_configuration = feature_configuration,
- cc_toolchain = cc_toolchain,
- user_compile_flags = ctx.fragments.cpp.copts +
- ctx.fragments.cpp.cxxopts +
- header_includes + (
- ctx.rule.attr.copts if hasattr(ctx.rule.attr, "copts") else []
- ),
- preprocessor_defines = compilation_context.defines,
- system_include_directories = depset(
- cc_toolchain.built_in_include_directories,
- transitive = [stl.system_includes, compilation_context.system_includes],
- ),
- include_directories = depset(transitive = [stl.includes, compilation_context.includes]),
- quote_include_directories = depset(
- transitive = [stl.quote_includes, compilation_context.quote_includes],
- ),
- variables_extension = {
- "rs_bindings_from_cc_tool": ctx.executable._generator.path,
- "rs_bindings_from_cc_flags": [
- "--rs_out",
- rs_output.path,
- "--cc_out",
- cc_output.path,
- ] + hdrs_command_line,
- "targets_and_headers": targets_and_headers,
- },
- )
- # Run the `rs_bindings_from_cc` to generate the _rust_api_impl.cc and _rust_api.rs files.
- cc_common.create_compile_action(
- actions = ctx.actions,
- action_name = ACTION_NAMES.rs_bindings_from_cc,
- feature_configuration = feature_configuration,
- cc_toolchain = cc_toolchain,
- source_file = public_hdrs[0],
- output_file = cc_output,
- grep_includes = ctx.file._grep_includes,
- additional_inputs = depset(
- public_hdrs + [ctx.executable._rustfmt, ctx.executable._generator] + ctx.files._rustfmt_cfg,
- ),
- additional_outputs = [rs_output],
- variables = variables,
- compilation_context = compilation_context,
- )
-
- # Compile the "_rust_api_impl.cc" file
- cc_info = compile_cc(
+ return generate_and_compile_bindings(
ctx,
ctx.rule.attr,
- cc_toolchain,
- feature_configuration,
- cc_output,
- [target[CcInfo]] + [
+ compilation_context = compilation_context,
+ public_hdrs = public_hdrs,
+ header_includes = header_includes,
+ action_inputs = public_hdrs + ctx.files._builtin_hdrs,
+ targets_and_headers = targets_and_headers,
+ deps_for_cc_file = [target[CcInfo]] + [
dep[RustBindingsFromCcInfo].cc_info
for dep in ctx.rule.attr.deps
if RustBindingsFromCcInfo in dep
- ] + ctx.attr._generator[GeneratedFilesDepsInfo].deps_for_cc_file,
- )
-
- # Compile the "_rust_api.rs" file
- dep_variant_info = compile_rust(
- ctx,
- ctx.rule.attr,
- rs_output,
- [
+ ] + ctx.attr._generator[GeneratedFilesDepsInfo].deps_for_cc_file + [
+ ctx.attr._std[RustBindingsFromCcInfo].cc_info,
+ ],
+ deps_for_rs_file = [
dep[RustBindingsFromCcInfo].dep_variant_info
for dep in ctx.rule.attr.deps
if RustBindingsFromCcInfo in dep
- ] + ctx.attr._generator[GeneratedFilesDepsInfo].deps_for_rs_file,
+ ] + ctx.attr._generator[GeneratedFilesDepsInfo].deps_for_rs_file + [
+ ctx.attr._std[RustBindingsFromCcInfo].dep_variant_info,
+ ],
)
- return [
- RustBindingsFromCcInfo(
- cc_info = cc_info,
- dep_variant_info = dep_variant_info,
- targets_and_headers = targets_and_headers,
- ),
- GeneratedBindingsInfo(
- cc_file = cc_output,
- rust_file = rs_output,
- ),
- ]
-
rust_bindings_from_cc_aspect = aspect(
implementation = _rust_bindings_from_cc_aspect_impl,
attr_aspects = ["deps"],
- attrs = bindings_attrs,
+ attrs = dict(bindings_attrs.items() + {
+ "_std": attr.label(
+ default = "//rs_bindings_from_cc:cc_std",
+ ),
+ }.items()),
toolchains = [
"//third_party/bazel_rules/rules_rust/rust:toolchain",
"//tools/cpp:toolchain_type",
diff --git a/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_utils.bzl b/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_utils.bzl
index 50a74f2..699bde0 100644
--- a/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_utils.bzl
+++ b/rs_bindings_from_cc/blaze_support/rust_bindings_from_cc_utils.bzl
@@ -6,6 +6,8 @@
# buildifier: disable=bzl-visibility
load("//third_party/bazel_rules/rules_rust/rust/private:rustc.bzl", "rustc_compile_action")
+load("//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
+load("//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
RustBindingsFromCcInfo = provider(
doc = ("A provider that contains compile and linking information for the generated" +
@@ -27,7 +29,7 @@
},
)
-def compile_cc(
+def _compile_cc(
ctx,
attr,
cc_toolchain,
@@ -74,7 +76,7 @@
linking_context = linking_context,
)
-def compile_rust(ctx, attr, src, deps):
+def _compile_rust(ctx, attr, src, deps):
"""Compiles a Rust source file.
Args:
@@ -131,6 +133,173 @@
build_info = None,
)
+def _generate_bindings(
+ ctx,
+ attr,
+ cc_toolchain,
+ feature_configuration,
+ compilation_context,
+ public_hdrs,
+ header_includes,
+ action_inputs,
+ targets_and_headers):
+ """Runs the bindings generator.
+
+ Args:
+ ctx: The rule context.
+ attr: The current rule's attributes.
+ cc_toolchain: The cc_toolchain.
+ feature_configuration: The feature configuration.
+ compilation_context: The compilation context for this action.
+ public_hdrs: A list of headers to be passed to the tool via the "--public_headers" flag.
+ header_includes: A list of flags to be passed to the command line with "-include".
+ action_inputs: A list of inputs to the bindings generating action.
+ targets_and_headers: A depset of strings, each one representing mapping of target to " +
+ "its headers in json format.
+
+ Returns:
+ tuple(cc_output, rs_output): The generated source files.
+ """
+ cc_output = ctx.actions.declare_file(ctx.label.name + "_rust_api_impl.cc")
+ rs_output = ctx.actions.declare_file(ctx.label.name + "_rust_api.rs")
+
+ variables = cc_common.create_compile_variables(
+ feature_configuration = feature_configuration,
+ cc_toolchain = cc_toolchain,
+ system_include_directories = depset(
+ direct = [
+ cc_toolchain.built_in_include_directories[0],
+ cc_toolchain.built_in_include_directories[1].replace("stable", "llvm_unstable"),
+ cc_toolchain.built_in_include_directories[2],
+ ],
+ transitive = [
+ compilation_context.system_includes,
+ ],
+ ),
+ include_directories = compilation_context.includes,
+ quote_include_directories = compilation_context.quote_includes,
+ user_compile_flags = ctx.fragments.cpp.copts +
+ ctx.fragments.cpp.cxxopts +
+ header_includes + (
+ attr.copts if hasattr(attr, "copts") else []
+ ),
+ preprocessor_defines = compilation_context.defines,
+ variables_extension = {
+ "rs_bindings_from_cc_tool": ctx.executable._generator.path,
+ "rs_bindings_from_cc_flags": [
+ "--rs_out",
+ rs_output.path,
+ "--cc_out",
+ cc_output.path,
+ ] + _get_hdrs_command_line(public_hdrs),
+ "targets_and_headers": targets_and_headers,
+ },
+ )
+
+ # Run the `rs_bindings_from_cc` to generate the _rust_api_impl.cc and _rust_api.rs files.
+ cc_common.create_compile_action(
+ compilation_context = compilation_context,
+ actions = ctx.actions,
+ action_name = ACTION_NAMES.rs_bindings_from_cc,
+ feature_configuration = feature_configuration,
+ cc_toolchain = cc_toolchain,
+ source_file = public_hdrs[0],
+ output_file = cc_output,
+ grep_includes = ctx.file._grep_includes,
+ additional_inputs = depset(
+ direct = action_inputs + [
+ ctx.executable._rustfmt,
+ ctx.executable._generator,
+ ] + ctx.files._rustfmt_cfg,
+ ),
+ additional_outputs = [rs_output],
+ variables = variables,
+ )
+ return (cc_output, rs_output)
+
+def generate_and_compile_bindings(
+ ctx,
+ attr,
+ compilation_context,
+ public_hdrs,
+ header_includes,
+ action_inputs,
+ targets_and_headers,
+ deps_for_cc_file,
+ deps_for_rs_file):
+ """Runs the bindings generator.
+
+ Args:
+ ctx: The rule context.
+ attr: The current rule's attributes.
+ compilation_context: The current compilation context.
+ public_hdrs: A list of headers to be passed to the tool via the "--public_headers" flag.
+ header_includes: A list of flags to be passed to the command line with "-include".
+ action_inputs: A list of inputs to the bindings generating action.
+ targets_and_headers: A depset of strings, each one representing mapping of target to " +
+ "its headers in json format.
+ deps_for_cc_file: list[CcInfo]: CcInfos needed by the generated C++ source file.
+ deps_for_rs_file: list[DepVariantInfo]: DepVariantInfos needed by the generated Rust source file.
+
+ Returns:
+ A RustBindingsFromCcInfo containing the result of the compilation of the generated source
+ files, as well a GeneratedBindingsInfo provider containing the generated source files.
+ """
+ cc_toolchain = find_cpp_toolchain(ctx)
+
+ feature_configuration = cc_common.configure_features(
+ ctx = ctx,
+ cc_toolchain = cc_toolchain,
+ requested_features = ctx.features,
+ unsupported_features = ctx.disabled_features + ["module_maps"],
+ )
+
+ cc_output, rs_output = _generate_bindings(
+ ctx = ctx,
+ attr = attr,
+ cc_toolchain = cc_toolchain,
+ feature_configuration = feature_configuration,
+ compilation_context = compilation_context,
+ public_hdrs = public_hdrs,
+ header_includes = header_includes,
+ action_inputs = action_inputs,
+ targets_and_headers = targets_and_headers,
+ )
+
+ # Compile the "_rust_api_impl.cc" file
+ cc_info = _compile_cc(
+ ctx,
+ attr,
+ cc_toolchain,
+ feature_configuration,
+ cc_output,
+ deps_for_cc_file,
+ )
+
+ # Compile the "_rust_api.rs" file
+ dep_variant_info = _compile_rust(
+ ctx,
+ attr,
+ rs_output,
+ deps_for_rs_file,
+ )
+
+ return [
+ RustBindingsFromCcInfo(
+ cc_info = cc_info,
+ dep_variant_info = dep_variant_info,
+ targets_and_headers = targets_and_headers,
+ ),
+ GeneratedBindingsInfo(
+ cc_file = cc_output,
+ rust_file = rs_output,
+ ),
+ OutputGroupInfo(out = depset([cc_output, rs_output])),
+ ]
+
+def _get_hdrs_command_line(hdrs):
+ return ["--public_headers=" + ",".join([x.short_path for x in hdrs])]
+
bindings_attrs = {
"_cc_toolchain": attr.label(
default = "//tools/cpp:current_cc_toolchain",
@@ -168,4 +337,7 @@
allow_single_file = True,
cfg = "exec",
),
+ "_builtin_hdrs": attr.label(
+ default = "//rs_bindings_from_cc:builtin_headers",
+ ),
}
diff --git a/rs_bindings_from_cc/blaze_support/toolchain_headers.bzl b/rs_bindings_from_cc/blaze_support/toolchain_headers.bzl
new file mode 100644
index 0000000..559bcdd
--- /dev/null
+++ b/rs_bindings_from_cc/blaze_support/toolchain_headers.bzl
@@ -0,0 +1,82 @@
+# Part of the Crubit project, under the Apache License v2.0 with LLVM
+# Exceptions. See /LICENSE for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+load(
+ "//rs_bindings_from_cc/bazel_support:rust_bindings_from_cc_utils.bzl",
+ "bindings_attrs",
+ "generate_and_compile_bindings",
+)
+
+def _is_public_std_header(input, public_hdrs):
+ return ("grte" not in input.path and
+ input.basename in public_hdrs and
+ "experimental" not in input.short_path)
+
+def _collect_std_hdrs(input_list, public_hdrs):
+ return [hdr for hdr in input_list if _is_public_std_header(hdr, public_hdrs)]
+
+def _collect_nonstd_hdrs(input_list, public_hdrs):
+ return [hdr for hdr in input_list if not _is_public_std_header(hdr, public_hdrs)]
+
+def _bindings_for_toolchain_headers_impl(ctx):
+ std_hdrs = ctx.files.hdrs
+
+ # The clang builtin headers also contain some standard headers. We'll consider those part of
+ # the C++ Standard library target, so we generate bindings for them.
+ builtin_std_hdrs = _collect_std_hdrs(ctx.files._builtin_hdrs, ctx.attr.public_hdrs)
+ builtin_nonstd_hdrs = _collect_nonstd_hdrs(
+ ctx.files._builtin_hdrs,
+ ctx.attr.public_hdrs,
+ )
+
+ targets_and_headers = depset(
+ direct = [
+ json.encode({
+ "t": str(ctx.label),
+ "h": [hdr.path for hdr in std_hdrs + builtin_std_hdrs],
+ }),
+ json.encode({
+ "t": "//:_builtin_hdrs",
+ "h": [h.path for h in builtin_nonstd_hdrs],
+ }),
+ ],
+ )
+
+ public_std_hdrs = _collect_std_hdrs(std_hdrs, ctx.attr.public_hdrs)
+
+ header_includes = []
+ for hdr in public_std_hdrs:
+ header_includes.append("-include")
+ header_includes.append(hdr.basename)
+
+ compilation_context = cc_common.create_compilation_context()
+
+ return generate_and_compile_bindings(
+ ctx,
+ ctx.attr,
+ compilation_context = compilation_context,
+ public_hdrs = public_std_hdrs,
+ header_includes = header_includes,
+ action_inputs = ctx.files._builtin_hdrs + std_hdrs,
+ targets_and_headers = targets_and_headers,
+ deps_for_cc_file = ctx.attr._generator[GeneratedFilesDepsInfo].deps_for_cc_file,
+ deps_for_rs_file = ctx.attr._generator[GeneratedFilesDepsInfo].deps_for_rs_file,
+ )
+
+bindings_for_toolchain_headers = rule(
+ implementation = _bindings_for_toolchain_headers_impl,
+ attrs = dict(
+ bindings_attrs.items() + {
+ "hdrs": attr.label(),
+ "public_hdrs": attr.string_list(),
+ "deps": attr.label_list(),
+ }.items(),
+ ),
+ toolchains = [
+ "//third_party/bazel_rules/rules_rust/rust:toolchain",
+ "//tools/cpp:toolchain_type",
+ ],
+ host_fragments = ["cpp"],
+ fragments = ["cpp", "google_cpp"],
+)
diff --git a/rs_bindings_from_cc/importer.cc b/rs_bindings_from_cc/importer.cc
index 6275385..35af0f6 100644
--- a/rs_bindings_from_cc/importer.cc
+++ b/rs_bindings_from_cc/importer.cc
@@ -538,11 +538,7 @@
// consider it a textual header. In that case we go up the include stack
// until we find a header that has an owning target.
- // TODO(b/208377928): We currently don't have a target for the headers in
- // Clang's resource directory, so for the time being we return a fictional
- // "//:virtual_clang_resource_dir_target" for system headers.
- while (source_location.isValid() &&
- !source_manager.isInSystemHeader(source_location)) {
+ while (source_location.isValid()) {
if (source_location.isMacroID()) {
source_location = source_manager.getExpansionLoc(source_location);
}
diff --git a/rs_bindings_from_cc/test/blaze_unit_tests/headers_and_targets/rust_bindings_from_cc_aspect_test.bzl b/rs_bindings_from_cc/test/blaze_unit_tests/headers_and_targets/rust_bindings_from_cc_aspect_test.bzl
index b2df1ef..0b7339b 100644
--- a/rs_bindings_from_cc/test/blaze_unit_tests/headers_and_targets/rust_bindings_from_cc_aspect_test.bzl
+++ b/rs_bindings_from_cc/test/blaze_unit_tests/headers_and_targets/rust_bindings_from_cc_aspect_test.bzl
@@ -24,18 +24,60 @@
},
)
+def _is_std(t):
+ return str(t) in ["//rs_bindings_from_cc:cc_std", "//:_builtin_hdrs"]
+
def _get_targets_and_headers(tut):
return [
- json.decode(x)
- for x in tut[RustBindingsFromCcInfo].targets_and_headers.to_list()
+ x
+ for x in [
+ json.decode(tah)
+ for tah in tut[RustBindingsFromCcInfo].targets_and_headers.to_list()
+ ]
+ if not _is_std(x["t"])
]
+def _lib_has_toolchain_targets_and_headers_test_impl(ctx):
+ env = analysistest.begin(ctx)
+ target_under_test = analysistest.target_under_test(env)
+ targets_and_headers = [
+ json.decode(tah)
+ for tah in target_under_test[RustBindingsFromCcInfo].targets_and_headers.to_list()
+ ]
+
+ asserts.equals(env, 2, len(targets_and_headers))
+
+ asserts.equals(
+ env,
+ targets_and_headers[0]["t"],
+ "//rs_bindings_from_cc:cc_std",
+ )
+ asserts.equals(
+ env,
+ targets_and_headers[1]["t"],
+ "//:_builtin_hdrs",
+ )
+
+ return analysistest.end(env)
+
+lib_has_toolchain_targets_and_headers_test = analysistest.make(
+ _lib_has_toolchain_targets_and_headers_test_impl,
+)
+
+def _test_lib_has_toolchain_targets_and_headers():
+ native.cc_library(name = "empty")
+ attach_aspect(name = "empty_with_aspect", dep = ":empty")
+ lib_has_toolchain_targets_and_headers_test(
+ name = "lib_has_toolchain_targets_and_headers_test",
+ target_under_test = ":empty_with_aspect",
+ )
+
def _no_targets_and_headers_test_impl(ctx):
env = analysistest.begin(ctx)
target_under_test = analysistest.target_under_test(env)
targets_and_headers = _get_targets_and_headers(target_under_test)
- asserts.equals(env, len(targets_and_headers), 0)
+ asserts.equals(env, 0, len(targets_and_headers))
return analysistest.end(env)
@@ -54,7 +96,7 @@
target_under_test = analysistest.target_under_test(env)
targets_and_headers = _get_targets_and_headers(target_under_test)
- asserts.equals(env, len(targets_and_headers), 1)
+ asserts.equals(env, 1, len(targets_and_headers))
asserts.equals(
env,
targets_and_headers[0]["t"],
@@ -84,7 +126,7 @@
target_under_test = analysistest.target_under_test(env)
targets_and_headers = _get_targets_and_headers(target_under_test)
- asserts.equals(env, len(targets_and_headers), 2)
+ asserts.equals(env, 2, len(targets_and_headers))
asserts.equals(
env,
@@ -131,7 +173,7 @@
targets_and_headers = _get_targets_and_headers(target_under_test)
# Check that none of the textual headers made it into the targets_and_headers provider.
- asserts.equals(env, len(targets_and_headers), 1)
+ asserts.equals(env, 1, len(targets_and_headers))
asserts.equals(
env,
targets_and_headers[0]["h"],
@@ -170,6 +212,7 @@
_test_targets_and_headers()
_test_targets_and_headers_propagate_with_cc_infos()
_test_textual_hdrs_not_in_targets_and_hdrs()
+ _test_lib_has_toolchain_targets_and_headers()
native.test_suite(
name = name,
@@ -178,5 +221,6 @@
":targets_and_headers_test",
":targets_and_headers_propagate_with_cc_info_test",
":textual_hdrs_not_in_targets_and_hdrs_test",
+ ":lib_has_toolchain_targets_and_headers_test",
],
)
diff --git a/rs_bindings_from_cc/test/cc_std/test.rs b/rs_bindings_from_cc/test/cc_std/test.rs
new file mode 100644
index 0000000..3d300ee
--- /dev/null
+++ b/rs_bindings_from_cc/test/cc_std/test.rs
@@ -0,0 +1,26 @@
+// Part of the Crubit project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+//TODO(rosica): We need namespaces in order to be able to test more here.
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn test_return_value() {
+ use cc_std::*;
+ let _t = tm {
+ tm_gmtoff: 0,
+ tm_hour: 1,
+ tm_isdst: 2,
+ tm_mday: 3,
+ tm_min: 4,
+ tm_mon: 5,
+ tm_sec: 6,
+ tm_wday: 7,
+ tm_yday: 8,
+ tm_year: 9,
+ tm_zone: "zone".as_ptr(),
+ };
+ }
+}
diff --git a/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs b/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs
index 4c9f988..5e7f275 100644
--- a/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs
@@ -11,148 +11,6 @@
pub type __builtin_ms_va_list = *mut u8;
-pub type __u_char = u8;
-
-pub type __u_short = u16;
-
-pub type __u_int = u32;
-
-pub type __u_long = u64;
-
-pub type __int8_t = i8;
-
-pub type __uint8_t = u8;
-
-pub type __int16_t = i16;
-
-pub type __uint16_t = u16;
-
-pub type __int32_t = i32;
-
-pub type __uint32_t = u32;
-
-pub type __int64_t = i64;
-
-pub type __uint64_t = u64;
-
-pub type __quad_t = i64;
-
-pub type __u_quad_t = u64;
-
-pub type __intmax_t = i64;
-
-pub type __uintmax_t = u64;
-
-pub type __dev_t = u64;
-
-pub type __uid_t = u32;
-
-pub type __gid_t = u32;
-
-pub type __ino_t = u64;
-
-pub type __ino64_t = u64;
-
-pub type __mode_t = u32;
-
-pub type __nlink_t = u64;
-
-pub type __off_t = i64;
-
-pub type __off64_t = i64;
-
-pub type __pid_t = i32;
-
-pub type __clock_t = i64;
-
-pub type __rlim_t = u64;
-
-pub type __rlim64_t = u64;
-
-pub type __id_t = u32;
-
-pub type __time_t = i64;
-
-pub type __useconds_t = u32;
-
-pub type __suseconds_t = i64;
-
-pub type __daddr_t = i32;
-
-pub type __key_t = i32;
-
-pub type __clockid_t = i32;
-
-pub type __timer_t = *mut ();
-
-pub type __blksize_t = i64;
-
-pub type __blkcnt_t = i64;
-
-pub type __blkcnt64_t = i64;
-
-pub type __fsblkcnt_t = u64;
-
-pub type __fsblkcnt64_t = u64;
-
-pub type __fsfilcnt_t = u64;
-
-pub type __fsfilcnt64_t = u64;
-
-pub type __fsword_t = i64;
-
-pub type __ssize_t = i64;
-
-pub type __syscall_slong_t = i64;
-
-pub type __syscall_ulong_t = u64;
-
-pub type __loff_t = __off64_t;
-
-pub type __caddr_t = *mut u8;
-
-pub type __intptr_t = i64;
-
-pub type __socklen_t = u32;
-
-pub type __sig_atomic_t = i32;
-
-pub type int_least8_t = i8;
-
-pub type int_least16_t = i16;
-
-pub type int_least32_t = i32;
-
-pub type int_least64_t = i64;
-
-pub type uint_least8_t = u8;
-
-pub type uint_least16_t = u16;
-
-pub type uint_least32_t = u32;
-
-pub type uint_least64_t = u64;
-
-pub type int_fast8_t = i8;
-
-pub type int_fast16_t = i64;
-
-pub type int_fast32_t = i64;
-
-pub type int_fast64_t = i64;
-
-pub type uint_fast8_t = u8;
-
-pub type uint_fast16_t = u64;
-
-pub type uint_fast32_t = u64;
-
-pub type uint_fast64_t = u64;
-
-pub type intmax_t = __intmax_t;
-
-pub type uintmax_t = __uintmax_t;
-
/// Using classes to force these to be non-POD.
/// In the Itanium ABI, the tail padding of POD types cannot be reused by other
/// objects, even if the POD type is potentially-overlapping.
diff --git a/rs_bindings_from_cc/test/golden/types_rs_api.rs b/rs_bindings_from_cc/test/golden/types_rs_api.rs
index 3557920..14445d0 100644
--- a/rs_bindings_from_cc/test/golden/types_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/types_rs_api.rs
@@ -11,148 +11,6 @@
pub type __builtin_ms_va_list = *mut u8;
-pub type __u_char = u8;
-
-pub type __u_short = u16;
-
-pub type __u_int = u32;
-
-pub type __u_long = u64;
-
-pub type __int8_t = i8;
-
-pub type __uint8_t = u8;
-
-pub type __int16_t = i16;
-
-pub type __uint16_t = u16;
-
-pub type __int32_t = i32;
-
-pub type __uint32_t = u32;
-
-pub type __int64_t = i64;
-
-pub type __uint64_t = u64;
-
-pub type __quad_t = i64;
-
-pub type __u_quad_t = u64;
-
-pub type __intmax_t = i64;
-
-pub type __uintmax_t = u64;
-
-pub type __dev_t = u64;
-
-pub type __uid_t = u32;
-
-pub type __gid_t = u32;
-
-pub type __ino_t = u64;
-
-pub type __ino64_t = u64;
-
-pub type __mode_t = u32;
-
-pub type __nlink_t = u64;
-
-pub type __off_t = i64;
-
-pub type __off64_t = i64;
-
-pub type __pid_t = i32;
-
-pub type __clock_t = i64;
-
-pub type __rlim_t = u64;
-
-pub type __rlim64_t = u64;
-
-pub type __id_t = u32;
-
-pub type __time_t = i64;
-
-pub type __useconds_t = u32;
-
-pub type __suseconds_t = i64;
-
-pub type __daddr_t = i32;
-
-pub type __key_t = i32;
-
-pub type __clockid_t = i32;
-
-pub type __timer_t = *mut ();
-
-pub type __blksize_t = i64;
-
-pub type __blkcnt_t = i64;
-
-pub type __blkcnt64_t = i64;
-
-pub type __fsblkcnt_t = u64;
-
-pub type __fsblkcnt64_t = u64;
-
-pub type __fsfilcnt_t = u64;
-
-pub type __fsfilcnt64_t = u64;
-
-pub type __fsword_t = i64;
-
-pub type __ssize_t = i64;
-
-pub type __syscall_slong_t = i64;
-
-pub type __syscall_ulong_t = u64;
-
-pub type __loff_t = __off64_t;
-
-pub type __caddr_t = *mut u8;
-
-pub type __intptr_t = i64;
-
-pub type __socklen_t = u32;
-
-pub type __sig_atomic_t = i32;
-
-pub type int_least8_t = i8;
-
-pub type int_least16_t = i16;
-
-pub type int_least32_t = i32;
-
-pub type int_least64_t = i64;
-
-pub type uint_least8_t = u8;
-
-pub type uint_least16_t = u16;
-
-pub type uint_least32_t = u32;
-
-pub type uint_least64_t = u64;
-
-pub type int_fast8_t = i8;
-
-pub type int_fast16_t = i64;
-
-pub type int_fast32_t = i64;
-
-pub type int_fast64_t = i64;
-
-pub type uint_fast8_t = u8;
-
-pub type uint_fast16_t = u64;
-
-pub type uint_fast32_t = u64;
-
-pub type uint_fast64_t = u64;
-
-pub type intmax_t = __intmax_t;
-
-pub type uintmax_t = __uintmax_t;
-
#[derive(Clone, Copy)]
#[repr(C)]
pub struct SomeStruct {
diff --git a/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs b/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs
index e41841d..6c71774 100644
--- a/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs
@@ -11,148 +11,6 @@
pub type __builtin_ms_va_list = *mut u8;
-pub type __u_char = u8;
-
-pub type __u_short = u16;
-
-pub type __u_int = u32;
-
-pub type __u_long = u64;
-
-pub type __int8_t = i8;
-
-pub type __uint8_t = u8;
-
-pub type __int16_t = i16;
-
-pub type __uint16_t = u16;
-
-pub type __int32_t = i32;
-
-pub type __uint32_t = u32;
-
-pub type __int64_t = i64;
-
-pub type __uint64_t = u64;
-
-pub type __quad_t = i64;
-
-pub type __u_quad_t = u64;
-
-pub type __intmax_t = i64;
-
-pub type __uintmax_t = u64;
-
-pub type __dev_t = u64;
-
-pub type __uid_t = u32;
-
-pub type __gid_t = u32;
-
-pub type __ino_t = u64;
-
-pub type __ino64_t = u64;
-
-pub type __mode_t = u32;
-
-pub type __nlink_t = u64;
-
-pub type __off_t = i64;
-
-pub type __off64_t = i64;
-
-pub type __pid_t = i32;
-
-pub type __clock_t = i64;
-
-pub type __rlim_t = u64;
-
-pub type __rlim64_t = u64;
-
-pub type __id_t = u32;
-
-pub type __time_t = i64;
-
-pub type __useconds_t = u32;
-
-pub type __suseconds_t = i64;
-
-pub type __daddr_t = i32;
-
-pub type __key_t = i32;
-
-pub type __clockid_t = i32;
-
-pub type __timer_t = *mut ();
-
-pub type __blksize_t = i64;
-
-pub type __blkcnt_t = i64;
-
-pub type __blkcnt64_t = i64;
-
-pub type __fsblkcnt_t = u64;
-
-pub type __fsblkcnt64_t = u64;
-
-pub type __fsfilcnt_t = u64;
-
-pub type __fsfilcnt64_t = u64;
-
-pub type __fsword_t = i64;
-
-pub type __ssize_t = i64;
-
-pub type __syscall_slong_t = i64;
-
-pub type __syscall_ulong_t = u64;
-
-pub type __loff_t = __off64_t;
-
-pub type __caddr_t = *mut u8;
-
-pub type __intptr_t = i64;
-
-pub type __socklen_t = u32;
-
-pub type __sig_atomic_t = i32;
-
-pub type int_least8_t = i8;
-
-pub type int_least16_t = i16;
-
-pub type int_least32_t = i32;
-
-pub type int_least64_t = i64;
-
-pub type uint_least8_t = u8;
-
-pub type uint_least16_t = u16;
-
-pub type uint_least32_t = u32;
-
-pub type uint_least64_t = u64;
-
-pub type int_fast8_t = i8;
-
-pub type int_fast16_t = i64;
-
-pub type int_fast32_t = i64;
-
-pub type int_fast64_t = i64;
-
-pub type uint_fast8_t = u8;
-
-pub type uint_fast16_t = u64;
-
-pub type uint_fast32_t = u64;
-
-pub type uint_fast64_t = u64;
-
-pub type intmax_t = __intmax_t;
-
-pub type uintmax_t = __uintmax_t;
-
/// The same as Derived from inheritance.h, but in a different build target.
///
/// This tests inheritance across library boundaries.