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

Link error when building with MISSION_MSGID_V2 = TRUE #2054

Closed
plexilcrf opened this issue Feb 22, 2022 · 1 comment · Fixed by #2056 or #2061
Closed

Link error when building with MISSION_MSGID_V2 = TRUE #2054

plexilcrf opened this issue Feb 22, 2022 · 1 comment · Fixed by #2056 or #2061
Assignees
Milestone

Comments

@plexilcrf
Copy link

Describe the bug
cFE compiles (with warnings about implicit function declarations), but linking the cfe_core executable errors out with undefined references to symbols CFE_SB_ValueToMsgId and CFE_SB_MsgIdToValue.

To Reproduce
Steps to reproduce the behavior:

  1. Create a mission configuration. Modify global_build_options.cmake by adding the following two lines:
    set(MISSION_INCLUDE_CCSDSEXT_HEADER TRUE)
    set(MISSION_MSGID_V2 TRUE)

  2. Build cFS. The following warnings will be issued when compiling cfe_msg_msgid_v2.c:
    [ 77%] Building C object msg/CMakeFiles/msg.dir/fsw/src/cfe_msg_msgid_v2.c.o
    /home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c: In function ‘CFE_MSG_GetMsgId’:
    /home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c:80:14: warning: implicit declaration of function ‘CFE_SB_ValueToMsgId’ [-Wimplicit-function-declaration]
    80 | *MsgId = CFE_SB_ValueToMsgId(msgidval);
    | ^~~~~~~~~~~~~~~~~~~
    /home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c: In function ‘CFE_MSG_SetMsgId’:
    /home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c:96:36: warning: implicit declaration of function ‘CFE_SB_MsgIdToValue’ [-Wimplicit-function-declaration]
    96 | CFE_SB_MsgId_Atom_t msgidval = CFE_SB_MsgIdToValue(MsgId);
    | ^~~~~~~~~~~~~~~~~~~
    The following error will be reported at the link phase:
    [100%] Linking C executable core-cpu1
    /usr/bin/ld: ../msg/libmsg.a(cfe_msg_msgid_v2.c.o): in function CFE_MSG_GetMsgId': cfe_msg_msgid_v2.c:(.text+0x8b): undefined reference to CFE_SB_ValueToMsgId'
    /usr/bin/ld: ../msg/libmsg.a(cfe_msg_msgid_v2.c.o): in function CFE_MSG_SetMsgId': cfe_msg_msgid_v2.c:(.text+0xd1): undefined reference to CFE_SB_MsgIdToValue'
    collect2: error: ld returned 1 exit status
    make[11]: *** [cpu1/CMakeFiles/core-cpu1.dir/build.make:199: cpu1/core-cpu1] Error 1

  3. The bug occurs because the two functions are defined as 'static inline' in cfe_sb.h, which is not referenced in cfe_msg_msgid_v2.c, and because the C language prior to the C99 standard implicitly defines functions as int fn_name(int). Simply adding #include "cfe_sb.h" fixes the problem.

Expected behavior
core-cpu1 should compile and link cleanly.

Code snips
See attached patch file.

msg_v2_link_error_patch.txt

System observed on:

  • Hardware: VirtualBox 6.1.30 emulation of a generic x86-64 system on macOS 11.6.3
  • OS: Ubuntu 20.04
  • Compiler: GCC 9.3.0
  • Versions: cFE tag v7.0.0-rc4, OSAL tag v6.0.0-rc4, PSP tag v1.6.0-rc4

Additional context

Reporter Info
Chuck Fry, QTS Inc., subcontractor to KBR Wyle on the ISRDS3 contract, at NASA ARC Code TI
[email protected]

skliper added a commit to skliper/cFE that referenced this issue Feb 23, 2022
@skliper skliper added the bug label Feb 23, 2022
@skliper skliper self-assigned this Feb 23, 2022
@skliper skliper added this to the Draco milestone Feb 23, 2022
@skliper
Copy link
Contributor

skliper commented Feb 23, 2022

@plexilcrf Thanks for the detailed issue! Fixed in #2056.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants