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

Incorrect assumption about file name patterns in table build #1436

Closed
jphickey opened this issue Apr 28, 2021 · 0 comments · Fixed by #1437 or #1492
Closed

Incorrect assumption about file name patterns in table build #1436

jphickey opened this issue Apr 28, 2021 · 0 comments · Fixed by #1437 or #1492
Assignees
Labels
Milestone

Comments

@jphickey
Copy link
Contributor

Describe the bug
On most CMake platforms the generated object file names are simply the file name (including the .c) concatenated with CMAKE_C_OUTPUT_EXTENSION. So, for example, on table build for sample_app, the file sample_app_tbl.c gets compiled into sample_app_tbl.c.o which can then be used to call elf2cfetbl.

Apparently this relationship is not guaranteed, there is at least one example of a platform where this gets compiled to sample_app_tbl.o instead of sample_app_tbl.c.o.

To Reproduce
Attempt to build on a platform that does not follow the expected pattern. Tables will fail to build with a failure to open the object file due to the name mismatch.

Expected behavior
Table should build successfully.

Code snips
I traced this back to a workaround that was put in for older CMake, which assumes the name of the object file:

cFE/cmake/arch_build.cmake

Lines 200 to 201 in 73c338d

get_filename_component(TBLOBJ ${TBL} NAME)
string(APPEND TBLOBJ ${CMAKE_C_OUTPUT_EXTENSION})

The preferred/correct way to do this is to use the $<TARGET_OBJECTS:...> generator expression, but this only works in newer CMake versions. The workaround was to assume a file name based on the expected pattern, which works most of the time, but there are exceptions.

System observed on:
Originally reported by @klystron78 when building for VxWorks 7.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Apr 28, 2021
jphickey added a commit to jphickey/cFE that referenced this issue Apr 28, 2021
Use a shell glob instead of assuming a specific file name, this
should pick up the object file no matter how it was named, as
long as it ends in ${CMAKE_C_OUTPUT_EXTENSION}.

It does rely on/assume there is only one such file, so this might
break if one changes the name of a table without a clean rebuild.

A proper fix would still be to use TARGET_OBJECTS generator expression,
but that can't happen until Ubuntu 18.04 (w/ ver 3.10) is EOL.
@skliper skliper added this to the 7.0.0 milestone Apr 28, 2021
@skliper skliper added the bug label Apr 28, 2021
jphickey added a commit to jphickey/cFE that referenced this issue Apr 28, 2021
This uses a sub-script to call elf2cfetbl which avoid relying
on a shell glob.  More complicated but should be more robust if/when
someone renames a table.
jphickey added a commit to jphickey/cFE that referenced this issue May 11, 2021
This uses a sub-script to call elf2cfetbl which avoid relying
on a shell glob.  More complicated but should be more robust if/when
someone renames a table.

Note: A proper/simpler fix would still be to use TARGET_OBJECTS generator
expression, but that can't happen until Ubuntu 18.04 (w/ ver 3.10) or older
versions are no longer supported.
astrogeco added a commit that referenced this issue May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants