Skip to content

libc-test: Resolve alias? #4293

@farao

Description

@farao

I'm trying to resolve Warnings of libc-test for a uclibc-based OS (x86_64-unknown-l4re-uclibc). Currently, I'm facing a more general issue for which I'm not sure how to fix it:

  1. There is a type alias in the rust files.

Example:

pub type fsword_t = c_long;

Since this is a "helper type" without pendant in the uclibc, I added this to cfg.skip_type(...)

  1. There is a struct using this type alias as a field type

Example:

pub struct statfs {
// FIXME(ulibc)
pub f_type: fsword_t,

  1. Then we have the problem, that the type alias is not resolved

Example:

warning: [email protected]: .../out/main.c:27500:18: error: unknown type name 'fsword_t';
warning: [email protected]: 27500 |                  fsword_t* __test_field_type_statfs_f_type(struct statfs* b) {
warning: [email protected]:       |                  ^~~~~~~~

=> Is there any way how to resolve this problem?

I tried adding the resolving of type aliases to ctest2:

-            s => (self.opts.type_name)(s, self.structs.contains(s), self.unions.contains(s)),
+            s => {
+                let new_s = (self.opts.type_name)(s, self.structs.contains(s), self.unions.contains(s));
+
+                if self.aliases.contains_key(&new_s) {
+                    self.ty2name(self.aliases.get(&new_s).unwrap(), false)
+                } else {
+                    new_s.to_string()
+                }
+            }

at: https://github.com/JohnTitor/ctest2/blob/05634716fbe6f9ea4bf090ce85776269740b1a58/src/lib.rs#L1214

But this brings up new problems, e.g. that types get resolved that were not meant to be resolved, e.g.

pub type Elf32_Rel = __c_anonymous_elf32_rel;

here's the corresponding warning:

   5 warning: [email protected]: .../out/main.c:14500:67: error: invalid application of 'sizeof' to incomplete type 'struct __c_anonymous_elf64_rel'
   6 warning: [email protected]: 14500 |              uint64_t __test_size_Elf32_Rel(void) { return sizeof(struct __c_anonymous_elf64_rel); }

What do you think? Is...

  • resolving the alias the correct move and think about a solution for the followup errors?
  • or is there an easy solution for the original problem that does not need changes in ctest2?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions