Conversation
src/common/tusb_compiler.h
Outdated
| #pragma GCC poison tud_vendor_control_request_cb | ||
| #endif | ||
|
|
||
| #if defined (__clang__) |
There was a problem hiding this comment.
can you do the #ifdef #else instead of undef (ust move this up). undef is rather confusing since people may only look at the first define.
There was a problem hiding this comment.
Just to clarify @hathach
Like this?
#if defined(__GNUC__) || defined (__clang__)
#define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
#define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
#define TU_ATTR_PACKED __attribute__ ((packed))
#if defined(__GNUC__)
#define TU_ATTR_WEAK __attribute__ ((weak))
#else
#define TU_ATTR_WEAK __attribute__ ((weak_import))
#endif
...
...
There was a problem hiding this comment.
yeah, but the otherway around
#if defined(__clang__)
#define TU_ATTR_WEAK __attribute__ ((weak_import))
#else
#define TU_ATTR_WEAK __attribute__ ((weak))
#endifThere was a problem hiding this comment.
All fixed :)
Not sure why pre-commit CI is failing 🤔
There was a problem hiding this comment.
unit test probably compile using clang, and has affected by this attribute. I will check later.
hathach
left a comment
There was a problem hiding this comment.
still haven't got time to test this out, will be off for a couple of week for TET holidays. Please be patient, thank you.
|
@Ryzee119 I am back from TET holidays, which compiler you are using. If it is arm clang, I could give it a try (was planning to support it anwyay). |
hathach
left a comment
There was a problem hiding this comment.
recently I switch to use weak as the default implementation of callback to be compatible with keil #2239
https://github.com/hathach/tinyusb/blob/master/src/device/usbd.c#L48
the other callback header can work with weak_import, but this style seems to require actual weak and cause the compile issue with unit-test (since test include mocking of dcd layer).
Maybe I should use weakref/alias or unify them all to default implemenation, will revise later. We probably need to keep this open until then. Thank you.
|
How it goes with #2606 ? |
|
so far I only tested arm-clang with cdc_msc example, it doesn't seem to need weak_import yet, but I admit we need more testinng. the conlfict with unit-test is resolved (unit test switch back to gcc) |
|
So sorry i missed this discussion somehow! I'm using clang + llvm cross compiling for x86 type embedded system with OHCI backend.
^ Yep this does the trick for me. I was having problems with the OHCI tusb_app_virt_to_phys/tusb_app_phys_to_virt weak functions. So I just need this patch and implement weak stub functions. Ill probably supersede this PR. I need to stick these two stubs somewhere for my needs. Can you suggest a good location? |
|
@Ryzee119 all weak callback is now migrated to use default empty implementation to better support keil/armcc. I guess we can safely close this now ? |
|
@hathach that's great. That should fix any outstanding issues I had. We may just need the defined(clang) check on GNUC so clang compiler will use those definitions which should all be compatible now I will confirm this soon |
Describe the PR
I'm using the clang compiler which for our purposes the compiler attributes match GCC from what I can read.
Although
TU_ATTR_WEAKhad to be changed to__attribute__ ((weak_import))or I was gettinglld: error: duplicate symbolerrors on all theTU_ATTR_WEAKfunctions.