Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Update CXXFLAGS in a better way
Browse files Browse the repository at this point in the history
We currently compile with std=c++11 everywhere we can, but
SimulationRuntime/c was missing due to not passing the CXXFLAGS.
These are now detected in a slightly better way, including optimization
flags from CFLAGS if they cause no warnings. Should cause fewer errors
from the static analysis.
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Dec 8, 2016
1 parent e2c90ae commit 4041222
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion SimulationRuntime/c/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ OMC_MINIMAL_RUNTIME=

CPPFLAGS = -I. -I$(top_builddir)/Compiler/runtime -I$(top_builddir)/3rdParty/gc/include -I$(top_builddir)/3rdParty/FMIL/install/include/ -I$(top_builddir)/3rdParty/lis-1.4.12/include/ -I$(top_builddir)/3rdParty/Ipopt/include/ -I$(top_builddir)/3rdParty/sundials/include/ $(CONFIG_CPPFLAGS) -DGC_REDIRECT_TO_LOCAL -I$(builddir_inc)/c
override CFLAGS += $(CPPFLAGS) $(CONFIG_CFLAGS) $(EXTRA_CFLAGS)
override CXXFLAGS += $(CPPFLAGS) $(CONFIG_CFLAGS) $(EXTRA_CFLAGS)

ifeq ($(OMC_MINIMAL_RUNTIME),)
OPTIONAL_LIBS=$(CDASKRDIR)/libcdaskr.a
else
override CFLAGS += -DOMC_MINIMAL_RUNTIME
override CXXFLAGS += -DOMC_MINIMAL_RUNTIME
endif

CXXFLAGS = $(CFLAGS)
FFLAGS = -O -fexceptions
# P.A: before, g77 had -O3 or -O2 but that caused a bug in DDASRT, giving infinite loop.
builddir = ../../build
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/c/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ AR = @AR_SH@
CC = @CC@
CXX = @CXX@
CONFIG_CPPFLAGS = @CPPFLAGS@
CXXFLAGS = @CXXFLAGS@
ifeq ($(OMC_MINIMAL_RUNTIME),)
IPOPT_CFLAGS=@IPOPT_CFLAGS@
else
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/c/Makefile.omdev.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONFIG_CFLAGS = -O2 -falign-functions -msse2 -mfpmath=sse \
-I$(top_builddir)/3rdParty/sundials/build/include \
-I$(OMDEV)/include/lis -I$(top_builddir)/ -I$(builddir_inc)/ \
-Wall -Wno-unused-variable
CXXFLAGS = $(CFLAGS)

# Not needed since we already set fpmath
FPMATHFORTRAN =
Expand Down
8 changes: 4 additions & 4 deletions SimulationRuntime/c/util/omc_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ static inline void va_errorStreamPrint(int stream, int indentNext, const char *f
static inline void va_errorStreamPrintWithEquationIndexes(int stream, int indentNext, const int *indexes, const char *format,va_list ap) {}
#endif

extern void va_throwStreamPrint(threadData_t *threadData, const char *format, va_list ap) __attribute__ ((noreturn, analyzer_noreturn));
extern void throwStreamPrint(threadData_t *threadData, const char *format, ...) __attribute__ ((format (printf, 2, 3), analyzer_noreturn, noreturn));
extern void throwStreamPrintWithEquationIndexes(threadData_t *threadData, const int *indexes, const char *format, ...) __attribute__ ((format (printf, 3, 4), analyzer_noreturn, noreturn));
extern void va_throwStreamPrint(threadData_t *threadData, const char *format, va_list ap) __attribute__ ((noreturn));
extern void throwStreamPrint(threadData_t *threadData, const char *format, ...) __attribute__ ((format (printf, 2, 3), noreturn));
extern void throwStreamPrintWithEquationIndexes(threadData_t *threadData, const int *indexes, const char *format, ...) __attribute__ ((format (printf, 3, 4), noreturn));
#ifdef HAVE_VA_MACROS
#define assertStreamPrint(threadData, cond, ...) if (!(cond)) {throwStreamPrint((threadData), __VA_ARGS__);}
#define assertStreamPrint(threadData, cond, ...) if (!(cond)) {throwStreamPrint((threadData), __VA_ARGS__); assert(0);}
#else
static void OMC_INLINE assertStreamPrint(threadData_t *threadData, int cond, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
static void OMC_INLINE assertStreamPrint(threadData_t *threadData, int cond, const char *format, ...)
Expand Down
12 changes: 11 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ if test -z "$MAKE"; then
MAKE=make
fi

dnl Disables the default CXXFLAGS="-g -O2"
if test -z "$CXXFLAGS"; then
CXXFLAGS=""
fi

AC_ARG_ENABLE(non-free-packages, [ --enable-non-free-packages Enables you to link non-free packages. But doing so limits your ability to distribute code under GPL3, even to co-workers and the like. If you are an OSMC member you might be allowed to link and ship such libraries if you have a commercial license for the linked packages.],[test "yes" = "$enableval" && ENABLE_NON_FREE_PACKAGES=1 && NON_FREE_VERSION=") (non-free version for personal use only; seriously do not distribute this binary"] && FINAL_MESSAGES="$FINAL_MESSAGES\nLinking against non-free packages: Yes (this version of omc not for distribution)")

dnl Checks for programs.
Expand Down Expand Up @@ -182,7 +187,6 @@ AC_TRY_LINK([void abc() {}], [abc();], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([n
fi
fi

dnl Disables the default CFLAGS="-g -O2"
LDFLAGS_BEFORE="$LDFLAGS"
LIBS_BEFORE="$LIBS"
LDFLAGS="$LDFLAGS -Wl,--no-undefined"
Expand Down Expand Up @@ -813,6 +817,12 @@ AC_MSG_RESULT([$MODELICA_SPEC_PLATFORM])

CFLAGS="$CFLAGS"

OLD_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CFLAGS $CXXFLAGS -Werror"
AC_LANG_PUSH([C++])
AC_TRY_LINK([], [], [CXXFLAGS="$CFLAGS $OLD_CXXFLAGS"], [CXXFLAGS="$OLD_CXXFLAGS"])
AC_LANG_POP([C++])

date=`date "+%Y-%m-%d %H:%M:%S"`

GENERATED_AUTOCONF_FILES="Makefile \
Expand Down

0 comments on commit 4041222

Please sign in to comment.