Skip to content
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ META
/parsing/camlinternalMenhirLib.ml
/parsing/camlinternalMenhirLib.mli

/runtime/api-testing
/runtime/domain_state.inc
/runtime/caml/m.h
/runtime/caml/s.h
Expand Down
75 changes: 75 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,80 @@ runtime-all: \
$(runtime_BYTECODE_SHARED_LIBRARIES:%=runtime/lib%_shared$(EXT_DLL)) \
$(runtime_PROGRAMS:%=runtime/%$(EXE)) $(SAK)

# If the compiler is configured with --enable-warn-error (which is the default
# for development builds), then all the installed header files are tested with
# more warnings enabled. The test also ensures that each header can be included
# without any other headers.
ifneq "$(EXTRA_WARNINGS_CFLAGS)" ""
runtime-all: runtime-header-tests
endif

# As with the runtime-header-tests, if a C++ compiler is available, then we also
# verify that the headers can be included in a C++ program without error.
ifneq "$(EXTRA_WARNINGS_CXXFLAGS)" ""
ifneq "$(TEST_CXX)" ""
runtime-all: runtime-header-cxx-tests
endif
endif

# Unlike in COMPILE_C_FILE, this is just a convenience test, so we don't do any
# effort with the dependency computations worrying about DEP_CC and so forth,
# because most _development_ is done with feature-rich C compilers!
API_TESTING_DEP_FILES := $(wildcard runtime/api-testing/*.$(D))
.PHONY: $(API_TESTING_DEP_FILES)
include $(API_TESTING_DEP_FILES)

ALL_PUBLIC_HEADER_FILES := $(notdir $(sort $(wildcard \
$(addsuffix /caml/*.h, $(addprefix otherlibs/, $(OTHERLIBS))) \
runtime/caml/*.h \
$(filter runtime/caml/%, $(runtime_BUILT_HEADERS)))))

runtime-header-tests: \
$(addprefix runtime/api-testing/,$(ALL_PUBLIC_HEADER_FILES:.h=.t))

runtime-header-cxx-tests: \
$(addprefix runtime/api-testing/,$(ALL_PUBLIC_HEADER_FILES:.h=.tpp))

.PRECIOUS: runtime/api-testing
runtime/api-testing:
$(MKDIR) $@

runtime/api-testing/%.t: runtime/api-testing/%.c.$(O)
@touch $@

runtime/api-testing/%.tpp: runtime/api-testing/%.cpp.$(O)
@touch $@

runtime/api-testing/%.c.$(O): runtime/api-testing/%.c
$(V_CC)$(CC) \
$(OC_CFLAGS) $(EXTRA_WARNINGS_CFLAGS) $(CFLAGS) \
$(OC_CPPFLAGS) \
$(call DEP_FLAGS,$@,$(@:.$(O)=.$(D))) \
$(addprefix -I otherlibs/, $(OTHERLIBS)) $(CPPFLAGS) \
$(OUTPUTOBJ)$@ -c $<

runtime/api-testing/%.c: | runtime/api-testing
$(V_GEN){ \
echo '#include <caml/$*.h>'; \
echo '#include <caml/$*.h>'; \
echo 'int answer = 42;'; \
} > $@

runtime/api-testing/%.cpp.$(O): runtime/api-testing/%.cpp
$(V_CXX)$(TEST_CXX) \
$(TEST_CXX_CXXFLAGS) $(EXTRA_WARNINGS_CXXFLAGS) $(CXXFLAGS) \
$(TEST_CXX_CPPFLAGS) \
$(call DEP_FLAGS,$@,$(@:.$(O)=.$(D))) \
-I runtime $(addprefix -I otherlibs/, $(OTHERLIBS)) $(CPPFLAGS) \
$(OUTPUTOBJ)$@ -c $<

runtime/api-testing/%.cpp: | runtime/api-testing
$(V_GEN){ \
echo '#include <caml/$*.h>'; \
echo '#include <caml/$*.h>'; \
echo 'int answer = 42;'; \
} > $@

.PHONY: runtime-allopt
ifeq "$(NATIVE_COMPILER)" "true"
runtime-allopt: \
Expand Down Expand Up @@ -2709,6 +2783,7 @@ endif
otherlibs/dynlink/dynlink_platform_intf.mli
$(MAKE) -C otherlibs distclean
rm -f $(runtime_CONFIGURED_HEADERS) runtime/ld.conf
rm -rf runtime/api-testing
$(MAKE) -C stdlib distclean
$(MAKE) -C testsuite distclean
rm -f tools/eventlog_metadata tools/*.bak
Expand Down
8 changes: 8 additions & 0 deletions Makefile.build_config.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ DEP_FLAGS =
endif
COMPUTE_DEPS=@compute_deps@

TEST_CXX = @ocamltest_CXX@
TEST_CXX_CXXFLAGS = @common_cflags@
TEST_CXX_CPPFLAGS = @common_cppflags@
CXXFLAGS ?=

BUILD_PATH_LOGICAL = @srcdir_abs@
BUILD_PATH_PHYSICAL = @srcdir_abs_real@
BUILD_MAP_FLAGS = @build_map_flags@
Expand All @@ -107,6 +112,9 @@ OC_BYTECODE_CPPFLAGS = $(OC_INCLUDES) @oc_bytecode_cppflags@

OC_NATIVE_CPPFLAGS = $(OC_INCLUDES) @oc_native_cppflags@

EXTRA_WARNINGS_CFLAGS = @cc_extra_warnings@
EXTRA_WARNINGS_CXXFLAGS = @cxx_extra_warnings@

# Additional link-time options
# To support dynamic loading of shared libraries (they need to look at
# our own symbols):
Expand Down
2 changes: 2 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ V ?= 0
ifeq "$(V)" "0"

V_CC = @$(info $ CC $@)
V_CXX = @$(info $ CXX $@)
V_CCDEPS = @$(info $ CCDEPS $@)
V_OCAMLC = @$(info $ OCAMLC $@)
V_OCAMLOPT = @$(info $ OCAMLOPT $@)
Expand All @@ -66,6 +67,7 @@ V_ODOC = @$(info $ ODOC $@)
else

V_CC =
V_CXX =
V_CCDEPS =
V_OCAMLC =
V_OCAMLOPT =
Expand Down
24 changes: 24 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -651,3 +651,27 @@ AC_DEFUN([OCAML_CHECK_WINDOWS_TRIPLET], [
[*-pc-windows*],
[AC_MSG_ERROR([unknown MSVC variant])])
])

# It's difficult to use AC_PROG_CXX or AX_CXX_COMPILE_STDCXX conditionally.
# This macro is only used for ocamltest to call the C++11 compiler if the
# default C compiler also can build C++.
AC_DEFUN([OCAML_CXX_COMPILE_STDCXX_11], [
AC_CACHE_CHECK([for a C++11 compiler],
[ocaml_cv_prog_cxx], [
AS_CASE(["$ccomp_type"],
[cc], [
saved_CC="$CC"
CC="$CC -xc++"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if !defined(__cplusplus) || __cplusplus < 201103L
#error "No C++11 support"
#endif
]])],
[ocaml_cv_prog_cxx="$CC"],
[ocaml_cv_prog_cxx=""])
CC="$saved_CC"],
[msvc], [
# cl.exe selects between C and C++ based on the file extension
ocaml_cv_prog_cxx="$CC"],
[ocaml_cv_prog_cxx=""])])
ocamltest_CXX="$ocaml_cv_prog_cxx"])
70 changes: 66 additions & 4 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ AC_SUBST([optional_libraries])
AC_SUBST([optional_bytecode_tools])
AC_SUBST([optional_native_tools])
AC_SUBST([ocamltest_CPP])
AC_SUBST([ocamltest_CXX])
AC_SUBST([ocamltest_libunix])
AC_SUBST([unix_library])
AC_SUBST([unix_directory])
Expand Down Expand Up @@ -288,6 +289,8 @@ AC_SUBST([native_runtime_id])
AC_SUBST([suffixing])
AC_SUBST([runtime_search])
AC_SUBST([runtime_search_target])
AC_SUBST([cc_extra_warnings])
AC_SUBST([cxx_extra_warnings])

## Generated files

Expand Down Expand Up @@ -1035,17 +1038,25 @@ AS_IF([test "x$interpval" = "xyes"],
AS_CASE([$ocaml_cc_vendor],
[xlc-*],
[warn_error_flag=''
cc_extra_warnings=''
cxx_extra_warnings=''
cc_warnings='-qflag=i:i'], # all warnings enabled
[sunc-*],
[cc_warnings=""],
[cc_extra_warnings=''
cxx_extra_warnings=''
cc_warnings=''],
[msvc-*],
[AS_CASE([$ocaml_cc_vendor],
[msvc-*-clang-*],
[cc_warnings='-W4 -Wno-unused-parameter -Wno-sign-compare -Wundef'
warn_error_flag='-WX'],
[cc_warnings='-W2'
warn_error_flag='-WX -options:strict'])],
cc_extra_warnings='-permissive-'
warn_error_flag='-WX -options:strict'
cxx_extra_warnings="$cc_extra_warnings $warn_error_flag"])],
[warn_error_flag='-Werror'
cc_extra_warnings='-Wextra -Wpedantic -pedantic -std=c11'
cxx_extra_warnings='-Werror -Wextra -Wpedantic -pedantic'
cc_warnings="-Wall -Wint-conversion -Wstrict-prototypes \
-Wold-style-definition -Wundef"])

Expand All @@ -1068,7 +1079,9 @@ done

AS_CASE([$enable_warn_error,OCAML__DEVELOPMENT_VERSION],
[yes,*|,true],
[cc_warnings="$cc_warnings $warn_error_flag"])
[cc_warnings="$cc_warnings $warn_error_flag"],
[cc_extra_warnings=''
cxx_extra_warnings=''])

AS_CASE([$target],
[*-w64-mingw32*|*-pc-windows],
Expand Down Expand Up @@ -2831,7 +2844,8 @@ testsuite/tools/test_in_prefix.opt"],
[optional_bytecode_tools="$optional_bytecode_tools \
testsuite/tools/test_in_prefix"])
testsuite_tools='testsuite/tools/codegen testsuite/tools/expect'
optional_bytecode_tools="$optional_bytecode_tools $testsuite_tools"],
optional_bytecode_tools="$optional_bytecode_tools $testsuite_tools"
OCAML_CXX_COMPILE_STDCXX_11],
[build_ocamltest=false
ocamltest=''])

Expand Down
6 changes: 6 additions & 0 deletions runtime/caml/sizeclasses.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* This file is generated by tools/gen_sizeclasses.ml */

#ifndef CAML_SIZECLASSES_H
#define CAML_SIZECLASSES_H

#define POOL_WSIZE 4096
#define POOL_HEADER_WSIZE 4
#define SIZECLASS_MAX 128
Expand Down Expand Up @@ -59,3 +63,5 @@ static const sizeclass sizeclass_wsize[SIZECLASS_MAX + 1] =
/*115:*/ 30, 30, 30, 30, 31,
/*120:*/ 31, 31, 31, 31, 31,
/*125:*/ 31, 31, 31, 31 };

#endif /* CAML_SIZECLASSES_H */
3 changes: 3 additions & 0 deletions tools/gen_sizeclasses.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ let print_list ppf li =

let _ =
printf "/* This file is generated by tools/gen_sizeclasses.ml */\n";
printf "\n#ifndef CAML_SIZECLASSES_H\n";
printf "#define CAML_SIZECLASSES_H\n\n";
printf "#define POOL_WSIZE %d\n" arena;
printf "#define POOL_HEADER_WSIZE %d\n" header_size;
printf "#define SIZECLASS_MAX %d\n" max_slot;
Expand All @@ -115,3 +117,4 @@ static const unsigned char wastage_sizeclass[NUM_SIZECLASSES] =@[<2>{ %a };@]
static const sizeclass sizeclass_wsize[SIZECLASS_MAX + 1] =@[<2>{ %a };@]
|}
print_list (255 :: size_slots 1);
printf "\n#endif /* CAML_SIZECLASSES_H */\n"
Loading