Allow compilation using bootstrapped FlexDLL

Extend the previous patch allowing make -f Makefile.nt flexdll
install-flexdll not to require the install-flexdll stage.

OCAML_FLEXLINK is utilised as required to allow compilation of the entire
system using an in-tree compiled flexlink. The build process simply
required the flexdll target to appear before world.

opt.opt compiles a native code version of flexlink.exe as flexlink.opt.

install always installs flexlink.exe if it was compiled along with any
required .manifest files. It also installs the appropriate .o/.obj files
to $(INSTALL_LIBDIR).

At present, the bootstrapping is not extended to the Cygwin ports.
master
David Allsopp 2016-01-02 14:49:08 +00:00
parent fe4b643c4e
commit b46843fb69
13 changed files with 55 additions and 46 deletions

View File

@ -522,6 +522,10 @@ Features wishes:
- GPR#383: configure: define _ALL_SOURCE for build on AIX7.1
(tkob)
Build system:
- GPR#388: FlexDLL added as a Git submodule and bootstrappable with the compiler
(David Allsopp)
OCaml 4.02.3 (27 Jul 2015):
---------------------------

View File

@ -18,6 +18,10 @@ include Makefile.shared
defaultentry:
@echo "Please refer to the installation instructions in file README.win32.adoc."
FLEXDLL_SUBMODULE_PRESENT:=$(wildcard flexdll/Makefile)
BOOT_FLEXLINK_CMD=$(if $(FLEXDLL_SUBMODULE_PRESENT),FLEXLINK_CMD="../boot/ocamlrun ../flexdll/flexlink.exe")
CAMLOPT:=$(if $(FLEXDLL_SUBMODULE_PRESENT),OCAML_FLEXLINK="boot/ocamlrun flexdll/flexlink.exe") $(CAMLOPT)
# FlexDLL sources missing error messages
# Different git mechanism displayed depending on whether this source tree came
# from a git clone or a source tarball.
@ -39,38 +43,22 @@ flexdll-repo: flexdll-common-err
@echo
@false
# Bootstrapping FlexDLL - leaves a bytecode image of flexlink in flexdll/
# Bootstrapping FlexDLL - leaves a bytecode image of flexlink.exe in flexdll/
flexdll: flexdll/Makefile
cd byterun ; $(MAKEREC) BOOTSTRAPPING_FLEXLINK=yes ocamlrun$(EXE)
cp byterun/ocamlrun.exe boot/ocamlrun.exe
cd stdlib ; $(MAKEREC) COMPILER=../boot/ocamlc stdlib.cma std_exit.cmo
cd stdlib ; cp stdlib.cma std_exit.cmo *.cmi ../boot
cd flexdll ; $(MAKECMD) MSVC_DETECT=0 TOOLCHAIN=$(TOOLCHAIN) TOOLPREF=$(TOOLPREF) CHAINS=$(FLEXDLL_CHAIN) NATDYNLINK=false OCAMLOPT="../boot/ocamlrun ../boot/ocamlc -I ../boot" flexlink.exe support
# The executable header will not have been available - flexlink.exe is just the bytecode image
cd flexdll ; mv flexlink.exe flexlink
cd stdlib ; $(MAKEREC) FLEXLINK_CMD="../boot/ocamlrun ../flexdll/flexlink" camlheader
install-flexdll:
mkdir -p $(INSTALL_BINDIR)
# Assemble flexlink.exe
cat stdlib/camlheader flexdll/flexlink > flexdll/flexlink.exe ; chmod +x flexdll/flexlink.exe ; rm flexdll/flexlink
# The $(if ...) installs the correct .manifest file for MSVC and MSVC64
# (GNU make doesn't have ifeq as a function, hence slightly convoluted use of filter-out)
cp flexdll/flexlink.exe flexdll/flexdll_*.$(O) flexdll/flexdll.h $(if $(filter-out mingw,$(TOOLCHAIN)),flexdll/default$(filter-out _i386,_$(ARCH)).manifest) $(INSTALL_BINDIR)/
# This is the flexlink-free version of ocamlrun, it won't be used during
# compilation and will be overwritten when the finished OCaml is installed
cp boot/ocamlrun.exe $(INSTALL_BINDIR)/
# Tidy-up the OCaml build tree ready for the next stage
cd byterun ; $(MAKEREC) clean
$(MAKEREC) partialclean
# If Makefile.nt was used to bootstrap FlexDLL, then opt.opt will build a native
# flexlink which install will put in $(INSTALL_BINDIR), overwriting the bytecode
# version placed there by install-flexdll
FLEXLINK_OPT=$(if $(or $(filter flexdll,$(MAKECMDGOALS)),$(wildcard flexdll/flexlink.exe)),flexlink_opt)
flexlink_opt:
cd flexdll ; rm flexlink.exe ; $(MAKECMD) MSVC_DETECT=0 TOOLCHAIN=$(TOOLCHAIN) TOOLPREF=$(TOOLPREF) OCAMLOPT="../ocamlopt.opt -I ../stdlib" flexlink.exe
flexlink.opt:
cd flexdll ; \
mv flexlink.exe flexlink ; \
$(MAKECMD) OCAML_FLEXLINK="../boot/ocamlrun ./flexlink" MSVC_DETECT=0 TOOLCHAIN=$(TOOLCHAIN) TOOLPREF=$(TOOLPREF) OCAMLOPT="../ocamlopt.opt -I ../stdlib" flexlink.exe ; \
mv flexlink.exe flexlink.opt ; \
mv flexlink flexlink.exe
# Recompile the system using the bootstrap compiler
all: runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml \
@ -114,11 +102,11 @@ LIBFILES=stdlib.cma std_exit.cmo *.cmi camlheader
# Start up the system from the distribution compiler
coldstart:
cd byterun ; $(MAKEREC) all
cd byterun ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) all
cp byterun/ocamlrun.exe boot/ocamlrun.exe
cd yacc ; $(MAKEREC) all
cd yacc ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) all
cp yacc/ocamlyacc.exe boot/ocamlyacc.exe
cd stdlib ; $(MAKEREC) COMPILER=../boot/ocamlc all
cd stdlib ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) COMPILER=../boot/ocamlc all
cd stdlib ; cp $(LIBFILES) ../boot
# Build the core system: the minimum needed to make depend and bootstrap
@ -180,8 +168,10 @@ opt:
$(MAKEREC) otherlibrariesopt ocamltoolsopt
# Native-code versions of the tools
# If the submodule is initialised, then opt.opt will build a native flexlink
opt.opt: core opt-core ocamlc.opt all ocamlopt.opt ocamllex.opt \
ocamltoolsopt ocamltoolsopt.opt otherlibrariesopt $(OCAMLBUILDNATIVE) $(OCAMLDOC_OPT) $(FLEXLINK_OPT)
ocamltoolsopt ocamltoolsopt.opt otherlibrariesopt $(OCAMLBUILDNATIVE) \
$(OCAMLDOC_OPT) $(if $(wildcard flexdll/Makefile),flexlink.opt)
# Complete build using fast compilers
world.opt: coldstart opt.opt
@ -231,12 +221,20 @@ installbyt:
else :; fi
if test -n "$(WITH_OCAMLBUILD)"; then (cd ocamlbuild; $(MAKE) install); \
else :; fi
if test -n "$(FLEXDLL_SUBMODULE_PRESENT)"; then $(MAKEREC) install-flexdll; \
else :; fi
cp config/Makefile $(INSTALL_LIBDIR)/Makefile.config
cp README.adoc $(INSTALL_DISTRIB)/Readme.general.txt
cp README.win32.adoc $(INSTALL_DISTRIB)/Readme.windows.txt
cp LICENSE $(INSTALL_DISTRIB)/License.txt
cp Changes $(INSTALL_DISTRIB)/Changes.txt
install-flexdll:
# The $(if ...) installs the correct .manifest file for MSVC and MSVC64
# (GNU make doesn't have ifeq as a function, hence slightly convoluted use of filter-out)
cp flexdll/flexlink.exe $(if $(filter-out mingw,$(TOOLCHAIN)),flexdll/default$(filter-out _i386,_$(ARCH)).manifest) $(INSTALL_BINDIR)/
cp flexdll/flexdll_*.$(O) $(INSTALL_LIBDIR)
# Installation of the native-code compiler
installopt:
cd asmrun ; $(MAKEREC) install
@ -252,7 +250,7 @@ installopt:
done
if test -f ocamlopt.opt ; then $(MAKEREC) installoptopt; fi
cd tools; $(MAKEREC) installopt
if test -f ocamlopt.opt -a -f flexdll/flexlink.exe ; then cp flexdll/flexlink.exe $(INSTALL_BINDIR)/ ; fi
if test -f ocamlopt.opt -a -f flexdll/flexlink.opt ; then cp -f flexdll/flexlink.opt $(INSTALL_BINDIR)/flexlink.exe ; fi
installoptopt:
cp ocamlc.opt $(INSTALL_BINDIR)/ocamlc.opt$(EXE)
@ -546,7 +544,7 @@ partialclean::
runtime: makeruntime stdlib/libcamlrun.$(A)
makeruntime:
cd byterun ; $(MAKEREC) all
cd byterun ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) all
stdlib/libcamlrun.$(A): byterun/libcamlrun.$(A)
cp byterun/libcamlrun.$(A) stdlib/libcamlrun.$(A)
clean::
@ -572,11 +570,11 @@ alldepend::
# The library
library:
cd stdlib ; $(MAKEREC) all
cd stdlib ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) all
library-cross:
cd stdlib ; $(MAKEREC) CAMLRUN=../byterun/ocamlrun all
cd stdlib ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) CAMLRUN=../byterun/ocamlrun all
libraryopt:
cd stdlib ; $(MAKEREC) allopt
cd stdlib ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) allopt
partialclean::
cd stdlib ; $(MAKEREC) clean
alldepend::
@ -594,7 +592,7 @@ alldepend::
cd lex ; $(MAKEREC) depend
ocamlyacc:
cd yacc ; $(MAKEREC) all
cd yacc ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) all
clean::
cd yacc ; $(MAKEREC) clean
@ -665,7 +663,7 @@ ocamlbuild.byte: ocamlc otherlibraries
cd ocamlbuild && $(MAKE) all
ocamlbuild.native: ocamlopt otherlibrariesopt
cd ocamlbuild && $(MAKE) allopt
cd ocamlbuild && $(if $(FLEXDLL_SUBMODULE_PRESENT),OCAML_FLEXLINK="../boot/ocamlrun ../flexdll/flexlink.exe") $(MAKE) allopt
partialclean::
cd ocamlbuild && $(MAKE) clean
@ -728,6 +726,6 @@ distclean:
.PHONY: ocamltoolsopt.opt ocamlyacc opt-core opt opt.opt otherlibraries
.PHONY: otherlibrariesopt promote promote-cross
.PHONY: restore runtime runtimeopt makeruntimeopt world world.opt
.PHONY: flexdll flexlink_opt flexdll-common-err flexdll-repo
.PHONY: flexdll flexlink.opt flexdll-common-err flexdll-repo
include .depend

View File

@ -117,7 +117,7 @@ FLEXLINK_FLAGS=-chain $(FLEXDLL_CHAIN) -stack 16777216 -link -static-libgcc
FLEXLINK=$(FLEXLINK_CMD) $(FLEXLINK_FLAGS)
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
IFLEXDIR=-I"../flexdll"
else
IFLEXDIR=-I"$(FLEXDIR)"
endif

View File

@ -117,7 +117,7 @@ FLEXLINK_FLAGS=-chain $(FLEXDLL_CHAIN) -stack 33554432
FLEXLINK=$(FLEXLINK_CMD) $(FLEXLINK_FLAGS)
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
IFLEXDIR=-I"../flexdll"
else
IFLEXDIR=-I"$(FLEXDIR)"
endif

View File

@ -108,7 +108,7 @@ FLEXLINK_FLAGS=-merge-manifest -stack 16777216
FLEXLINK=$(FLEXLINK_CMD) $(FLEXLINK_FLAGS)
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
IFLEXDIR=-I"../flexdll"
else
IFLEXDIR=-I"$(FLEXDIR)"
endif

View File

@ -112,7 +112,7 @@ FLEXLINK_FLAGS=-x64 -merge-manifest -stack 33554432
FLEXLINK=$(FLEXLINK_CMD) $(FLEXLINK_FLAGS)
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=
IFLEXDIR=-I"../flexdll"
else
IFLEXDIR=-I"$(FLEXDIR)"
endif

View File

@ -17,7 +17,7 @@ CAMLRUN ?= ../boot/ocamlrun
CAMLYACC ?= ../boot/ocamlyacc
CAMLC=$(CAMLRUN) ../boot/ocamlc -I ../boot
CAMLOPT=$(CAMLRUN) ../ocamlopt -I ../stdlib
CAMLOPT=$(if $(wildcard ../flexdll/Makefile),OCAML_FLEXLINK="../boot/ocamlrun ../flexdll/flexlink.exe") $(CAMLRUN) ../ocamlopt -I ../stdlib
COMPFLAGS=-warn-error A
LINKFLAGS=
YACCFLAGS=-v

View File

@ -18,7 +18,7 @@ CAMLYACC ?= ../boot/ocamlyacc
##########################
ROOTDIR = ..
OCAMLC = $(CAMLRUN) $(ROOTDIR)/ocamlc -nostdlib -I $(ROOTDIR)/stdlib
OCAMLOPT = $(CAMLRUN) $(ROOTDIR)/ocamlopt -nostdlib -I $(ROOTDIR)/stdlib
OCAMLOPT = $(if $(wildcard $(ROOTDIR)/flexdll/Makefile),OCAML_FLEXLINK="$(ROOTDIR)/boot/ocamlrun $(ROOTDIR)/flexdll/flexlink.exe") $(CAMLRUN) $(ROOTDIR)/ocamlopt -nostdlib -I $(ROOTDIR)/stdlib
OCAMLDEP = $(CAMLRUN) $(ROOTDIR)/tools/ocamldep
OCAMLLEX = $(CAMLRUN) $(ROOTDIR)/boot/ocamllex
OCAMLLIB = $(LIBDIR)

View File

@ -15,6 +15,8 @@
include ../Makefile
export OCAML_FLEXLINK:=$(if $(wildcard $(ROOTDIR)/flexdll/Makefile),$(ROOTDIR)/boot/ocamlrun $(ROOTDIR)/flexdll/flexlink.exe)
# The Unix version now works fine under Windows
# Note .. is the current directory (this makefile is included from

View File

@ -22,6 +22,8 @@ COMPFLAGS=-w +33 -warn-error A -g
MKLIB=$(CAMLRUN) ../../tools/ocamlmklib
CFLAGS=-I../../byterun $(EXTRACFLAGS)
export OCAML_FLEXLINK:=$(if $(wildcard ../../flexdll/Makefile),../../boot/ocamlrun ../../flexdll/flexlink.exe)
CAMLOBJS=thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo
CMIFILES=$(CAMLOBJS:.cmo=.cmi)
COBJS=st_stubs_b.$(O)

View File

@ -56,11 +56,12 @@ endif
OCAML=$(OCAMLRUN) $(OTOPDIR)/ocaml $(OCFLAGS) \
-init $(OTOPDIR)/testsuite/lib/empty
OCAMLC=$(OCAMLRUN) $(OTOPDIR)/ocamlc $(CUSTOM) $(OCFLAGS)
OCAMLOPT=$(OCAMLRUN) $(OTOPDIR)/ocamlopt $(OCFLAGS)
FLEXLINK_PREFIX=$(if $(FLEXLINK),$(if $(wildcard $(TOPDIR)/flexdll/Makefile),OCAML_FLEXLINK="$(WINTOPDIR)/boot/ocamlrun $(WINTOPDIR)/flexdll/flexlink.exe" ))
OCAMLC=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/ocamlc $(CUSTOM) $(OCFLAGS)
OCAMLOPT=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/ocamlopt $(OCFLAGS)
OCAMLDOC=$(OCAMLRUN) $(OTOPDIR)/ocamldoc/ocamldoc
OCAMLLEX=$(OCAMLRUN) $(OTOPDIR)/lex/ocamllex
OCAMLMKLIB=$(OCAMLRUN) $(OTOPDIR)/tools/ocamlmklib \
OCAMLMKLIB=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/tools/ocamlmklib \
-ocamlc "$(OTOPDIR)/boot/ocamlrun$(EXE) \
$(OTOPDIR)/ocamlc $(OCFLAGS)" \
-ocamlopt "$(OTOPDIR)/boot/ocamlrun$(EXE) \

View File

@ -12,6 +12,8 @@
include Makefile.shared
CAMLOPT:=$(if $(wildcard ../flexdll/Makefile),OCAML_FLEXLINK="../boot/ocamlrun ../flexdll/flexlink.exe") $(CAMLOPT)
# To make custom toplevels
OCAMLMKTOP=ocamlmktop.cmo
@ -20,7 +22,7 @@ OCAMLMKTOP_IMPORTS=misc.cmo identifiable.cmo numbers.cmo config.cmo clflags.cmo
ocamlmktop: $(OCAMLMKTOP)
$(CAMLC) $(LINKFLAGS) -o ocamlmktop $(OCAMLMKTOP_IMPORTS) $(OCAMLMKTOP)
ocamlmklibconfig.ml:: ../config/Makefile
ocamlmklibconfig.ml:: ../config/Makefile Makefile
echo "let mkdll = try \
let flexlink = \
let flexlink = Sys.getenv \"OCAML_FLEXLINK\" in \

View File

@ -109,7 +109,7 @@ install::
clean::
rm -f ocamlmklib
ocamlmklibconfig.ml:: ../config/Makefile
ocamlmklibconfig.ml:: ../config/Makefile Makefile
(echo 'let bindir = "$(BINDIR)"'; \
echo 'let ext_lib = "$(EXT_LIB)"'; \
echo 'let ext_dll = "$(EXT_DLL)"'; \