rizinorg / cutter

Free and Open Source Reverse Engineering Platform powered by rizin
https://cutter.re
GNU General Public License v3.0
15.89k stars 1.15k forks source link

Does not build on macOS with Python features enabled: #2266

Closed i0ntempest closed 4 years ago

i0ntempest commented 4 years ago

Environment information

Describe the bug When building with MacPorts installed Python (tried 3.6 to 3.8) and pyside2 and both python feature switches on, I get symbol not found errors:

:info:build /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -rdynamic -headerpad_max_install_names  -arch x86_64 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.15 -Wl,-rpath,@executable_path/../Frameworks -o Cutter.app/Contents/MacOS/Cutter Main.o Cutter.o EditStringDialog.o WriteCommandsDialogs.o DisassemblerGraphView.o OverviewView.o RichTextPainter.o InitialOptionsDialog.o AboutDialog.o CommentsDialog.o EditInstructionDialog.o FlagDialog.o RenameDialog.o RemoteDebugDialog.o NativeDebugDialog.o XrefsDialog.o MainWindow.o Helpers.o HexAsciiHighlighter.o HexHighlighter.o Highlighter.o MdHighlighter.o DirectionalComboBox.o AsmOptionsWidget.o NewFileDialog.o AnalTask.o CommentsWidget.o ConsoleWidget.o Dashboard.o EntrypointWidget.o ExportsWidget.o FlagsWidget.o FunctionsWidget.o ImportsWidget.o Omnibar.o RelocsWidget.o SectionsWidget.o SegmentsWidget.o StringsWidget.o SymbolsWidget.o DisassemblyContextMenu.o DisassemblyWidget.o HexdumpWidget.o Configuration.o Colors.o SaveProjectDialog.o TempConfig.o SvgIconEngine.o SyntaxHighlighter.o DecompilerWidget.o VisualNavbar.o GraphView.o PreferencesDialog.o AppearanceOptionsWidget.o GraphOptionsWidget.o PreferenceCategory.o QuickFilterView.o ClassesWidget.o ResourcesWidget.o VTablesWidget.o TypesWidget.o HeadersWidget.o SearchWidget.o CutterApplication.o PythonAPI.o R2PluginsDialog.o CutterDockWidget.o CutterTreeWidget.o GraphWidget.o OverviewWidget.o JsonTreeItem.o JsonModel.o VersionInfoDialog.o ZignaturesWidget.o AsyncTask.o AsyncTaskDialog.o StackWidget.o RegistersWidget.o ThreadsWidget.o ProcessesWidget.o BacktraceWidget.o MapFileDialog.o CommandTask.o ProgressIndicator.o R2Task.o R2TaskDialog.o DebugActions.o MemoryMapWidget.o DebugOptionsWidget.o PluginsOptionsWidget.o BreakpointWidget.o BreakpointsDialog.o AttachProcDialog.o RegisterRefsWidget.o SetToDataDialog.o EditVariablesDialog.o EditFunctionDialog.o CutterTreeView.o ComboQuickFilterView.o HexdumpRangeDialog.o QtResImporter.o CutterSeekable.o RefreshDeferrer.o WelcomeDialog.o RunScriptTask.o EditMethodDialog.o TypesInteractionDialog.o SdbWidget.o PythonManager.o PluginManager.o BasicBlockHighlighter.o BasicInstructionHighlighter.o LinkTypeDialog.o ColorPicker.o ColorThemeWorker.o ColorThemeComboBox.o ColorThemeListView.o ColorThemeEditDialog.o UpdateWorker.o MemoryDockWidget.o CrashHandler.o BugReporting.o HighDpiPixmap.o GraphGridLayout.o HexWidget.o SelectionHighlight.o Decompiler.o AddressableItemContextMenu.o AddressableItemModel.o ListDockWidget.o MultitypeFileSaveDialog.o BoolToggleDelegate.o IOModesController.o cutterbindings_module_wrapper.o cuttercore_wrapper.o configuration_wrapper.o mainwindow_wrapper.o basicblockhighlighter_wrapper.o addressableitemcontextmenu_wrapper.o cutterdockwidget_wrapper.o cutterplugin_wrapper.o qrc_resources.o qrc_native.o qrc_dark.o qrc_midnight.o qrc_light.o moc_Cutter.o moc_EditStringDialog.o moc_WriteCommandsDialogs.o moc_DisassemblerGraphView.o moc_OverviewView.o moc_AboutDialog.o moc_AsmOptionsWidget.o moc_CommentsDialog.o moc_EditInstructionDialog.o moc_FlagDialog.o moc_RenameDialog.o moc_RemoteDebugDialog.o moc_NativeDebugDialog.o moc_XrefsDialog.o moc_HexAsciiHighlighter.o moc_HexHighlighter.o moc_MainWindow.o moc_Highlighter.o moc_MdHighlighter.o moc_DirectionalComboBox.o moc_InitialOptionsDialog.o moc_NewFileDialog.o moc_AnalTask.o moc_CommentsWidget.o moc_ConsoleWidget.o moc_Dashboard.o moc_EntrypointWidget.o moc_ExportsWidget.o moc_FlagsWidget.o moc_FunctionsWidget.o moc_ImportsWidget.o moc_Omnibar.o moc_RelocsWidget.o moc_SectionsWidget.o moc_SegmentsWidget.o moc_StringsWidget.o moc_SymbolsWidget.o moc_DisassemblyContextMenu.o moc_DisassemblyWidget.o moc_HexdumpWidget.o moc_Configuration.o moc_SaveProjectDialog.o moc_SyntaxHighlighter.o moc_DecompilerWidget.o moc_VisualNavbar.o moc_GraphView.o moc_PreferencesDialog.o moc_AppearanceOptionsWidget.o moc_GraphOptionsWidget.o moc_QuickFilterView.o moc_ClassesWidget.o moc_ResourcesWidget.o moc_CutterApplication.o moc_VTablesWidget.o moc_TypesWidget.o moc_HeadersWidget.o moc_SearchWidget.o moc_R2PluginsDialog.o moc_CutterDockWidget.o moc_CutterTreeWidget.o moc_GraphWidget.o moc_OverviewWidget.o moc_VersionInfoDialog.o moc_ZignaturesWidget.o moc_AsyncTask.o moc_AsyncTaskDialog.o moc_StackWidget.o moc_RegistersWidget.o moc_ThreadsWidget.o moc_ProcessesWidget.o moc_BacktraceWidget.o moc_MapFileDialog.o moc_StringsTask.o moc_FunctionsTask.o moc_CommandTask.o moc_R2Task.o moc_R2TaskDialog.o moc_DebugActions.o moc_MemoryMapWidget.o moc_DebugOptionsWidget.o moc_PluginsOptionsWidget.o moc_BreakpointWidget.o moc_BreakpointsDialog.o moc_AttachProcDialog.o moc_RegisterRefsWidget.o moc_SetToDataDialog.o moc_EditVariablesDialog.o moc_EditFunctionDialog.o moc_CutterTreeView.o moc_ComboQuickFilterView.o moc_HexdumpRangeDialog.o moc_CutterSeekable.o moc_RefreshDeferrer.o moc_WelcomeDialog.o moc_RunScriptTask.o moc_EditMethodDialog.o moc_TypesInteractionDialog.o moc_SdbWidget.o moc_PythonManager.o moc_PluginManager.o moc_UpdateWorker.o moc_ColorPicker.o moc_ColorThemeWorker.o moc_ColorThemeComboBox.o moc_MemoryDockWidget.o moc_ColorThemeListView.o moc_ColorThemeEditDialog.o moc_LinkTypeDialog.o moc_HexWidget.o moc_Decompiler.o moc_AddressableItemContextMenu.o moc_ListDockWidget.o moc_MultitypeFileSaveDialog.o   -F/opt/local/libexec/qt5/lib -L/usr/local/lib -lr_core -lr_config -lr_cons -lr_io -lr_flag -lr_asm -lr_debug -lr_hash -lr_bin -lr_lang -lr_parse -lr_bp -lr_egg -lr_reg -lr_search -lr_syscall -lr_socket -lr_fs -lr_anal -lr_magic -lr_util -lr_crypto -F/opt/local/Library/Frameworks/Python.framework -framework Python /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/shiboken2/libshiboken2.cpython-38-darwin.5.15.dylib /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PySide2/libpyside2.cpython-38-darwin.5.15.dylib -framework QtSvg -framework QtWidgets -framework QtGui -framework AppKit -framework Metal -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL   
:info:build Undefined symbols for architecture x86_64:
:info:build   "_PyBytes_AsString", referenced from:
:info:build       pySideDestructionVisitor(SbkObject*, void*) in PythonManager.o
:info:build   "_PyModule_Create2", referenced from:
:info:build       PyInit_api() in PythonAPI.o
:info:build       PyInit_qtres() in QtResImporter.o
:info:build   "_PyUnicode_AsUTF8String", referenced from:
:info:build       pySideDestructionVisitor(SbkObject*, void*) in PythonManager.o
:info:build   "_PyUnicode_FromString", referenced from:
:info:build       api_version(_object*, _object*) in PythonAPI.o
:info:build       api_cmd(_object*, _object*) in PythonAPI.o
:info:build   "_Py_DecodeLocale", referenced from:
:info:build       PythonManager::initPythonHome() in PythonManager.o
:info:build   "__Py_Dealloc", referenced from:
:info:build       QtResImport(char const*) in QtResImporter.o
:info:build       PluginManager::loadPythonPlugin(char const*) in PluginManager.o
:info:build       _QMap_QString_QVariant__CppToPython__QMap_QString_QVariant_(void const*) in cutterbindings_module_wrapper.o
:info:build       Shiboken::AutoDecRef::~AutoDecRef() in cutterbindings_module_wrapper.o
:info:build       Shiboken::AutoDecRef::~AutoDecRef() in cuttercore_wrapper.o
:info:build       Sbk_CutterCoreFunc_addTypes(_object*, _object*) in cuttercore_wrapper.o
:info:build       Sbk_CutterCoreFunc_ansiEscapeToHtml(_object*, _object*) in cuttercore_wrapper.o
:info:build       ...
:info:build ld: symbol(s) not found for architecture x86_64
:info:build clang: error: linker command failed with exit code 1 (use -v to see invocation)

Complete build log: main.log

To Reproduce

Steps to reproduce the behavior:

  1. Configure with qmake with python and python bindings enabled with paths in appropriate variables (SHIBOKEN_EXECUTABLE etc., full content can be found in the log file)
  2. Run the build
  3. The build fails after a while

Expected behavior It should successfully build

Screenshots

Additional context

karliss commented 4 years ago

Looks like the required python3 symbols weren't linked. Can you try if changing PKGCONFIG += python3 to PKGCONFIG += python3-embed helps?

i0ntempest commented 4 years ago

Thanks with some tinkering it now builds (I had to manually provide python library paths), but it doesnt launch:

$ /Applications/MacPorts/Cutter.app/Contents/MacOS/Cutter 
qt.qpa.fonts: Populating font family aliases took 238 ms. Replace uses of missing font family "Sans-serif" with one that exists to avoid this cost. 
Setting PYTHONHOME = "/Applications/MacPorts/Cutter.app/Contents/MacOS"  for macOS Application Bundle.
PYTHONHOME = "/Applications/MacPorts/Cutter.app/Contents/MacOS"
Python path configuration:
  PYTHONHOME = '/Applications/MacPorts/Cutter.app/Contents/MacOS'
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/Applications/MacPorts/Cutter.app/Contents/MacOS/Cutter'
  sys.base_prefix = '/Applications/MacPorts/Cutter.app/Contents/MacOS'
  sys.base_exec_prefix = '/Applications/MacPorts/Cutter.app/Contents/MacOS'
  sys.executable = '/Applications/MacPorts/Cutter.app/Contents/MacOS/Cutter'
  sys.prefix = '/Applications/MacPorts/Cutter.app/Contents/MacOS'
  sys.exec_prefix = '/Applications/MacPorts/Cutter.app/Contents/MacOS'
  sys.path = [
    '/Applications/MacPorts/Cutter.app/Contents/MacOS/lib/python38.zip',
    '/Applications/MacPorts/Cutter.app/Contents/MacOS/lib/python3.8',
    '/Applications/MacPorts/Cutter.app/Contents/MacOS/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000000117eaedc0 (most recent call first):
<no Python frame>

Use --pythonhome to point to MacPorts python does work, but is there a way to make it use that python installation by default? I tried changing the paths in PythonManager.cpp, the path does change but the program still crashes.