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

Commit

Permalink
8076060: Improve make bootstrap process
Browse files Browse the repository at this point in the history
Reviewed-by: erikj
  • Loading branch information
ihse committed Mar 26, 2015
1 parent beb9785 commit 906c677
Show file tree
Hide file tree
Showing 15 changed files with 970 additions and 746 deletions.
214 changes: 28 additions & 186 deletions Makefile
@@ -1,5 +1,5 @@
#
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,200 +23,42 @@
# questions.
#

# This must be the first rule
default:
###
### This file is just a very small wrapper needed to run the real make/Init.gmk.
### It also performs some sanity checks on make.
###

# Inclusion of this pseudo-target will cause make to execute this file
# serially, regardless of -j. Recursively called makefiles will not be
# affected, however. This is required for correct dependency management.
.NOTPARALLEL:

# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU Make.
# /usr/ccs/bin/make lacks basically every other flow control mechanism.
.TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU make/gmake, this is a requirement. Check your path. 1>&2 && exit 1

# Assume we have GNU make, but check version.
ifeq ($(strip $(foreach v, 3.81% 3.82% 4.%, $(filter $v, $(MAKE_VERSION)))), )
$(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
endif
.TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU Make/gmake, this is a requirement. Check your path. 1>&2 && exit 1

# Locate this Makefile
ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
else
makefile_path:=$(lastword $(MAKEFILE_LIST))
# The .FEATURES variable is likely to be unique for GNU Make.
ifeq ($(.FEATURES), )
$(info Error: '$(MAKE)' does not seem to be GNU Make, which is a requirement.)
$(info Check your path, or upgrade to GNU Make 3.81 or newer.)
$(error Cannot continue)
endif
root_dir:=$(patsubst %/,%,$(dir $(makefile_path)))

ifeq ($(MAIN_TARGETS), )
COMMAND_LINE_VARIABLES:=$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var))))))
MAKE_CONTROL_VARIABLES:=LOG CONF SPEC JOBS TEST IGNORE_OLD_CONFIG
UNKNOWN_COMMAND_LINE_VARIABLES:=$(strip $(filter-out $(MAKE_CONTROL_VARIABLES), $(COMMAND_LINE_VARIABLES)))
ifneq ($(UNKNOWN_COMMAND_LINE_VARIABLES), )
$(info Note: Command line contains non-control variables: $(UNKNOWN_COMMAND_LINE_VARIABLES).)
$(info Make sure it is not mistyped, and that you intend to override this variable.)
$(info 'make help' will list known control variables)
endif
# Assume we have GNU Make, but check version.
ifeq ($(strip $(foreach v, 3.81% 3.82% 4.%, $(filter $v, $(MAKE_VERSION)))), )
$(info Error: This version of GNU Make is too low ($(MAKE_VERSION)).)
$(info Check your path, or upgrade to GNU Make 3.81 or newer.)
$(error Cannot continue)
endif

ifneq ($(findstring qp,$(MAKEFLAGS)),)
# When called with -qp, assume an external part (e.g. bash completion) is trying
# to understand our targets.
# Duplication of global targets, needed before ParseConfAndSpec in case we have
# no configurations.
help:
# If both CONF and SPEC are unset, look for all available configurations by
# setting CONF to the empty string.
ifeq ($(SPEC), )
CONF?=
endif
# In Cygwin, the MAKE variable gets prepended with the current directory if the
# make executable is called using a Windows mixed path (c:/cygwin/bin/make.exe).
ifneq ($(findstring :, $(MAKE)), )
MAKE := $(patsubst $(CURDIR)%, %, $(patsubst $(CURDIR)/%, %, $(MAKE)))
endif

# ... and then we can include our helper functions
include $(root_dir)/make/MakeHelpers.gmk

$(eval $(call ParseLogLevel))
$(eval $(call ParseConfAndSpec))

# Now determine if we have zero, one or several configurations to build.
ifeq ($(SPEC),)
# Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
# Locate this Makefile
ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))),)
makefile_path := $(CURDIR)/$(strip $(lastword $(MAKEFILE_LIST)))
else
# In Cygwin, the MAKE variable gets messed up if the make executable is called with
# a Windows mixed path (c:/cygwin/bin/make.exe). If that's the case, fix it by removing
# the prepended root_dir.
ifneq ($(findstring :, $(MAKE)), )
MAKE := $(patsubst $(root_dir)%, %, $(MAKE))
endif

# We are potentially building multiple configurations.
# First, find out the valid targets
# Run the makefile with an arbitrary SPEC using -p -q (quiet dry-run and dump rules) to find
# available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
all_phony_targets := $(sort $(filter-out $(global_targets), $(strip $(shell \
cd $(root_dir)/make && $(MAKE) -f Main.gmk -p -q FRC SPEC=$(firstword $(SPEC)) \
-I $(root_dir)/make/common | grep "^.PHONY:" | head -n 1 | cut -d " " -f 2-))))

# Loop through the configurations and call the main-wrapper for each one. The wrapper
# target will execute with a single configuration loaded.
$(all_phony_targets):
@$(if $(TARGET_RUN),,\
$(foreach spec,$(SPEC),\
(cd $(root_dir) && $(MAKE) SPEC=$(spec) MAIN_TARGETS="$(call GetRealTarget)" \
$(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) main-wrapper) &&) true)
@echo > /dev/null
$(eval TARGET_RUN=true)

.PHONY: $(all_phony_targets)

ifneq ($(MAIN_TARGETS), )
# The wrapper target was called so we now have a single configuration. Load the spec file
# and call the real Main.gmk.
include $(SPEC)
include $(SRC_ROOT)/make/common/MakeBase.gmk

### Clean up from previous run
# Remove any build.log from a previous run, if they exist
ifneq (,$(BUILD_LOG))
ifneq (,$(BUILD_LOG_PREVIOUS))
# Rotate old log
$(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
$(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
else
$(shell $(RM) $(BUILD_LOG) 2> /dev/null)
endif
$(shell $(RM) $(OUTPUT_ROOT)/build-trace-time.log 2> /dev/null)
endif
# Remove any javac server logs and port files. This
# prevents a new make run to reuse the previous servers.
ifneq (,$(SJAVAC_SERVER_DIR))
$(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
endif

# Split out the targets requiring sequential execution. Run these targets separately
# from the rest so that the rest may still enjoy full parallel execution.
SEQUENTIAL_TARGETS := $(filter dist-clean clean% reconfigure, $(MAIN_TARGETS))
PARALLEL_TARGETS := $(filter-out $(SEQUENTIAL_TARGETS), $(MAIN_TARGETS))

main-wrapper:
ifneq ($(SEQUENTIAL_TARGETS), )
(cd $(SRC_ROOT)/make && $(MAKE) -f Main.gmk SPEC=$(SPEC) -j 1 \
$(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(SEQUENTIAL_TARGETS))
endif
ifneq ($(PARALLEL_TARGETS), )
@$(call AtMakeStart)
(cd $(SRC_ROOT)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -f Main.gmk SPEC=$(SPEC) -j $(JOBS) \
$(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(PARALLEL_TARGETS) \
$(if $(filter true, $(OUTPUT_SYNC_SUPPORTED)), -O$(OUTPUT_SYNC)))
@$(call AtMakeEnd)
endif

.PHONY: main-wrapper

endif
makefile_path := $(lastword $(MAKEFILE_LIST))
endif
topdir := $(strip $(patsubst %/, %, $(dir $(makefile_path))))

# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
# If you add more global targets, please update the variable global_targets in MakeHelpers.

# Helper macro to allow $(info) to properly print strings beginning with spaces.
_:=

help:
$(info )
$(info OpenJDK Makefile help)
$(info =====================)
$(info )
$(info Common make targets)
$(info $(_) make [default] # Compile all modules in langtools, hotspot, jdk, jaxws,)
$(info $(_) # jaxp and corba, and create a runnable "exploded" image)
$(info $(_) make all # Compile everything, all repos, docs and images)
$(info $(_) make images # Create complete j2sdk and j2re images)
$(info $(_) make <phase> # Build the specified phase and everything it depends on)
$(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic))
$(info $(_) make *-only # Applies to most targets and disables compling the)
$(info $(_) # dependencies for the target. This is faster but may)
$(info $(_) # result in incorrect build results!)
$(info $(_) make docs # Create all docs)
$(info $(_) make docs-javadoc # Create just javadocs, depends on less than full docs)
$(info $(_) make profiles # Create complete j2re compact profile images)
$(info $(_) make bootcycle-images # Build images twice, second time with newly built JDK)
$(info $(_) make install # Install the generated images locally)
$(info $(_) make reconfigure # Rerun configure with the same arguments as last time)
$(info $(_) make help # Give some help on using make)
$(info $(_) make test # Run tests, default is all tests (see TEST below))
$(info )
$(info Targets for cleaning)
$(info $(_) make clean # Remove all files generated by make, but not those)
$(info $(_) # generated by configure)
$(info $(_) make dist-clean # Remove all files, including configuration)
$(info $(_) make clean-<outputdir> # Remove the subdir in the output dir with the name)
$(info $(_) make clean-<phase> # Remove all build results related to a certain build)
$(info $(_) # phase (gensrc, java, libs, launchers))
$(info $(_) make clean-<module> # Remove all build results related to a certain module)
$(info $(_) make clean-<module>-<phase> # Remove all build results related to a certain)
$(info $(_) # module and phase)
$(info )
$(info Targets for specific modules)
$(info $(_) make <module> # Build <module> and everything it depends on.)
$(info $(_) make <module>-<phase> # Compile the specified phase for the specified module)
$(info $(_) # and everything it depends on)
$(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic))
$(info )
$(info Make control variables)
$(info $(_) CONF= # Build all configurations (note, assignment is empty))
$(info $(_) CONF=<substring> # Build the configuration(s) with a name matching)
$(info $(_) # <substring>)
$(info $(_) SPEC=<spec file> # Build the configuration given by the spec file)
$(info $(_) LOG=<loglevel> # Change the log level from warn to <loglevel>)
$(info $(_) # Available log levels are:)
$(info $(_) # 'warn' (default), 'info', 'debug' and 'trace')
$(info $(_) # To see executed command lines, use LOG=debug)
$(info $(_) JOBS=<n> # Run <n> parallel make jobs)
$(info $(_) # Note that -jN does not work as expected!)
$(info $(_) IGNORE_OLD_CONFIG=true # Skip tests if spec file is up to date)
$(info $(_) make test TEST=<test> # Only run the given test or tests, e.g.)
$(info $(_) # make test TEST="jdk_lang jdk_net")
$(info )

.PHONY: help
# ... and then we can include the real makefile
include $(topdir)/make/Init.gmk
16 changes: 2 additions & 14 deletions common/autoconf/basics.m4
Expand Up @@ -78,7 +78,7 @@ AC_DEFUN([BASIC_PREPEND_TO_PATH],
AC_DEFUN([BASIC_FIXUP_PATH],
[
# Only process if variable expands to non-empty
if test "x[$]$1" != x; then
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
BASIC_FIXUP_PATH_CYGWIN($1)
Expand Down Expand Up @@ -118,7 +118,7 @@ AC_DEFUN([BASIC_FIXUP_PATH],
AC_DEFUN([BASIC_FIXUP_EXECUTABLE],
[
# Only process if variable expands to non-empty
if test "x[$]$1" != x; then
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
Expand Down Expand Up @@ -709,18 +709,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
])

AC_DEFUN_ONCE([BASIC_SETUP_LOGGING],
[
# Setup default logging of stdout and stderr to build.log in the output root.
BUILD_LOG='$(OUTPUT_ROOT)/build.log'
BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
AC_SUBST(BUILD_LOG)
AC_SUBST(BUILD_LOG_PREVIOUS)
AC_SUBST(BUILD_LOG_WRAPPER)
])


#%%% Simple tools %%%

# Check if we have found a usable version of make
Expand Down
3 changes: 1 addition & 2 deletions common/autoconf/configure.ac
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -88,7 +88,6 @@ PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET

# Continue setting up basic stuff. Most remaining code require fundamental tools.
BASIC_SETUP_PATHS
BASIC_SETUP_LOGGING

# Check if it's a pure open build or if custom sources are to be used.
JDKOPT_SETUP_OPEN_OR_CUSTOM
Expand Down
17 changes: 1 addition & 16 deletions common/autoconf/generated-configure.sh
Expand Up @@ -907,9 +907,6 @@ JVM_VARIANTS
JVM_INTERPRETER
JDK_VARIANT
SET_OPENJDK
BUILD_LOG_WRAPPER
BUILD_LOG_PREVIOUS
BUILD_LOG
TOPDIR
PATH_SEP
ZERO_ARCHDEF
Expand Down Expand Up @@ -3471,9 +3468,6 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.






#%%% Simple tools %%%

# Check if we have found a usable version of make
Expand Down Expand Up @@ -4369,7 +4363,7 @@ VS_SDK_PLATFORM_NAME_2013=
#CUSTOM_AUTOCONF_INCLUDE

# Do not change or remove the following line, it is needed for consistency checks:
DATE_WHEN_GENERATED=1426774983
DATE_WHEN_GENERATED=1427382753

###############################################################################
#
Expand Down Expand Up @@ -14401,15 +14395,6 @@ $as_echo "$as_me: The path of TOPDIR, which resolves as \"$path\", is invalid."
AUTOCONF_DIR=$TOPDIR/common/autoconf


# Setup default logging of stdout and stderr to build.log in the output root.
BUILD_LOG='$(OUTPUT_ROOT)/build.log'
BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'





# Check if it's a pure open build or if custom sources are to be used.

# Check whether --enable-openjdk-only was given.
Expand Down
35 changes: 5 additions & 30 deletions common/autoconf/spec.gmk.in
Expand Up @@ -55,25 +55,12 @@ CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
# A self-referential reference to this file.
SPEC:=@SPEC@

# Specify where the spec file is.
MAKE_ARGS="SPEC=$(SPEC)"
# What make to use for main processing, after bootstrapping top-level Makefile.
MAKE := @MAKE@

MAKE:=@MAKE@

# Pass along the verbosity and log level settings.
ifeq (,$(findstring VERBOSE=,$(MAKE)))
MAKE:=$(MAKE) $(VERBOSE) VERBOSE="$(VERBOSE)" LOG_LEVEL="$(LOG_LEVEL)"
endif

# No implicit variables or rules!
ifeq (,$(findstring -R,$(MAKE)))
MAKE:=$(MAKE) -R
endif

# Specify where the common include directory for makefiles is.
ifeq (,$(findstring -I @TOPDIR@/make/common,$(MAKE)))
MAKE:=$(MAKE) -I @TOPDIR@/make/common
endif
# The default make arguments
MAKE_ARGS = $(MAKE_LOG_FLAGS) -R -I $(TOPDIR)/make/common SPEC=$(SPEC) \
MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" LOG_LEVEL=$(LOG_LEVEL)

OUTPUT_SYNC_SUPPORTED:=@OUTPUT_SYNC_SUPPORTED@
OUTPUT_SYNC:=@OUTPUT_SYNC@
Expand Down Expand Up @@ -573,18 +560,6 @@ JTREGEXE:=@JTREGEXE@
XCODEBUILD=@XCODEBUILD@
FIXPATH:=@FIXPATH@

# Where the build output is stored for your convenience.
BUILD_LOG:=@BUILD_LOG@
BUILD_LOG_PREVIOUS:=@BUILD_LOG_PREVIOUS@
# Disable the build log wrapper on sjavac+windows until
# we have solved how to prevent the log wrapper to wait
# for the background sjavac server process.
ifeq (@ENABLE_SJAVAC@X@OPENJDK_BUILD_OS@,yesXwindows)
BUILD_LOG_WRAPPER:=
else
BUILD_LOG_WRAPPER:=@BUILD_LOG_WRAPPER@
endif

# Build setup
ENABLE_JFR=@ENABLE_JFR@
ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
Expand Down
3 changes: 2 additions & 1 deletion configure
Expand Up @@ -31,4 +31,5 @@ this_script_dir=`cd $this_script_dir > /dev/null && pwd`

# Delegate to wrapper, forcing wrapper to believe $0 is this script by using -c.
# This trick is needed to get autoconf to co-operate properly.
bash -c ". $this_script_dir/common/autoconf/configure" $this_script_dir/configure CHECKME $this_script_dir "$@"
# The ${-:+-$-} construction passes on bash options.
bash ${-:+-$-} -c ". $this_script_dir/common/autoconf/configure" $this_script_dir/configure CHECKME $this_script_dir "$@"

0 comments on commit 906c677

Please sign in to comment.