Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M1 arm-none-eabi-gcc & xmake compile stm32 project Unable to pass #4778

Closed
cc-cao opened this issue Feb 27, 2024 · 3 comments
Closed

M1 arm-none-eabi-gcc & xmake compile stm32 project Unable to pass #4778

cc-cao opened this issue Feb 27, 2024 · 3 comments
Labels

Comments

@cc-cao
Copy link

cc-cao commented Feb 27, 2024

Xmake 版本

2.8.7

操作系统版本和架构

macos sonoma 14.3.1

描述问题

I don't know what to do with it, or even why, and it compiles well on Windows 11
I am unable to link properly and it inexplicably generates some undefined ldflag -dead_strip

期待的结果

I hope it compiles properly

工程配置

`add_rules("mode.debug", "mode.release")

toolchain("arm-none-eabi")
set_kind("standalone")
set_sdkdir("$(projectdir)/../arm-gnu-toolchain")
toolchain_end()

target("main")
set_languages("c11")
set_targetdir("build")
set_filename("A2Plus.elf")
set_toolchains("arm-none-eabi")
set_kind("binary")

add_defines("USE_HAL_DRIVER", "STM32F103xE")
-- add_defines("DEBUG")

add_files(
    "drivers/STM32F1xx_HAL_Driver/Src/*.c",
    "middlewares/FreeRTOS/Source/*.c",
    "middlewares/FreeRTOS/Source/portable/MemMang/*.c",
    "middlewares/FreeRTOS/Source/portable/GCC/ARM_CM3/*.c",
    "middlewares/FreeRTOS/Source/CMSIS_RTOS_V2/*.c",
    "src/*.c",
    "src/utils/*.c",
    "src/thread/*.c",
    "src/bsp/*.c",
    "src/startup_stm32f103xe.s"
)

add_includedirs(
    "src/include",
    "src/bsp",
    "src/utils",
    "src/thread",
    "drivers/CMSIS/Include",
    "drivers/CMSIS/Device/ST/STM32F1xx/Include",
    "drivers/STM32F1xx_HAL_Driver/Inc/Legacy",
    "drivers/STM32F1xx_HAL_Driver/Inc",
    "middlewares/FreeRTOS/Source/include",
    "middlewares/FreeRTOS/Source/portable/GCC/ARM_CM3",
    "middlewares/FreeRTOS/Source/CMSIS_RTOS_V2"
)

add_cflags(
    "-mcpu=cortex-m3",
    "-mthumb",
    "-Og",
    "-Wall -fdata-sections -ffunction-sections",
    {force = true}
)

add_asflags(
    "-mcpu=cortex-m3",
    "-mthumb",
    "-Og",
    "-Wall -fdata-sections -ffunction-sections",
    "-x assembler-with-cpp",
    {force = true}
)

add_ldflags(
    "-mcpu=cortex-m3",
    "-mthumb",
    "-specs=nano.specs",
    "-specs=nosys.specs",
    "-T./src/STM32F103VETx_FLASH.ld",
    "-lc -lm -lnosys",
    "-Wl,--gc-sections",
    {force = true}
)

after_build(function(target, opt)
    local targetfile = target:targetfile()
    local toolchain_path = "$(projectdir)/../arm-gnu-toolchain"
    arm_objcopy = format("%s/bin/arm-none-eabi-objcopy", toolchain_path)
    arm_size = format("%s/bin/arm-none-eabi-size", toolchain_path)
    os.exec(arm_objcopy .. " -O ihex " .. targetfile .. " " .. string.gsub(targetfile, "elf", "hex"))
    os.exec(arm_objcopy .. " -O binary " .. targetfile .. " " .. string.gsub(targetfile, "elf", "bin"))
    os.exec(arm_size .. " -Ax " .. targetfile)
    os.exec(arm_size .. " -Bx " .. targetfile)
    os.exec(arm_size .. " -Bd " .. targetfile)
end)

`

附加信息和错误日志

error: /Users/cc/Downloads/arm-gnu-toolchain/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: Error: unable to disambiguate: -dead_strip (did you mean --dead_strip ?)
collect2: error: ld returned 1 exit status

@cc-cao cc-cao added the bug label Feb 27, 2024
@cc-cao
Copy link
Author

cc-cao commented Feb 27, 2024

Snipaste

@cc-cao
Copy link
Author

cc-cao commented Feb 27, 2024

@waruqi
Copy link
Member

waruqi commented Feb 27, 2024

if you use cross toolchain, you should switch to cross platform.

xmake f -p cross or set_plat("cross")

@cc-cao cc-cao closed this as completed Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants