Skip to content

Commit

Permalink
adapt to msys2 mingw32/mingw64 - ticket:2578
Browse files Browse the repository at this point in the history
* adapt to msys2 mingw32/mingw64 - ticket:2578

* force qt4 build only on Linux
  • Loading branch information
adrpo committed Apr 4, 2016
1 parent 45d32fb commit c463e0a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 31 deletions.
33 changes: 21 additions & 12 deletions OMEdit/OMEditGUI/CrashReport/backtrace.c
Expand Up @@ -162,6 +162,18 @@ release_set(struct bfd_set *set)
}
}

#if defined(__MINGW32__) && !defined(__MINGW64__) /* on 32 bit */
#define REG_BP Ebp /* frame pointer */
#define REG_IP Eip /* program counter */
#define REG_SP Esp /* stack pointer */
#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_I386
#elif defined(__MINGW32__) && defined(__MINGW64__) /* on 64 bit */
#define REG_BP Rbp /* frame pointer */
#define REG_IP Rip /* program counter */
#define REG_SP Rsp /* stack pointer */
#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_AMD64
#endif

void
_backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT context)
{
Expand All @@ -172,23 +184,21 @@ _backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT

STACKFRAME frame;
memset(&frame,0,sizeof(frame));
#if defined(__MINGW32__) && (GCC_VERSION > 40900)
/* adrpo: this doesn't seem to be working for MinGW GCC 4.9.2 */
#else
frame.AddrPC.Offset = context->Eip;

frame.AddrPC.Offset = context->REG_IP; /* program counter */
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrStack.Offset = context->Esp;
frame.AddrStack.Offset = context->REG_SP; /* stack pointer */
frame.AddrStack.Mode = AddrModeFlat;
frame.AddrFrame.Offset = context->Ebp;
frame.AddrFrame.Offset = context->REG_BP; /* frame pointer */
frame.AddrFrame.Mode = AddrModeFlat;
#endif

HANDLE process = GetCurrentProcess();
HANDLE thread = GetCurrentThread();

char symbol_buffer[sizeof(IMAGEHLP_SYMBOL) + 255];
char module_name_raw[MAX_PATH];

while(StackWalk(IMAGE_FILE_MACHINE_I386,
while(StackWalk(IMAGE_FILE_MACHINE_NATIVE,
process,
thread,
&frame,
Expand All @@ -205,11 +215,11 @@ _backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT
symbol->SizeOfStruct = (sizeof *symbol) + 255;
symbol->MaxNameLength = 254;

DWORD module_base = SymGetModuleBase(process, frame.AddrPC.Offset);
HINSTANCE module_base = (HINSTANCE)SymGetModuleBase(process, frame.AddrPC.Offset);

const char * module_name = "[unknown module]";
if (module_base &&
GetModuleFileNameA((HINSTANCE)module_base, module_name_raw, MAX_PATH)) {
GetModuleFileNameA(module_base, module_name_raw, (DWORD)MAX_PATH)) {
module_name = module_name_raw;
bc = get_bc(ob, set, module_name);
}
Expand All @@ -223,8 +233,7 @@ _backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT
}

if (file == NULL) {
DWORD dummy = 0;
if (SymGetSymFromAddr(process, frame.AddrPC.Offset, &dummy, symbol)) {
if (SymGetSymFromAddr(process, frame.AddrPC.Offset, NULL, symbol)) {
file = symbol->Name;
}
else {
Expand Down
17 changes: 2 additions & 15 deletions OMEdit/OMEditGUI/Makefile.omdev.mingw
Expand Up @@ -18,19 +18,6 @@ install: build Resources/nls/qm.stamp
mkdir -p $(builddir_share)/omedit/nls/
cp -p $(resourcedir)/*.qm $(builddir_share)/omedit/nls/
cp -p ../bin/$(NAME)$(EXE) $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/libgcc_s_dw2-1.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/mingwm10.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/mingw/bin/libintl-8.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/mingw/bin/libiconv-2.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/QtCore4.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/QtGui4.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/QtNetwork4.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/QtSvg4.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/QtWebKit4.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/QtXml4.dll $(builddir_bin)
cp -puf $(OMDEV)/tools/OMTools/dll/QtXmlPatterns4.dll $(builddir_bin)
mkdir -p $(builddir_bin)/iconengines/
cp -puf $(OMDEV)/tools/OMTools/dll/qsvgicon4.dll $(builddir_bin)/iconengines/

Resources/nls/qm.stamp: OMEditGUI.pro Resources/nls/*.ts
lrelease $<
Expand All @@ -46,7 +33,7 @@ clean: MakefileClean

parsergen:
$(MAKE) -C Debugger/Parser -f Makefile.lib.omdev.mingw

build: version $(NAME)
$(MAKE) -f Makefile
Makefile: parsergen OMEditGUI.pro
Expand All @@ -71,4 +58,4 @@ else # version is not empty, update it if it changed
else \
echo "#define GIT_SHA \"OMEdit $(GIT_SHA)\"" > version.h; echo Retrieved version number. version.h was created; \
fi;
endif
endif
11 changes: 10 additions & 1 deletion OMEdit/OMEditGUI/OMEditGUI.pro
Expand Up @@ -65,7 +65,16 @@ win32 {
QMAKE_CXXFLAGS += -g
QMAKE_LFLAGS_RELEASE =
# required for backtrace
LIBS += -L$$(OMDEV)/tools/mingw/bin -limagehlp -lbfd -lintl -liberty
# win32 vs. win64
UNAME = $$system(uname)
isEmpty(UNAME): UNAME = MINGW32
ISMINGW32 = $$find(UNAME, MINGW32)
message(uname: $$UNAME)
count( ISMINGW32, 1 ) {
LIBS += -L$$(OMDEV)/tools/msys/mingw32/bin -L$$(OMDEV)/tools/msys/mingw32/lib -L$$(OMDEV)/tools/msys/mingw32/lib/binutils -limagehlp -lbfd -lintl -liberty
} else {
LIBS += -L$$(OMDEV)/tools/msys/mingw64/bin -L$$(OMDEV)/tools/msys/mingw64/lib -L$$(OMDEV)/tools/msys/mingw64/lib/binutils -limagehlp -lbfd -lintl -liberty
}
}
LIBS += -L../OMEditGUI/Debugger/Parser -lGDBMIParser \
-L$$(OMBUILDDIR)/lib/omc -lomantlr3 -lOMPlot -lomqwt \
Expand Down
10 changes: 8 additions & 2 deletions OMEdit/OMEditGUI/Options/OptionsDialog.cpp
Expand Up @@ -3535,12 +3535,18 @@ DebuggerPage::DebuggerPage(OptionsDialog *pOptionsDialog)
// GDB Path
mpGDBPathLabel = new Label(tr("GDB Path:"));
#ifdef WIN32
#if defined(__MINGW32__) && !defined(__MINGW64__)
const char *sgdb = "/tools/msys/mingw32/bin/gdb.exe";
#endif
#if defined(__MINGW64__)
const char *sgdb = "/tools/msys/mingw64/bin/gdb.exe";
#endif
const char *OMDEV = getenv("OMDEV");
if (QString(OMDEV).isEmpty()) {
mpGDBPathTextBox = new QLineEdit(QString(Helper::OpenModelicaHome).append("/MinGW/bin/gdb.exe"));
mpGDBPathTextBox = new QLineEdit(QString(Helper::OpenModelicaHome).append(sgdb));
} else {
QString qOMDEV = QString(OMDEV).replace("\\", "/");
mpGDBPathTextBox = new QLineEdit(QString(qOMDEV).append("/tools/mingw/bin/gdb.exe"));
mpGDBPathTextBox = new QLineEdit(QString(qOMDEV).append(sgdb));
}
#else
mpGDBPathTextBox = new QLineEdit("gdb");
Expand Down
7 changes: 6 additions & 1 deletion OMEdit/OMEditGUI/Simulation/SimulationProcessThread.cpp
Expand Up @@ -76,7 +76,12 @@ void SimulationProcessThread::compileModel()
SimulationPage *pSimulationPage = mpSimulationOutputWidget->getMainWindow()->getOptionsDialog()->getSimulationPage();
QStringList args;
#ifdef WIN32
args << simulationOptions.getOutputFileName() << pSimulationPage->getTargetCompilerComboBox()->currentText() << "parallel" << numProcs << "0";
#if defined(__MINGW32__) && defined(__MINGW64__) /* on 64 bit */
const char* omPlatform = "mingw64";
#else
const char* omPlatform = "mingw32";
#endif
args << simulationOptions.getOutputFileName() << pSimulationPage->getTargetCompilerComboBox()->currentText() << omPlatform << "parallel" << numProcs << "0";
QString compilationProcessPath = QString(Helper::OpenModelicaHome) + "/share/omc/scripts/Compile.bat";
mpCompilationProcess->start(compilationProcessPath, args);
emit sendCompilationOutput(QString("%1 %2\n").arg(compilationProcessPath).arg(args.join(" ")), Qt::blue);
Expand Down
4 changes: 4 additions & 0 deletions qjson/CMakeLists.txt
Expand Up @@ -41,7 +41,11 @@ SET(FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Library/Frameworks"
SET(QT_USE_IMPORTED_TARGETS TRUE)

option(QT4_BUILD "Force building with Qt4 even if Qt5 is found")
IF (WIN32)
# set(QT4_BUILD ON)
ELSE(WIN32)
set(QT4_BUILD ON)
ENDIF(WIN32)

IF (NOT QT4_BUILD)
FIND_PACKAGE( Qt5Core QUIET )
Expand Down

0 comments on commit c463e0a

Please sign in to comment.