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

gnu-rm下,汇编文件week函数无法被同名文件覆盖 #5461

Open
USTHzhanglu opened this issue Aug 12, 2024 · 4 comments
Open

gnu-rm下,汇编文件week函数无法被同名文件覆盖 #5461

USTHzhanglu opened this issue Aug 12, 2024 · 4 comments
Labels

Comments

@USTHzhanglu
Copy link

Xmake 版本

2.9.4

操作系统版本和架构

win10 22H2

描述问题

我在搭建MCU工程时,将工程拆分成sys.luaapp.lua,前者set_kind("static"),后者set_kind("binary"),其中中断函数(即week同名函数)放到了sys.lua中,编译后烧录测试异常,排查后发现startup.s中的week函数实际上未被同名函数覆盖,将该文件放到app.lua中重复编译了一遍才正常链接

期待的结果

正确的配置方法,或者其他解决问题的方法

工程配置

sys.lua
add_includedirs(
  "./driver/GD32E23x_standard_peripheral/include",
  {public = true}
)
add_includedirs(
  "./system",
  "./driver/CMSIS/Core/include",
  "./driver/CMSIS/GD/GD32E23x/Include",
  {public = true}
)

target("driver")
    set_kind("static")
    add_files(
      "./driver/GD32E23x_standard_peripheral/source/*.c"
    )

target_end()

target("system")
    set_kind("static")
    add_deps("driver")
    add_files(
      "./system/*.c",
      "./driver/CMSIS/GD/GD32E23x/Source/system_gd32e23x.c"
    )
    set_policy("build.merge_archive", true)
target_end()
sys.lua
-- for all source/target encodings
set_encodings("utf-8") -- msvc: /utf-8
add_requires("gnu-rm")
set_toolchains("@gnu-rm")

set_plat("cross")
set_arch("cortex-m23")
add_cxflags(
  "-O0",
  "-mcpu=cortex-m23",
  "-mthumb -mthumb-interwork",
  "-Wall",
  "-fdata-sections",
  "-ffunction-sections",
  "-g",
  {force = true}
)

add_asflags(
  "-O0",
  "-mcpu=cortex-m23",
  "-mthumb -mthumb-interwork",
  "-Wall",
  "-x assembler-with-cpp",
  -- "-fdata-sections",
  -- "-ffunction-sections",
  "-g",
  {force = true}
)

add_ldflags(
  "-mcpu=cortex-m23",
  "-mthumb -mthumb-interwork",
  "-Wl,--gc-sections",
  "--specs=nosys.specs",
  "-Tsystem/gd32e23x.ld",
  {force = true}
)

includes("./sys.lua")

target("APP")
  set_kind("binary")
  add_deps("system")
  add_files("APP/core/src/main.c")
  add_files(
    "./driver/CMSIS/GD/GD32E23x/Source/GCC/startup_gd32e23x.s"
  )
  -- add_files(
  --   "./system/gd32e23x_it.c"
  -- )
target_end()

附加信息和错误日志

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Under gnu-rm, the assembly file week function cannot be overwritten by the file with the same name.

@USTHzhanglu
Copy link
Author

我通过在binary中指定add_linkgroups("system","driver",{whole = true})解决了该问题.
但是仍然有一些疑问,其中system已经声明了依赖于driver(有一个函数在后者中定义),但是只add_linkgroups("system",{whole = true})时,会报undefined reference to 'nvic_vector_table_set' collect2.exe: error: ld returned 1 exit status,必须要两个一起添加才可以;
同时增加该指令后,删除add_deps("driver")能正常编译
不增加该指令,删除add_deps("driver"),会报一样的错误
add_linkgroups会覆盖add_deps的设置吗

@waruqi
Copy link
Member

waruqi commented Aug 12, 2024

看不懂你在说啥,很乱。。反正这种 link 问题,xmake -v 看下完整 link 参数,调下链接顺序不就好了么。。

你这一会 merge archive ,一会删 deps ,一会 linkgroups 什么的,又没给 link args 和 logs ,我哪知道咋回事。。

add_linkgroups("system","driver",{whole = true}) 既然这个可以,一种可能是两个库之间有循环依赖。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I don't understand what you are talking about, it's very confusing. . Anyway, for this kind of link problem, wouldn't it be better to check the complete link parameters with xmake -v and adjust the link order? .

Now you merge archive, delete deps, linkgroups and so on, but you don’t provide link args and logs. I don’t know what’s going on. .

add_linkgroups("system","driver",{whole = true}) Since this works, one possibility is that there is a circular dependency between the two libraries.

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

3 participants