Skip to content

Commit

Permalink
Fixes to compile using msys2 on Linux
Browse files Browse the repository at this point in the history
OMC now compiles fine, but fails to load due to missing DLLs (some
files were compiled as .a-files, but were in fact DLLs, etc).
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Nov 13, 2015
1 parent 4f43fa1 commit f19ece7
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 33 deletions.
10 changes: 5 additions & 5 deletions Compiler/FrontEnd/Types.mo
Expand Up @@ -8249,13 +8249,13 @@ public function makeCallAttr
output DAE.CallAttributes callAttr;
protected
Boolean isImpure,isT,isB;
DAE.FunctionBuiltin builtin;
DAE.InlineType inline;
DAE.FunctionBuiltin isbuiltin;
DAE.InlineType isinline;
algorithm
DAE.FUNCTION_ATTRIBUTES(isBuiltin=builtin,isImpure=isImpure,inline=inline) := attr;
DAE.FUNCTION_ATTRIBUTES(isBuiltin=isbuiltin,isImpure=isImpure,inline=isinline) := attr;
isT := isTuple(ty);
isB := isBuiltin(builtin);
callAttr := DAE.CALL_ATTR(ty,isT,isB,isImpure,false,inline,DAE.NO_TAIL());
isB := isBuiltin(isbuiltin);
callAttr := DAE.CALL_ATTR(ty,isT,isB,isImpure,false,isinline,DAE.NO_TAIL());
end makeCallAttr;

public function getFuncArg
Expand Down
4 changes: 2 additions & 2 deletions Compiler/boot/Makefile.common
Expand Up @@ -143,13 +143,13 @@ $(OMHOME)/$(LIB_OMC)/libOpenModelicaCompiler$(SHREXT): $(ALL_OBJECTS) $(OMHOME)/
$(CC) -shared $(RPATH) $(INSTALL_NAME) -o $@ $^ $(LDFLAGS)
test ! "$(SHREXT)" = ".dylib" || install_name_tool -id @rpath/libOpenModelicaCompiler.dylib $@

ifeq ($(STATIC),)
ifeq (${STATIC},)
#shared
$(GEN_DIR)omc$(EXE_EXT): $(OMHOME)/$(LIB_OMC)/libOpenModelicaCompiler$(SHREXT) $(GEN_DIR)_main_omc.o $(GEN_DIR)_main.o
$(CC) $(GEN_DIR)_main.o $(RPATH) $(CFLAGS) $(CPPFLAGS) -o $@ $(LDFLAGS) -lOpenModelicaCompiler
install: $(GEN_DIR)omc$(EXE_EXT) install-interface
cp -a $< $(OMHOME)/bin/
cp -a $(OMHOME)/$(LIB_OMC)/libOpenModelicaCompiler$(SHREXT) $(OMHOME)/bin/
test ! "$(SHREXT)" = ".dll" || cp -a $(OMHOME)/$(LIB_OMC)/libOpenModelicaCompiler$(SHREXT) $(OMHOME)/bin/

else
#static
Expand Down
1 change: 1 addition & 0 deletions Compiler/boot/Makefile.in
Expand Up @@ -7,6 +7,7 @@ CXX=@CXX@
CFLAGS=@CFLAGS@
TOP_DIR=@abs_top_builddir@
OMHOME=@OMBUILDDIR@
EXE_EXT=@EXE@

LIB_OMC=lib/@host_short@/omc
LDFLAGS=-L. -L$(GEN_DIR) -L"$(OMHOME)/$(LIB_OMC)" -lomparse -lomcruntime -lOpenModelicaRuntimeC -lModelicaExternalC -lomantlr3 $(CORBALIBS) $(FMILIB) $(GSLIB) @RT_LDFLAGS@ @LIBSOCKET@ @LIBLPSOLVE55@ @OMC_LIBS@ @GRAPHLIB@ -lexpat @LD_LAPACK@
Expand Down
4 changes: 3 additions & 1 deletion Compiler/runtime/Makefile.common
Expand Up @@ -22,9 +22,11 @@ endif
OMC_OBJ = Error_omc.o Print_omc.o System_omc.o Settings_omc.o serializer.o \
IOStreamExt_omc.o ErrorMessage.o FMI_omc.o systemimplmisc.o \
UnitParserExt_omc.o unitparser.o BackendDAEEXT_omc.o Socket_omc.o matching.o matching_cheap.o \
Database_omc.o Dynload_omc.o SimulationResults_omc.o TaskGraphResults_omc.o HpcOmSchedulerExt_omc.o HpcOmBenchmarkExt_omc.o ptolemyio_omc.o \
Dynload_omc.o SimulationResults_omc.o TaskGraphResults_omc.o HpcOmSchedulerExt_omc.o HpcOmBenchmarkExt_omc.o ptolemyio_omc.o \
Lapack_omc.o getMemorySize.o GraphStreamExt_omc.o $(OMCCORBASRC)

# Database_omc.o

all: install
.PHONY: all install
install: libomcruntime.a
Expand Down
1 change: 0 additions & 1 deletion Compiler/runtime/config.unix.h.in
Expand Up @@ -41,7 +41,6 @@
#define CONFIG_DEFAULT_OPENMODELICAHOME "@prefix@"
#define CONFIG_PATH_DELIMITER "/"
#define CONFIG_GROUP_DELIMITER ":"
#define CONFIG_USER_IS_ROOT (geteuid() == 0 ? 1 : 0)
#define CONFIG_CORBALIBS "@CORBALIBS@"
#define CONFIG_LPSOLVE55 "@LIBLPSOLVE55@"
#define CONFIG_REVISION "@SOURCE_REVISION@"
Expand Down
10 changes: 8 additions & 2 deletions Compiler/runtime/omc_config.h
Expand Up @@ -31,7 +31,13 @@
#ifndef OPENMODELICA_CONFIG_H
#define OPENMODELICA_CONFIG_H

#if defined(NO_AUTOCONF) || (defined(__MINGW32__) || defined(_MSC_VER)) /* Windows */
#if defined(__MINGW32__) || defined(_MSC_VER)
#define CONFIG_USER_IS_ROOT 0
#else
#define CONFIG_USER_IS_ROOT (geteuid() == 0 ? 1 : 0)
#endif

#if !defined(MSYS2_AUTOCONF) && (defined(__MINGW32__) || defined(_MSC_VER)) /* Windows */

#define DEFAULT_CC "gcc"
#define DEFAULT_CXX "g++"
Expand All @@ -44,7 +50,7 @@
#define CONFIG_PLATFORM "WIN32"
#define CONFIG_MODELICA_SPEC_PLATFORM "win32"
#define CONFIG_OPENMODELICA_SPEC_PLATFORM "mingw32"
#define CONFIG_USER_IS_ROOT 0

#define CONFIG_WITH_OPENMP 1

#define CONFIG_DEFAULT_OPENMODELICAHOME NULL
Expand Down
4 changes: 2 additions & 2 deletions Makefile.in
Expand Up @@ -11,8 +11,8 @@ includedir = @includedir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
CMAKE = CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="@CMAKE_LDFLAGS@" cmake
CMAKE_RPATH = CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="@RPATH_QMAKE@ @CMAKE_LDFLAGS@" cmake
CMAKE = CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="@CMAKE_LDFLAGS@" cmake @CMAKE_EXTRA_DEFINES@
CMAKE_RPATH = CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="@RPATH_QMAKE@ @CMAKE_LDFLAGS@" cmake @CMAKE_EXTRA_DEFINES@
CMAKE_TARGET = "Unix Makefiles"
OPENCL = @OPENCL@
AR = @AR@
Expand Down
4 changes: 2 additions & 2 deletions Parser/Makefile.common
Expand Up @@ -17,7 +17,7 @@ install: $(ANTLR_LIB) libomparse.a
cp $(ANTLR_LIB) libomparse.a $(OMBUILDDIR)/$(LIB_OMC)/

$(ANTLR)/antlr3config.h: $(ANTLR)/antlr3config.h.in $(ANTLR)/configure
(cd $(ANTLR) && ./configure $(ANTLR64) $(ANTLRDEBUG) $(host) CC="$(CC)" LDFLAGS="" CFLAGS="" CPPFLAGS="")
(cd $(ANTLR) && ./configure $(ANTLR64) $(ANTLRDEBUG) $(host) CC="$(CC)" LDFLAGS="" CFLAGS="$(CFLAGS)" CPPFLAGS="")
libomantlr3.a: $(ANTLR)/src/*.c $(ANTLR)/include/*.h $(ANTLR)/antlr3config.h
# build the library
$(CC) ${CFLAGS} ${CPPFLAGS} -c $(ANTLR)/src/*.c -I$(ANTLR)/include -I$(ANTLR)
Expand All @@ -27,7 +27,7 @@ libomantlr3.a: $(ANTLR)/src/*.c $(ANTLR)/include/*.h $(ANTLR)/antlr3config.h
rm -f antlr3*.o
libomantlr3$(SHREXT): $(ANTLR)/src/*.c $(ANTLR)/include/*.h $(ANTLR)/antlr3config.h
# build the library
$(CC) -shared -o $@ ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} $(ANTLR)/src/*.c -I$(ANTLR)/include -I$(ANTLR)
$(CC) -shared -o $@ ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} -DANTLR3_NODEBUGGER $(ANTLR)/src/*.c -I$(ANTLR)/include -I$(ANTLR)
test ! `uname` = Darwin || install_name_tool -id "@rpath/$@" $@

HFILES = \
Expand Down
3 changes: 2 additions & 1 deletion Parser/Makefile.in
Expand Up @@ -7,8 +7,9 @@ SHREXT=@SHREXT@
ifeq (x86_64,@target_cpu@)
ANTLR64=--enable-64bit
endif
ANTLRDEBUG=--disable-antlrdebug
ifeq (arm,@target_cpu@)
ANTLRDEBUG=--disable-antlrdebug --disable-abiflags
ANTLRDEBUG+=--disable-abiflags
endif
host=--host=@host@
host_short=@host_short@
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/util/omc_msvc.c
Expand Up @@ -64,7 +64,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap) {
#if !defined(OMC_MINIMAL_RUNTIME)

#include <windows.h>
#include <TlHelp32.h>
#include <tlhelp32.h>
#include <time.h>

#ifndef SIGALRM
Expand Down
36 changes: 20 additions & 16 deletions configure.ac
Expand Up @@ -303,10 +303,7 @@ fi

dnl Misc. headers

AC_CHECK_HEADER(expat.h,,
CPPFLAGS="$CPPFLAGS -I \"$ac_top_srcdir/3rdParty/FMIL/Expat/lib\""
AC_MSG_RESULT([using local expat.h])
)
AC_CHECK_HEADER(expat.h,,AC_MSG_ERROR([no]))

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
Expand Down Expand Up @@ -413,9 +410,6 @@ LIBS=""
CC="$CC_OLD"
CFLAGS="$CFLAGS_OLD"

if echo "$host" | grep -q "mingw"; then
true
else
dnl check for lpsolve55

AC_ARG_WITH(lpsolve, [ --with-lpsolve (default searching for lpsolve; disable if only using omc to cross-compile)],[if test "$withval" = "no"; then NO_LPLIB="#define NO_LPLIB"; fi],[])
Expand All @@ -432,7 +426,7 @@ if test "$WANT_STATIC_LPSOLVE" = "no"; then
LIBDL="$LIBS"
AC_SEARCH_LIBS(sqrt,m)
AC_SEARCH_LIBS(colamd,colamd)
AC_SEARCH_LIBS(make_lp,[lpsolve55_pic lpsolve55],[],[AC_MSG_ERROR([lpsolve linking failed using $LIBS])])
AC_SEARCH_LIBS(make_lp,[lpsolve55_pic lpsolve55],[],[MINGW_EXTRA_LIBS="$MINGW_EXTRA_LIBS lpsolve"; AC_MSG_RESULT([lpsolve linking failed using $LIBS])])
LIBLPSOLVE55=$LIBS
LIBS=""
else
Expand All @@ -446,15 +440,19 @@ else
AC_SEARCH_LIBS(sqrt,m)
LIBS="$LPLIB/liblpsolve55_pic.a $LPLIB/libcolamd.a $LIBS"
AC_MSG_CHECKING([for static lpsolve55])
AC_LINK_IFELSE([AC_LANG_CALL([], [make_lp])], [LIBLPSOLVE55=$LIBS], [AC_MSG_ERROR([failed])])
AC_LINK_IFELSE([AC_LANG_CALL([], [make_lp])], [LIBLPSOLVE55=$LIBS], [MINGW_EXTRA_LIBS="$MINGW_EXTRA_LIBS lpsolve"; AC_MSG_RESULT([failed])])
AC_MSG_RESULT([$LIBLPSOLVE55])
LIBS=""
fi
AC_CHECK_HEADER([lp_lib.h],[LPSOLVEINC=lp_lib.h],[
AC_CHECK_HEADER([lpsolve/lp_lib.h],[LPSOLVEINC=lpsolve/lp_lib.h],[AC_MSG_ERROR([failed to find lpsolve55 headers])])
AC_CHECK_HEADER([lpsolve/lp_lib.h],[LPSOLVEINC=lpsolve/lp_lib.h],[
if ! ( echo $MINGW_EXTRA_LIBS | grep -q lpsolve ); then
MINGW_EXTRA_LIBS="$MINGW_EXTRA_LIBS lpsolve";
fi
AC_MSG_RESULT([failed to find lpsolve55 headers])
])
])

fi
fi # NO_LPLIB

if ! (echo "$host" | grep -q "mingw"); then
Expand Down Expand Up @@ -613,6 +611,7 @@ AC_CHECK_HEADER([CL/cl.h],[OPENCL="Yes"],[
FINAL_MESSAGES="$FINAL_MESSAGES\nParModelica: $OPENCL"

AC_SUBST(CMAKE_LDFLAGS)
AC_SUBST(CMAKE_EXTRA_DEFINES)
if test "$DARWIN" = "1"; then
APP=".app"
EXE=".app"
Expand Down Expand Up @@ -643,11 +642,11 @@ if test "$DARWIN" = "1"; then
OMC_LIBS="$(OMC_LIBS) -Wl,-undefined -Wl,dynamic_lookup"
BOOTSTRAP_STATIC=""
CMAKE_LDFLAGS="-Wl,-undefined -Wl,dynamic_lookup"
elif test "$host" = "i586-pc-mingw32msvc"; then
elif echo "$host" | grep -iq "mingw"; then
APP=".exe"
EXE=".exe"
# Yes, we build static libs on Windows, so the "shared" extension is .a
SHREXT=".a"
SHREXT=".dll"
LIBGC="$OMBUILDDIR/lib/$host_short/omc/libomcgc.a"
LIBSIMULATION=libSimulationRuntimeC.a
LIBRUNTIME=libOpenModelicaRuntimeC.a
Expand All @@ -664,12 +663,17 @@ elif test "$host" = "i586-pc-mingw32msvc"; then
RT_LDFLAGS_GENERATED_CODE_SIM="$LDFLAGS -lSimulationRuntimeC -lcdaskr $RT_LDFLAGS_SIM"
RT_LDFLAGS_GENERATED_CODE_SOURCE_FMU="$LDFLAGS $LD_LAPACK -lm$LD_NOUNDEFINED"
LINK="cp -frl"
RPATH="-Wl,-z,origin -Wl,-rpath,'\$\$ORIGIN/../lib/$host_short/omc' -Wl,-rpath,'\$\$ORIGIN'"
RPATH_QMAKE="-Wl,-z,origin -Wl,-rpath,\\'\\\$\$ORIGIN/../lib/$host_short/omc\\' -Wl,-rpath,\\'\\\$\$ORIGIN\\'"
# No RPATH in Windows :(
RPATH=""
RPATH_QMAKE=""
OS_TARGET="windows"
AR_SH="$AR -ru"
LDFLAGS_SOCKET=" -lwsock32"
BOOTSTRAP_STATIC="static"
BOOTSTRAP_STATIC=""
AC_CHECK_TOOL(WINDRES, windres, [AC_MSG_ERROR([no])])
CMAKE_EXTRA_DEFINES="-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RC_COMPILER=$WINDRES"
CPPFLAGS="$CPPFLAGS -DMSYS2_AUTOCONF=1"
OMC_LIBS="$OMC_LIBS -lstdc++ -lwsock32 -ltre -liconv -lintl -lshlwapi"
else
APP=""
EXE=""
Expand Down

0 comments on commit f19ece7

Please sign in to comment.