tinyusb
tinyusb copied to clipboard
Add clang to compiler.h
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_WEAK had to be changed to __attribute__ ((weak_import)) or I was getting lld: error: duplicate symbol errors on all the TU_ATTR_WEAK functions.
@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).
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.
recently I switch to use weak as the default implementation of callback to be compatible with keil https://github.com/hathach/tinyusb/pull/2239
^ 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.
+++ b/src/common/tusb_compiler.h
@@ -123,7 +123,7 @@
//--------------------------------------------------------------------+
// TODO refactor since __attribute__ is supported across many compiler
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined (__clang__)
diff --git a/src/portable/ohci/ohci.c b/src/portable/ohci/ohci.c
index c59d475..715ac63 100644
--- a/src/portable/ohci/ohci.c
+++ b/src/portable/ohci/ohci.c
TU_ATTR_ALWAYS_INLINE static inline void *_phys_addr(void *virtual_address)
{
- if (tusb_app_virt_to_phys) return tusb_app_virt_to_phys(virtual_address);
- return virtual_address;
+ return tusb_app_virt_to_phys(virtual_address);
}
TU_ATTR_ALWAYS_INLINE static inline void *_virt_addr(void *physical_address)
{
- if (tusb_app_phys_to_virt) return tusb_app_phys_to_virt(physical_address);
- return physical_address;
+ return tusb_app_phys_to_virt(physical_address);
}
Ill probably supersede this PR. I need to stick these two stubs somewhere for my needs. Can you suggest a good location?
TU_ATTR_WEAK void* tusb_app_virt_to_phys(void *virt_addr) {
return virt_addr;
}
TU_ATTR_WEAK void* tusb_app_phys_to_virt(void *phys_addr) {
return phys_addr;
}