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 failed when WITH_THREADS is set to OFF #866

Closed
MrJia1997 opened this issue Sep 30, 2022 · 2 comments · Fixed by #964
Closed

Link failed when WITH_THREADS is set to OFF #866

MrJia1997 opened this issue Sep 30, 2022 · 2 comments · Fixed by #964
Labels
Milestone

Comments

@MrJia1997
Copy link

MrJia1997 commented Sep 30, 2022

Version: v0.6.0 (should be reproducible on master)
Platform: macOS 12.6
Compiler: AppleClang 14.0.0

When WITH_THREADS options is set to OFF, linking glog will pop an linking error which says
undef: __ZN6google24glog_internal_namespace_31IsFailureSignalHandlerInstalledEv

It looks like the symbol google::glog_internal_namespace_::IsFailureSignalHandlerInstalled() is defined in src/signalhandler.cc ,

glog/src/signalhandler.cc

Lines 367 to 381 in 05fbc65

bool IsFailureSignalHandlerInstalled() {
#ifdef HAVE_SIGACTION
// TODO(andschwa): Return kFailureSignalHandlerInstalled?
struct sigaction sig_action;
memset(&sig_action, 0, sizeof(sig_action));
sigemptyset(&sig_action.sa_mask);
sigaction(SIGABRT, NULL, &sig_action);
if (sig_action.sa_sigaction == &FailureSignalHandler) {
return true;
}
#elif defined(GLOG_OS_WINDOWS)
return kFailureSignalHandlerInstalled;
#endif // HAVE_SIGACTION
return false;
}

and the source file will not be included in the build target if WITH_THREADS is set to OFF.

glog/CMakeLists.txt

Lines 530 to 536 in 05fbc65

if (WITH_THREADS AND Threads_FOUND)
if (CMAKE_USE_PTHREADS_INIT)
set (HAVE_PTHREAD 1)
endif (CMAKE_USE_PTHREADS_INIT)
else (WITH_THREADS AND Threads_FOUND)
set (NO_THREADS 1)
endif (WITH_THREADS AND Threads_FOUND)

glog/CMakeLists.txt

Lines 621 to 623 in 05fbc65

if (HAVE_PTHREAD OR WIN32 OR CYGWIN)
list (APPEND GLOG_SRCS src/signalhandler.cc)
endif (HAVE_PTHREAD OR WIN32 OR CYGWIN)

Is this an intended behavior? If not, I can help to fix this.

@MrJia1997
Copy link
Author

Any advice here?

@MrSome1
Copy link

MrSome1 commented Nov 24, 2022

Hi there, I just came to the same problem.
Just comment the if condition line in the glog/CMakeLists.txt to fix.

#if (HAVE_PTHREAD OR WIN32 OR CYGWIN) 
list (APPEND GLOG_SRCS src/signalhandler.cc) 
#endif (HAVE_PTHREAD OR WIN32 OR CYGWIN)

And I tried some basic functions, like LOG(INFO), they worked.
But not sure if there will be unknown issues, and I wonder if this is an intended behavior too.
Wish this will help.

@sergiud sergiud added the bug label Oct 6, 2023
@sergiud sergiud added this to the 0.7 milestone Oct 6, 2023
@sergiud sergiud linked a pull request Oct 6, 2023 that will close this issue
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.

3 participants