谷动谷力

 找回密码
 立即注册
查看: 1473|回复: 0
打印 上一主题 下一主题
收起左侧

使用 LLVM-for-Arm 工具链编译 RT-Thread 源码

[复制链接]
跳转到指定楼层
楼主
发表于 2022-1-13 21:21:10 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 sunsili 于 2022-1-13 21:27 编辑

使用 LLVM-for-Arm 工具链编译 RT-Thread 源码[color=rgba(0, 0, 0, 0.3)]

原创RTThread物联网操作系统


使用 LLVM 编译 RT-Thread


硬件测试环境


pdd 不久前搞活动, 99 块买了两块阿里出的 L469 的开发板,最高主频为 80Mhz。所以本次测试硬件就使用该开发板进行测试。

工具准备


1、使用 git 工具下载 llvm 工具链:

  1. git clone https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm.git
复制代码


2、下载 make 工具:

  1. git clone https://github.com/xpack-dev-tools/windows-build-tools-xpack.git
复制代码

编译

1、在 rt-thread\bsp\stm32\stm32l496-ali-developer 目录下打开 env 工具:
2、使用命令 scons --target=cmake 生成 CMakelists.txt 文件:
3、这里的命令生成的 CMake 文件使用的是 gcc 的工具链,需要修改一下使用 llvm 的工具链:

  1. 1LiuKang@DESKTOP-538H6DE D:\repo\github\rt-thread\bsp\stm32\stm32l496-ali-developer
  2. 2$ cd build
  3. 3
  4. 4LiuKang@DESKTOP-538H6DE D:\repo\github\rt-thread\bsp\stm32\stm32l496-ali-developer\build
  5. 5$ cmake -G "MinGW Makefiles" ..
  6. 6-- Configuring done
  7. 7-- Generating done
  8. 8-- Build files have been written to: D:/repo/github/rt-thread/bsp/stm32/stm32l496-ali-developer/build
  9. 9
  10. 10LiuKang@DESKTOP-538H6DE D:\repo\github\rt-thread\bsp\stm32\stm32l496-ali-developer\build
  11. 11$ D:\software\tools\xpack-windows-build-tools-2.12.2\bin\make.exe
  12. 12[  1%] Building C object CMakeFiles/rtthread.elf.dir/applications/main.c.obj
  13. 13[  2%] Building C object CMakeFiles/rtthread.elf.dir/packages/CoreMark-latest/core_main.c.obj
  14. 14[  4%] Building C object CMakeFiles/rtthread.elf.dir/packages/CoreMark-latest/core_util.c.obj
  15. 15[  5%] Building C object CMakeFiles/rtthread.elf.dir/packages/CoreMark-latest/core_portme.c.obj
  16. 16[  7%] Building C object CMakeFiles/rtthread.elf.dir/packages/CoreMark-latest/core_list_join.c.obj
  17. 17[  8%] Building C object CMakeFiles/rtthread.elf.dir/packages/CoreMark-latest/core_state.c.obj
  18. 18[ 10%] Building C object CMakeFiles/rtthread.elf.dir/packages/CoreMark-latest/core_matrix.c.obj
  19. 19[ 11%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/libcpu/arm/common/showmem.c.obj
  20. 20[ 13%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/libcpu/arm/common/div0.c.obj
  21. 21[ 14%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/libcpu/arm/common/backtrace.c.obj
  22. 22[ 15%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/libcpu/arm/cortex-m4/cpuport.c.obj
  23. 23[ 17%] Building ASM object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/libcpu/arm/cortex-m4/context_gcc.S.obj
  24. 24[ 18%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/misc/pin.c.obj
  25. 25[ 20%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/serial/serial.c.obj
  26. 26[ 21%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/src/dataqueue.c.obj
  27. 27[ 23%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/src/ringblk_buf.c.obj
  28. 28[ 24%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/src/ringbuffer.c.obj
  29. 29[ 26%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/src/waitqueue.c.obj
  30. 30[ 27%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/src/completion.c.obj
  31. 31[ 28%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/src/pipe.c.obj
  32. 32[ 30%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/drivers/src/workqueue.c.obj
  33. 33[ 31%] Building ASM object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l496xx.s.obj
  34. 34clang: warning: argument unused during compilation: '-D HAVE_CCONFIG_H' [-Wunused-command-line-argument]
  35. 35clang: warning: argument unused during compilation: '-D RT_USING_NEWLIB' [-Wunused-command-line-argument]
  36. 36clang: warning: argument unused during compilation: '-D STM32L496xx' [-Wunused-command-line-argument]
  37. 37clang: warning: argument unused during compilation: '-D USE_HAL_DRIVER' [-Wunused-command-line-argument]
  38. 38clang: warning: argument unused during compilation: '-D __RTTHREAD__' [-Wunused-command-line-argument]
  39. 39[ 33%] Building C object CMakeFiles/rtthread.elf.dir/board/CubeMX_Config/Src/stm32l4xx_hal_msp.c.obj
  40. 40[ 34%] Building C object CMakeFiles/rtthread.elf.dir/board/board.c.obj
  41. 41[ 36%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c.obj
  42. 42[ 37%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/HAL_Drivers/drv_usart.c.obj
  43. 43[ 39%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/HAL_Drivers/drv_common.c.obj
  44. 44[ 40%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/finsh/shell.c.obj
  45. 45[ 42%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/finsh/msh.c.obj
  46. 46[ 43%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/finsh/cmd.c.obj
  47. 47[ 44%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/idle.c.obj
  48. 48[ 46%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/kservice.c.obj
  49. 49[ 47%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/scheduler.c.obj
  50. 50[ 49%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/irq.c.obj
  51. 51[ 50%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/timer.c.obj
  52. 52[ 52%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/mempool.c.obj
  53. 53[ 53%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/ipc.c.obj
  54. 54[ 55%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/device.c.obj
  55. 55[ 56%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/clock.c.obj
  56. 56[ 57%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/thread.c.obj
  57. 57[ 59%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/mem.c.obj
  58. 58[ 60%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/components.c.obj
  59. 59[ 62%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/src/object.c.obj
  60. 60[ 63%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/libc/compilers/common/stdlib.c.obj
  61. 61[ 65%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/libc/compilers/common/time.c.obj
  62. 62[ 66%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/libc/compilers/gcc/newlib/syscalls.c.obj
  63. 63[ 68%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/components/libc/compilers/gcc/newlib/libc_syms.c.obj
  64. 64[ 69%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cryp.c.obj
  65. 65[ 71%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c.obj
  66. 66[ 72%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_usart.c.obj
  67. 67[ 73%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c.obj
  68. 68[ 75%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c.obj
  69. 69[ 76%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c.obj
  70. 70[ 78%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c.obj
  71. 71[ 79%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c.obj
  72. 72[ 81%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c.obj
  73. 73[ 82%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c.obj
  74. 74[ 84%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c.obj
  75. 75[ 85%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c.obj
  76. 76[ 86%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c.obj
  77. 77[ 88%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_usart_ex.c.obj
  78. 78[ 89%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c.obj
  79. 79[ 91%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c.obj
  80. 80[ 92%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_comp.c.obj
  81. 81[ 94%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c.obj
  82. 82[ 95%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rng.c.obj
  83. 83[ 97%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c.obj
  84. 84[ 98%] Building C object CMakeFiles/rtthread.elf.dir/D_/repo/github/rt-thread/bsp/stm32/libraries/STM32L4xx_HAL/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cryp_ex.c.obj
  85. 85[100%] Linking C executable rtthread.elf
  86. 86clang: warning: argument unused during compilation: '-Wa,-mimplicit-it=thumb' [-Wunused-command-line-argument]
  87. 87   text    data     bss     dec     hex filename
  88. 88 117152    2864    1844  121860   1dc04 rtthread.elf
  89. 89[100%] Built target rtthread.elf
复制代码



5、下载 bin 文件到开发板:

6、llvm 的编译下载就完成啦。
跑分测试


使用 LLVM、GCC、IAR 三种工具链编译出来的可执行文件,测试一下跑分情况:
GCC 5.4.1
优化等级:-Os


GCC 10.3.1
优化等级:-Os


LLVM
优化等级:-Os


IAR
优化等级:
IAR 跑分情况



MDK
优化等级:


MDK AC6 跑分情况



跑分排名
IAR (199.94) > MDK AC6 (160.74) > LLVM (159.24) > GCC 5.4.1 (143.1.8) > GCC 10.3.1 (136.48)


+10
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号|Sitemap

GMT+8, 2024-11-18 08:23 , Processed in 0.228828 second(s), 40 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表