Build fails on musl: undefined reference to backtrace
sdsddsd1 opened this issue · 1 comments
sdsddsd1 commented
Hello,
I am trying to build build Viper on a musl based system. After I installed the needed libexecinfo it fails with the following:
Scanning dependencies of target viper-browser
[ 99%] Building CXX object src/app/CMakeFiles/viper-browser.dir/viper-browser_autogen/mocs_compilation.cpp.o
[ 99%] Building CXX object src/app/CMakeFiles/viper-browser.dir/qrc_application.cpp.o
[100%] Building CXX object src/app/CMakeFiles/viper-browser.dir/main.cpp.o
[100%] Linking CXX executable viper-browser
/usr/bin/ld: CMakeFiles/viper-browser.dir/main.cpp.o: in function `_handleCrash(int, siginfo_t*, void*)':
main.cpp:(.text+0x243): undefined reference to `backtrace'
/usr/bin/ld: main.cpp:(.text+0x251): undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status
make[2]: *** [src/app/CMakeFiles/viper-browser.dir/build.make:570: src/app/viper-browser] Error 1
make[1]: *** [CMakeFiles/Makefile2:219: src/app/CMakeFiles/viper-browser.dir/all] Error 2
make: *** [Makefile:150: all] Error 2
sdsddsd1 commented
In the meanwhile I have found this patch. Closed.
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 17bf7f8..5d4cded 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -30,58 +30,11 @@
#include <QTextStream>
#include <iostream>
-#include <execinfo.h>
#include <signal.h>
#include <string.h>
#define BT_BUF_SIZE 100
-void _handleCrash(int s, siginfo_t * /*siginfo*/, void * /*context*/)
-{
- if (s != SIGSEGV)
- return;
- void *buffer[BT_BUF_SIZE];
-
- int nptrs = backtrace(buffer, BT_BUF_SIZE);
- char **strings = backtrace_symbols(buffer, nptrs);
-
- if (strings == NULL)
- {
- std::cout << "Could not get backtrace symbols" << std::endl;
- exit(EXIT_FAILURE);
- }
-
- QDir d(QString("%1/.config/Vaccarelli").arg(QDir::homePath()));
- if (!d.cd(QLatin1String("crash-logs")))
- {
- if (!d.mkdir(QLatin1String("crash-logs")) || !d.cd(QLatin1String("crash-logs")))
- {
- std::cout << "Could not create crash log directory" << std::endl;
- exit(EXIT_FAILURE);
- }
- }
-
- QDateTime now = QDateTime::currentDateTime();
- QFile crashFile(QString("%1/Crash_%2.log").arg(d.absolutePath()).arg(now.toString(Qt::ISODate)));
- if (crashFile.open(QIODevice::WriteOnly))
- {
- QTextStream stream(&crashFile);
- for (int i = 0; i < nptrs; ++i)
- {
- stream << "[" << i << "]: " << strings[i] << "\n";
- }
-
- crashFile.close();
-
- std::cout << "Saved crash log to " << QFileInfo(crashFile).absoluteFilePath().toStdString() << std::endl;
- }
- else
- std::cout << "Could not save crash log to file" << std::endl;
-
- free(strings);
-
- exit(EXIT_FAILURE);
-}
#undef BT_BUF_SIZE
@@ -139,7 +92,6 @@ int main(int argc, char *argv[])
#ifdef Q_OS_LINUX
struct sigaction act;
memset (&act, '\0', sizeof(act));
- act.sa_sigaction = &_handleCrash;
act.sa_flags = SA_SIGINFO;
if (sigaction(SIGSEGV, &act, NULL) < 0)
qWarning() << "Could not install handler for signal SIGSEGV";