Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ AC_ARG_ENABLE(visibility-hidden,

WARN=''
if test x"$GCC" = xyes; then
WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes -Wno-format-zero-length'
WARN='-Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes'
CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length"

# We require C99 with some GNU extensions, e.g. `linux` macro
CFLAGS="$CFLAGS -std=gnu99"
Expand Down Expand Up @@ -978,7 +979,6 @@ AC_SUBST(JEMALLOC_LDFLAGS)
AC_SUBST(JEMALLOC_AUTOCONF_FLAGS)
fi


# Terminology:
# Crash privacy - Attempts to not send identifying information in the crash dump / to protect the obscurity of the program control flow
# MERP - The MS telemetry profile. Not for general use.
Expand Down Expand Up @@ -1016,6 +1016,43 @@ if test x$enable_monotouch = xyes; then
AC_DEFINE(ENABLE_MONOTOUCH, 1, [Enable runtime support for Monotouch (Xamarin.iOS and Xamarin.Mac)])
fi

AC_ARG_ENABLE(cxx, [ --enable-cxx compile some code as C++])

if test "x$enable_cxx" = "xyes"; then

# FIXME Centos6 requires a different flag for prerelease C++11.
#CXX_ADD_CFLAGS=' -xc++ -std=gnu++98 -fno-exceptions -fno-rtti '
CXX_ADD_CFLAGS=' -xc++ -std=gnu++11 -fno-exceptions -fno-rtti '

# -std=gnu99 -xc++ is not allowed and errors.
CXX_REMOVE_CFLAGS=-std=gnu99
# These give warnings and should be removed. They are C-only.
# i.e. C++ never allows these, they are always errors and their warningness is not controllable.
CXX_REMOVE_CFLAGS="$CXX_REMOVE_CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs"
# Likewise with CentOS 6 gcc 4.4.
CXX_REMOVE_CFLAGS="$CXX_REMOVE_CFLAGS -Werror-implicit-function-declaration"

# The C-only-ness of -Wno-format-zero-length varies with gcc version.
# It is C-only prior to 4.7. Using it with C++ prior to 4.7
# generates a warning every time we run gcc which is very unsightly.
# The warning is for e.g. sprintf(foo, "") which can just be
# foo[0] = 0 but Mono's use is more elaborate, not as easy to "fix",
# and completely legal and valid.
# We have to switch to C++ and not just use -xc++ because of -std=gnu99 (error when combined with -xc++).
# Alternatively, just run $CXX -xc++ -c /dev/null.
AC_LANG_PUSH(C++)
ORIG_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -Werror -Wno-format-zero-length -xc++ "
AC_MSG_CHECKING(or C-only-ness of -Wno-format-zero-length)
AC_TRY_COMPILE([ ], [ ], [ AC_MSG_RESULT(yes) ],
[ AC_MSG_RESULT(no)
CXX_REMOVE_CFLAGS="$CXX_REMOVE_CFLAGS -Wno-format-zero-length" ])
CXXFLAGS=$ORIG_CXXFLAGS
AC_LANG_POP(C++)
fi
AC_SUBST(CXX_ADD_CFLAGS)
AC_SUBST(CXX_REMOVE_CFLAGS)

#
# Set the build profiles and options before things which use them
#
Expand Down
19 changes: 14 additions & 5 deletions mono/metadata/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ libmonoruntime_config_la_CPPFLAGS = $(AM_CPPFLAGS) -DMONO_BINDIR=\"$(bindir)/\"
if DISABLE_ICALL_TABLES
libmono_icall_table_la_SOURCES = \
icall-table.c
libmono_icall_table_la_CFLAGS = $(SGEN_DEFINES)
# Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342.
libmono_icall_table_la_CFLAGS = $(SGEN_DEFINES) @CXX_ADD_CFLAGS@
libmono_icall_table_la_LDFLAGS = $(libmonoldflags)
if BITCODE
libmono_icall_table_la_LIBADD = $(glib_libs) ../utils/libmonoutils.la ../sgen/libmonosgen.la libmonoruntimesgen.la
Expand All @@ -143,7 +144,8 @@ libmono_ilgen_la_SOURCES = \
marshal-ilgen.h \
sgen-mono-ilgen.c \
sgen-mono-ilgen.h
libmono_ilgen_la_CFLAGS = $(SGEN_DEFINES)
# Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342.
libmono_ilgen_la_CFLAGS = $(SGEN_DEFINES) @CXX_ADD_CFLAGS@
libmono_ilgen_la_LDFLAGS = $(libmonoldflags)
if BITCODE
libmono_ilgen_la_LIBADD = $(glib_libs) ../utils/libmonoutils.la ../sgen/libmonosgen.la libmonoruntimesgen.la
Expand Down Expand Up @@ -185,7 +187,8 @@ libmono_system_native_la_SOURCES = \
pal-icalls.h \
pal-icalls.c

libmono_system_native_la_CFLAGS = -I$(abs_top_srcdir)/external/corefx/src/Native/Unix/Common -I$(abs_top_srcdir)/external/corefx/src/Native/Unix/System.Native -Wno-typedef-redefinition
# Add back CXX_REMOVE_CFLAGS to keep this as C until/unless https://github.com/dotnet/corefx/pull/31342.
libmono_system_native_la_CFLAGS = -I$(abs_top_srcdir)/external/corefx/src/Native/Unix/Common -I$(abs_top_srcdir)/external/corefx/src/Native/Unix/System.Native -Wno-typedef-redefinition @CXX_REMOVE_CFLAGS@

CLEANFILES = mono-bundle.stamp

Expand Down Expand Up @@ -404,12 +407,18 @@ sgen_sources = \
sgen-mono.h \
sgen-client-mono.h

# Per-library to workaround CoreFX/native until/unless https://github.com/dotnet/corefx/pull/31342.
#CFLAGS := $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @CXX_ADD_CFLAGS@
CFLAGS := $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@)

libmonoruntime_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources)
libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES)
# Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342.
libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES) @CXX_ADD_CFLAGS@
libmonoruntime_la_LIBADD = libmonoruntime-config.la

libmonoruntimesgen_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(sgen_sources)
libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES)
# Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342.
libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES) @CXX_ADD_CFLAGS@
libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la

libmonoruntimeincludedir = $(includedir)/mono-$(API_VER)/mono/metadata
Expand Down
1 change: 1 addition & 0 deletions mono/mini/Makefile.am.in
Original file line number Diff line number Diff line change
Expand Up @@ -1005,3 +1005,4 @@ Makefile.am: Makefile.am.in $(llvm_makefile_dep)

endif

CFLAGS := $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @CXX_ADD_CFLAGS@
2 changes: 2 additions & 0 deletions mono/sgen/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ monosgen_sources = \

libmonosgen_la_SOURCES = $(monosgen_sources)
libmonosgen_la_CFLAGS = $(SGEN_DEFINES)

CFLAGS := $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @CXX_ADD_CFLAGS@
2 changes: 2 additions & 0 deletions mono/utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,5 @@ DIST_SUBDIRS = jemalloc
if MONO_JEMALLOC_ENABLED
SUBDIRS = jemalloc
endif

CFLAGS := $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @CXX_ADD_CFLAGS@
23 changes: 23 additions & 0 deletions scripts/ci/run-jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ if [ -x "/usr/bin/dpkg-architecture" ];
wget -qO- https://download.mono-project.com/test/new-certs.tgz| tar zx -C ~/.config/.mono/
fi

if [[ ${CI_TAGS} == *'cxx'* ]]; then
EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS -enable-cxx"
fi

if [[ ${CI_TAGS} == *'cplusplus'* ]]; then
EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS -enable-cxx"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be --enable-cxx?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have both cxx and cplusplus that do the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lewurm No, autoconf accepts single dashes everywhere. @akoeplinger PR had me rename but Jenkins uses old form. Once Jenkins is updated then compat can be dropped.

fi

if [[ ${CI_TAGS} == *'win-'* ]];
then
mkdir -p ~/.config/.mono/
Expand Down Expand Up @@ -156,6 +164,7 @@ fi

if [[ ${CI_TAGS} != *'mac-sdk'* ]]; # Mac SDK builds Mono itself
then
echo ./autogen.sh $EXTRA_CONF_FLAGS
${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh $EXTRA_CONF_FLAGS
fi
if [[ ${CI_TAGS} == *'win-i386'* ]];
Expand Down Expand Up @@ -184,6 +193,20 @@ if [[ ${CI_TAGS} == *'linux-ppc64el'* ]]; then make_parallelism=-j1; fi
make_continue=
if [[ ${CI_TAGS} == *'checked-all'* ]]; then make_continue=-k; fi


# FIXME For now C++ means just build mono (metadata, mini, sgen, utils) and ignore errors to get more.
# Once this succeeds, we can let it proceed more normally through tests.
if [[ ${CI_TAGS} == *'cxx'* ]];
then
${TESTCMD} --label=make --timeout=${make_timeout} --fatal make ${make_parallelism} -k -w -C mono V=1
exit 0
fi
if [[ ${CI_TAGS} == *'cplusplus'* ]];
then
${TESTCMD} --label=make --timeout=${make_timeout} --fatal make ${make_parallelism} -k -w -C mono V=1
exit 0
fi

if [[ ${CI_TAGS} != *'mac-sdk'* ]]; # Mac SDK builds Mono itself
then
${TESTCMD} --label=make --timeout=${make_timeout} --fatal make ${make_parallelism} ${make_continue} -w V=1
Expand Down