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

linkage problem on macOS: ld: symbol(s) not found for architecture x86_64 #1162

Open
Tracked by #1161
stanislaw opened this issue Sep 22, 2021 · 0 comments
Open
Tracked by #1161

Comments

@stanislaw
Copy link
Contributor

Is your feature request related to a problem? Please describe.

There is a solvable linkage problem on macOS: ld: symbol(s) not found for architecture x86_64.

Undefined symbols for architecture x86_64:
  "_OS_impl_filehandle_table", referenced from:
      _Test_OS_SocketConnect_Impl in coveragetest-bsd-sockets.c.o
      _Test_OS_SocketAccept_Impl in coveragetest-bsd-sockets.c.o
      _Test_OS_SocketRecvFrom_Impl in coveragetest-bsd-sockets.c.o
      _OS_SocketOpen_Impl in os-impl-bsd-sockets.c.o
      _OS_SocketBind_Impl in os-impl-bsd-sockets.c.o
      _OS_SocketConnect_Impl in os-impl-bsd-sockets.c.o
      _OS_SocketShutdown_Impl in os-impl-bsd-sockets.c.o
      ...
  "_OS_stream_table", referenced from:
      _Test_OS_SocketOpen_Impl in coveragetest-bsd-sockets.c.o
      _Test_OS_SocketBind_Impl in coveragetest-bsd-sockets.c.o
      _Osapi_Test_Setup in coveragetest-bsd-sockets.c.o
      _OS_SocketOpen_Impl in os-impl-bsd-sockets.c.o
      _OS_SocketBind_Impl in os-impl-bsd-sockets.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [unit-test-coverage/vxworks/coverage-vxworks-bsd-sockets-testrunner] Error 1
make[2]: *** [unit-test-coverage/vxworks/CMakeFiles/coverage-vxworks-bsd-sockets-testrunner.dir/all] Error 2
make[1]: *** [all] Error 2

Describe the solution you'd like

The issue seems to be coming from the differences between gcc on Linux and clang on macOS. The following simple modification makes the error to go away for the OS_module_table symbol.

-OS_module_internal_record_t OS_module_table[OS_MAX_MODULES];
+OS_module_internal_record_t OS_module_table[OS_MAX_MODULES] = {0};
-OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS];
+OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS] = {0};

and so on...

This change is implemented consistently in #1161.

Describe alternatives you've considered

It doesn't seem to be possible to implement it differently on macOS / clang.

Additional context

This solution makes sense only if the macOS OSAL is integrated into the OSAL CI. Otherwise, it will not be obvious to a Linux programmer that the practice of initializing the global variables has to be followed.

Requester Info
Stanislav Pankevich (Personal contribution)

jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants