Skip to content

Possible error due to C complier requirement for 'tensorflow/lite/experimental/microfrontend/lib' instead of C++ compiler #15

@tallamjr

Description

@tallamjr

After pulling in most recent changes as of today (tfmicro@6d4a771 with tensorflow@33689c4 on macOS.10.15.5) and running:

$ cargo clean --verbose && cargo test --verbose

I get one of the (all similar) errors shown below:

warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:164:22: error: assigning to 'int16_t *' (aka 'short *') from incompatible type 'void *'
warning:   state->unweights = calloc(weight_index_start, sizeof(*state->unweights));
warning:                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This occurs for both CC=clang and CC=gcc which gives similar messages, indicating that the reason might be down to needing to compile the code from tensorflow/tensorflow/lite/experimental/microfrontend/lib with a C compiler instead of C++.

Refs:

The full output from using clang is shown here, and a trimmed gcc version of the message is below that. I tried myself to modify build.rs, but it got to a point where I had to admit to myself I am too much of a newbie to be able to know really what to fix.
CC=clang:

     Running `/Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-4b1014e20b828738/build-script-build`
The following warnings were emitted during compilation:

warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:69:7: error: assigning to 'int16_t *' (aka 'short *') from incompatible type 'void *'
warning:       malloc(num_channels_plus_1 * sizeof(*state->channel_frequency_starts));
warning:       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:71:7: error: assigning to 'int16_t *' (aka 'short *') from incompatible type 'void *'
warning:       malloc(num_channels_plus_1 * sizeof(*state->channel_weight_starts));
warning:       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:73:7: error: assigning to 'int16_t *' (aka 'short *') from incompatible type 'void *'
warning:       malloc(num_channels_plus_1 * sizeof(*state->channel_widths));
warning:       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:74:17: error: assigning to 'uint64_t *' (aka 'unsigned long long *') from incompatible type 'void *'
warning:   state->work = malloc(num_channels_plus_1 * sizeof(*state->work));
warning:                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:76:10: error: cannot initialize a variable of type 'float *' with an rvalue of type 'void *'
warning:   float* center_mel_freqs =
warning:          ^
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:78:12: error: cannot initialize a variable of type 'int16_t *' (aka 'short *') with an rvalue of type 'void *'
warning:   int16_t* actual_channel_starts =
warning:            ^
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:80:12: error: cannot initialize a variable of type 'int16_t *' (aka 'short *') with an rvalue of type 'void *'
warning:   int16_t* actual_channel_widths =
warning:            ^
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:163:20: error: assigning to 'int16_t *' (aka 'short *') from incompatible type 'void *'
warning:   state->weights = calloc(weight_index_start, sizeof(*state->weights));
warning:                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tensorflow/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.c:164:22: error: assigning to 'int16_t *' (aka 'short *') from incompatible type 'void *'
warning:   state->unweights = calloc(weight_index_start, sizeof(*state->unweights));
warning:                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: 9 errors generated.
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
warning: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

error: failed to run custom build command for `tfmicro v0.1.0 (/Users/tallamjr/github/EDGE22/forks/tfmicro)`

CC=gcc:

error[E0658]: unions with non-`Copy` fields are unstable
   --> /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tflite_types.rs:386:9
    |
386 | /         pub union basic_string___short__bindgen_ty_1<_CharT> {
387 | |             pub __size_: cty::c_uchar,
388 | |             pub __lx: root::std::basic_string_value_type<_CharT>,
389 | |             _bindgen_union_align: u8,
390 | |             pub _phantom_0:
391 | |                 ::core::marker::PhantomData<::core::cell::UnsafeCell<_CharT>>,
392 | |         }
    | |_________^
    |
    = note: see issue #55149 <https://github.com/rust-lang/rust/issues/55149> for more information

error[E0658]: unions with non-`Copy` fields are unstable
   --> /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tflite_types.rs:386:9
    |
386 | /         pub union basic_string___short__bindgen_ty_1<_CharT> {
387 | |             pub __size_: cty::c_uchar,
388 | |             pub __lx: root::std::basic_string_value_type<_CharT>,
389 | |             _bindgen_union_align: u8,
390 | |             pub _phantom_0:
391 | |                 ::core::marker::PhantomData<::core::cell::UnsafeCell<_CharT>>,
392 | |         }
    | |_________^
    |
    = note: see issue #55149 <https://github.com/rust-lang/rust/issues/55149> for more information

error[E0740]: unions may not contain fields that need dropping
   --> /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tflite_types.rs:388:13
    |
388 |             pub __lx: root::std::basic_string_value_type<_CharT>,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: `std::mem::ManuallyDrop` can be used to wrap the type
   --> /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tflite_types.rs:388:13
    |
388 |             pub __lx: root::std::basic_string_value_type<_CharT>,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0740]: unions may not contain fields that need dropping
   --> /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tflite_types.rs:388:13
    |
388 |             pub __lx: root::std::basic_string_value_type<_CharT>,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: `std::mem::ManuallyDrop` can be used to wrap the type
   --> /Users/tallamjr/github/EDGE22/forks/tfmicro/target/debug/build/tfmicro-950f68498590f496/out/tflite_types.rs:388:13
    |
388 |             pub __lx: root::std::basic_string_value_type<_CharT>,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0658, E0740.
For more information about an error, try `rustc --explain E0658`.
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0658, E0740.
For more information about an error, try `rustc --explain E0658`.

Please do let me know if there is more information that would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions