sifive / freedom-u540-c000-bootloader

Freedom U540-C000 Bootloader Code
Other
85 stars 38 forks source link

Fails to build with clang #29

Open kraj opened 3 years ago

kraj commented 3 years ago

I was trying to use clang cross compiler to build it and it showed up two issues

  1. Use gcc specific commandline option -mexplicit-relocs in Makefile
  2. Fails to compile code using atomics
ux00boot/ux00boot.c:505:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') inval
id)                                                                               
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_VAL), UX00BOOT_ERROR_LED_GPIO_MASK);                                                                                         
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/u540-c000-bootloader/gitAUTOINC+128f282d17-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/stdatomic.h:138:4
2: note: expanded from macro 'atomic_fetch_or'                         
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)                                                               
                                         ^                     ~~~~~~
ux00boot/ux00boot.c:506:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') inval
id)                                                                                                                                                                  
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_EN), UX00BOOT_ERROR_LED_GPIO_MASK);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                           
/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/u540-c000-bootloader/gitAUTOINC+128f282d17-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/stdatomic.h:138:4
2: note: expanded from macro 'atomic_fetch_or'
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
                                         ^                     ~~~~~~
ux00boot/ux00boot.c:507:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') inval
id)                                                                               
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_XOR), UX00BOOT_ERROR_LED_GPIO_MASK);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/u540-c000-bootloader/gitAUTOINC+128f282d17-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/stdatomic.h:138:4
2: note: expanded from macro 'atomic_fetch_or'          
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
                                         ^                     ~~~~~~                                                                                                
3 errors generated.
ux00boot/ux00boot.c:505:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') inval
id)
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_VAL), UX00BOOT_ERROR_LED_GPIO_MASK);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/u540-c000-bootloader/gitAUTOINC+128f282d17-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/stdatomic.h:138:4
2: note: expanded from macro 'atomic_fetch_or'
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
                                         ^                     ~~~~~~
make: *** [Makefile:62: zsbl/ux00boot.o] Error 1
make: *** Waiting for unfinished jobs.... 
ux00boot/ux00boot.c:506:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') inval
id)
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_EN), UX00BOOT_ERROR_LED_GPIO_MASK);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/u540-c000-bootloader/gitAUTOINC+128f282d17-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/stdatomic.h:138:4
2: note: expanded from macro 'atomic_fetch_or'
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
                                         ^                     ~~~~~~
ux00boot/ux00boot.c:507:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') inval
id)
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_XOR), UX00BOOT_ERROR_LED_GPIO_MASK);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/u540-c000-bootloader/gitAUTOINC+128f282d17-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/stdatomic.h:138:4
2: note: expanded from macro 'atomic_fetch_or'
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
                                         ^                     ~~~~~~
3 errors generated.
make: *** [Makefile:68: fsbl/ux00boot.o] Error 1
fsbl/main.c:129:5: error: second parameter of 'main' (argument array) must be of type 'char **'
int main(int id, unsigned long dtb)
    ^
fsbl/main.c:276:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') invalid)
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_VAL), PHY_NRESET);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/u540-c000-bootloader/gitAUTOINC+128f282d17-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/stdatomic.h:138:4
2: note: expanded from macro 'atomic_fetch_or'
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
                                         ^                     ~~~~~~
fsbl/main.c:277:3: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile uint32_t *' (aka 'volatile unsigned int *') invalid)
  atomic_fetch_or(&GPIO_REG(GPIO_OUTPUT_EN),  PHY_NRESET);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~