Skip to content

Commit

Permalink
Support bootstrap compiler in configure
Browse files Browse the repository at this point in the history
Split the cold Makefile target into compiler and cold. Allows a compiler
to be bootstrapped before running configure. configure updated so that
if the boot strap has been built, PATH is altered to use it. The change
is persisted in Makefile.config, along with OCAMLLIB.
  • Loading branch information
dra27 committed Jan 11, 2018
1 parent b1f3836 commit bb87113
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Makefile
Expand Up @@ -70,7 +70,7 @@ OPAMINSTALLER_FLAGS += --mandir "$(DESTDIR)$(mandir)"
ifdef OCAMLFIND
ifndef DESTDIR
ifneq ($(OCAMLFIND),no)
LIBINSTALL_DIR ?= $(shell $(OCAMLFIND) printconf destdir)
LIBINSTALL_DIR ?= $(shell PATH="$(PATH)" $(OCAMLFIND) printconf destdir)
endif
endif
endif
Expand Down Expand Up @@ -164,8 +164,11 @@ endif
endif
endif

cold:
.PHONY: compiler cold
compiler:
env MAKE=$(MAKE) ./shell/bootstrap-ocaml.sh $(OCAML_PORT)

cold: compiler
env PATH="`pwd`/bootstrap/ocaml/bin:$$PATH" ./configure $(CONFIGURE_ARGS)
env PATH="`pwd`/bootstrap/ocaml/bin:$$PATH" $(MAKE) lib-ext
env PATH="`pwd`/bootstrap/ocaml/bin:$$PATH" $(MAKE)
Expand Down
4 changes: 3 additions & 1 deletion Makefile.config.in
Expand Up @@ -10,6 +10,8 @@ CONF_OCAMLFLAGS = @CONF_OCAMLFLAGS@

MCCS_ENABLED = @MCCS_ENABLED@

OCAMLLIB = @OCAMLLIB@

OCAMLFIND = @OCAMLFIND@
OCAML = @OCAML@
OCAMLC = @OCAMLC@
Expand All @@ -28,4 +30,4 @@ LIB_PREFIX = @LIB_PREFIX@
CPATH = @CPATH@
LIBRARY_PATH = @LIBRARY_PATH@

export OCAMLVERSION OCAMLFIND OCAML OCAMLC OCAMLOPT EXE PATH INCLUDE LIB CPATH LIBRARY_PATH
export OCAMLVERSION OCAMLFIND OCAML OCAMLC OCAMLOPT EXE PATH INCLUDE LIB CPATH LIBRARY_PATH OCAMLLIB
19 changes: 16 additions & 3 deletions configure
Expand Up @@ -1817,6 +1817,18 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# If a bootstrap compiler has been built, always use it
PATH_PREPEND=
PRE_BOOTSTRAP_PATH="$PATH"
if test -x bootstrap/ocaml/bin/ocamlc -o -x bootstrap/ocaml/bin/ocamlopt ; then :
echo Bootstrap compiler found -- activating
unset OCAMLLIB
export PATH_PREPEND=`pwd`/bootstrap/ocaml/bin:
export PATH="$PATH_PREPEND:$PATH"
fi
# checking for ocamlc
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ocamlc", so it can be a program name with args.
Expand Down Expand Up @@ -1917,7 +1929,7 @@ fi
$as_echo "OCaml version is $OCAMLVERSION" >&6; }
# If OCAMLLIB is set, use it
if test "$OCAMLLIB" = ""; then
OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
OCAMLLIB=`$OCAMLC -where 2>/dev/null | tr -d '\015' || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OCAMLLIB previously set; preserving it." >&5
$as_echo "OCAMLLIB previously set; preserving it." >&6; }
Expand Down Expand Up @@ -3213,7 +3225,7 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an installed Microsoft C Compiler for ${SDK_ARCH}" >&5
$as_echo_n "checking for an installed Microsoft C Compiler for ${SDK_ARCH}... " >&6; }
eval `./shell/msvs-detect --arch=$SDK_ARCH; echo RESULT=$?`
eval `PATH="$PRE_BOOTSTRAP_PATH" ./shell/msvs-detect --arch=$SDK_ARCH; echo RESULT=$?`
if test "x$MSVS_NAME" = "x" ; then :
if test ${RESULT} -eq 0 ; then :
Expand All @@ -3232,7 +3244,8 @@ else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: from $MSVS_NAME" >&5
$as_echo "from $MSVS_NAME" >&6; }
export PATH_PREPEND="${MSVS_PATH}:${PATH_PREPEND}"
export PATH="${PATH_PREPEND}$PATH"
# Note that we put ${MSVS_PATH} here NOT ${PATH_PREPEND} so that the bootstrap path isn't repeated
export PATH="${MSVS_PATH}:$PATH"
LIB_PREPEND="${MSVS_LIB};"
INC_PREPEND="${MSVS_INC};"
export Lib="${MSVS_LIB};$LIB"
Expand Down
15 changes: 13 additions & 2 deletions configure.ac
Expand Up @@ -3,6 +3,16 @@ AC_COPYRIGHT(Copyright 2012-2017 OcamlPro SAS)

AC_CONFIG_MACRO_DIR([m4])

# If a bootstrap compiler has been built, always use it
PATH_PREPEND=
PRE_BOOTSTRAP_PATH="$PATH"
AS_IF([ test -x bootstrap/ocaml/bin/ocamlc -o -x bootstrap/ocaml/bin/ocamlopt ],[
echo Bootstrap compiler found -- activating
unset OCAMLLIB
export PATH_PREPEND=`pwd`/bootstrap/ocaml/bin:
export PATH="$PATH_PREPEND:$PATH"
])

AC_PROG_OCAML
if test "x$OCAMLC" = "xno"; then
AC_MSG_ERROR([You must install the OCaml compiler])
Expand Down Expand Up @@ -69,7 +79,7 @@ AS_IF([test ! -x ${OCAML_TEST_CC}],[
AS_IF([test "x${CCOMP_TYPE}" = "xmsvc"],[
AS_IF([test "${ARCH}" = "i386"],[SDK_ARCH=x86],[SDK_ARCH=x64])
AC_MSG_CHECKING([for an installed Microsoft C Compiler for ${SDK_ARCH}])
eval `./shell/msvs-detect --arch=$SDK_ARCH; echo RESULT=$?`
eval `PATH="$PRE_BOOTSTRAP_PATH" ./shell/msvs-detect --arch=$SDK_ARCH; echo RESULT=$?`
AS_IF([ test "x$MSVS_NAME" = "x" ], [
AS_IF([ test ${RESULT} -eq 0 ], [
AC_MSG_RESULT([from PATH])
Expand All @@ -79,7 +89,8 @@ AS_IF([test ! -x ${OCAML_TEST_CC}],[
],[
AC_MSG_RESULT([from $MSVS_NAME])
export PATH_PREPEND="${MSVS_PATH}:${PATH_PREPEND}"
export PATH="${PATH_PREPEND}$PATH"
# Note that we put ${MSVS_PATH} here NOT ${PATH_PREPEND} so that the bootstrap path isn't repeated
export PATH="${MSVS_PATH}:$PATH"
LIB_PREPEND="${MSVS_LIB};"
INC_PREPEND="${MSVS_INC};"
export Lib="${MSVS_LIB};$LIB"
Expand Down
2 changes: 1 addition & 1 deletion m4/ocaml.m4
Expand Up @@ -18,7 +18,7 @@ AC_DEFUN([AC_PROG_OCAML],
AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
# If OCAMLLIB is set, use it
if test "$OCAMLLIB" = ""; then
OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
OCAMLLIB=`$OCAMLC -where 2>/dev/null | tr -d '\015' || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
else
AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
fi
Expand Down

0 comments on commit bb87113

Please sign in to comment.