cunctator / traceshark

This is a tool for Linux kernel ftrace and perf events visualization
GNU General Public License v3.0
150 stars 19 forks source link

macOS: building with Qt 5.15.2, linking fails: Undefined symbols for architecture x86_64: QArrayData::deallocate #8

Closed mhansen closed 7 months ago

mhansen commented 3 years ago

Hi there, I'm not sure this is a huge priority (probably most users are on linux) but just reporting these issues compiling on macOS:

$ qmake --version
QMake version 3.1
Using Qt version 5.15.2 in /usr/local/Cellar/qt@5/5.15.2/lib

$ make install
/Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -fwhole-program -O2 -std=c++11 -headerpad_max_install_names  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -Wl,-rpath,@executable_path/../Frameworks -o traceshark.app/Contents/MacOS/traceshark obj/qcustomplot.o obj/abstracttaskmodel.o obj/cpuselectdialog.o obj/cpuselectmodel.o obj/cursor.o obj/cursorinfo.o obj/errordialog.o obj/eventinfodialog.o obj/eventselectdialog.o obj/eventselectmodel.o obj/eventsmodel.o obj/eventswidget.o obj/graphenabledialog.o obj/infowidget.o obj/licensedialog.o obj/mainwindow.o obj/migrationarrow.o obj/migrationline.o obj/regexdialog.o obj/regexwidget.o obj/statslimitedmodel.o obj/statsmodel.o obj/tableview.o obj/taskgraph.o obj/taskmodel.o obj/taskrangeallocator.o obj/taskselectdialog.o obj/tasktoolbar.o obj/traceplot.o obj/tracesharkstyle.o obj/valuebox.o obj/yaxisticker.o obj/abstracttask.o obj/cpufreq.o obj/cpuidle.o obj/cputask.o obj/filterstate.o obj/regexfilter.o obj/task.o obj/tcolor.o obj/traceanalyzer.o obj/fileinfo.o obj/traceevent.o obj/tracefile.o obj/traceparser.o obj/ftraceparams.o obj/ftracegrammar.o obj/perfparams.o obj/perfgrammar.o obj/indexwatcher.o obj/loadbuffer.o obj/loadthread.o obj/tthread.o obj/workqueue.o obj/mempool.o obj/errors.o obj/main.o obj/setting.o obj/settingstore.o obj/traceshark.o obj/translate.o obj/bitvector.o obj/error.o obj/qrc_traceshark.o obj/moc_qcustomplot.o obj/moc_abstracttaskmodel.o obj/moc_cpuselectdialog.o obj/moc_cpuselectmodel.o obj/moc_cursor.o obj/moc_cursorinfo.o obj/moc_errordialog.o obj/moc_eventinfodialog.o obj/moc_eventselectdialog.o obj/moc_eventselectmodel.o obj/moc_eventsmodel.o obj/moc_eventswidget.o obj/moc_graphenabledialog.o obj/moc_infowidget.o obj/moc_licensedialog.o obj/moc_mainwindow.o obj/moc_migrationarrow.o obj/moc_migrationline.o obj/moc_regexdialog.o obj/moc_regexwidget.o obj/moc_statslimitedmodel.o obj/moc_statsmodel.o obj/moc_tableview.o obj/moc_taskmodel.o obj/moc_taskselectdialog.o obj/moc_tasktoolbar.o obj/moc_traceplot.o obj/moc_valuebox.o obj/moc_tthread.o   -F/usr/local/Cellar/qt@5/5.15.2/lib -framework QtPrintSupport -framework QtWidgets -framework QtGui -framework AppKit -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL   
ld: warning: object file (obj/abstracttaskmodel.o) was built for newer macOS version (11.0) than being linked (10.13)
ld: warning: object file (obj/cpuselectmodel.o) was built for newer macOS version (11.0) than being linked (10.13)
ld: warning: object file (obj/cursorinfo.o) was built for newer macOS version (11.0) than being linked (10.13)
ld: warning: object file (obj/regexwidget.o) was built for newer macOS version (11.0) than being linked (10.13)
Undefined symbols for architecture x86_64:
  "QArrayData::deallocate(QArrayData*, long long, long long)", referenced from:
      CPUSelectModel::~CPUSelectModel() in cpuselectmodel.o
      CPUSelectModel::~CPUSelectModel() in cpuselectmodel.o
      CPUSelectModel::~CPUSelectModel() in cpuselectmodel.o
      CPUSelectModel::rowToName(int, bool&) const in cpuselectmodel.o
      CPUSelectModel::data(QModelIndex const&, int) const in cpuselectmodel.o
      CPUSelectModel::headerData(int, Qt::Orientation, int) const in cpuselectmodel.o
      CPUSelectModel::rowToName(int, bool&) const (.cold.1) in cpuselectmodel.o
      ...
  "QByteArray::reallocData(long long, QArrayData::AllocationOption)", referenced from:
      CursorInfo::moveTriggered() in cursorinfo.o
  "QString::toLocal8Bit_helper(QChar const*, long long)", referenced from:
      CursorInfo::moveTriggered() in cursorinfo.o
  "QString::fromUtf8(QByteArrayView)", referenced from:
      CursorInfo::CursorInfo(int, QWidget*) in cursorinfo.o
      CursorInfo::updateValue(vtl::Time) in cursorinfo.o
      CursorInfo::createInputMask(unsigned int) in cursorinfo.o
      RegexWidget::RegexWidget(QWidget*, RegexWidget::Type) in regexwidget.o
      RegexWidget::setType(RegexWidget::Type) in regexwidget.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: *** [traceshark.app/Contents/MacOS/traceshark] Error 1

I'm not sure if this is a mismatch in Qt versions (I'm using 5.15 -- the version installed from brew install qt@5, the readme says 5.13. Or perhaps I'm just holding it totally wrong!

mhansen commented 3 years ago

Also possible I'm perhaps building against one Qt and trying to link against another version of Qt? Not sure.

cunctator commented 3 years ago

I have not been successful in reproducing this issue. I was able to build and run traceshark with Big Sur and Qt 5.15.2.

I tried both installing Qt with brew and with macports. As far as I could tell, both worked. EDIT: As a side note, "make install" doesn't work for me either because it fails when trying to install the man page to some apparently incorrect path but I am able to build, link and run the traceshark binary.

cunctator commented 3 years ago

Regarding the missing symbols, they are not used by traceshark directly but they are used indirectly through Qt's header files.

It looks to me as if the toolchain that compiled the traceshark object files has a disagreement with the toolchain that compiled the Qt library regarding various integer types.

For example, looking at the Qt sources, the prototype of one of the functions is: void QArrayData::deallocate(QArrayData *data, size_t objectSize, size_t alignment)

When I look at the preprocessed sources for my build of cpuselectmodel.o, I find these two lines:

typedef long unsigned int __darwin_size_t;
typedef __darwin_size_t size_t;

Apparently, some system header file used by my toolchain defines size_t to be long unsigned int. Judging from the error message posted above, there size_t has apparently been defined as long long.

So it seems likely that the traceshark object files have been compiled with a toolchain that is not fully compatible with the toolchain that Qt has been built with.

Another possibility is that some include path passed as an argument to the compiler is wrong but I consider this to be less likely.

mhansen commented 2 years ago

Thanks for the debugging ideas and pointers. I'll give another go at debugging this.

cunctator commented 7 months ago

There has been no activity on this for over two years. Also, nowadays, the recommended way to build for MacOS is to use brew to install Qt6 and that works for me. I believe that things has changed so much that the problems described here are probably moot.

If there are still issues with building for MacOS, please open a new issue.