X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=Makefile.tpl;h=84fee3dd0f796cdd89ca876bb7f3e0f13aa722ac;hb=6bdf164fc57e0191d40d903ab549666a12fc77a8;hp=9d2797b65011750615a17d8d3f8b2b9ce26e6a29;hpb=e054112458e12cb562cf84cabcb1970ca5ef1ff1;p=binutils-gdb.git diff --git a/Makefile.tpl b/Makefile.tpl index 9d2797b6501..84fee3dd0f7 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -390,7 +390,7 @@ MAKEINFOFLAGS = --split-size=5000000 # --------------------------------------------- AS = @AS@ -AR = @AR@ +AR = @AR@ @AR_PLUGIN_OPTION@ AR_FLAGS = rc CC = @CC@ CXX = @CXX@ @@ -399,7 +399,7 @@ LD = @LD@ LIPO = @LIPO@ NM = @NM@ OBJDUMP = @OBJDUMP@ -RANLIB = @RANLIB@ +RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@ READELF = @READELF@ STRIP = @STRIP@ WINDRES = @WINDRES@ @@ -415,6 +415,49 @@ CXXFLAGS = @CXXFLAGS@ LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates GOCFLAGS = $(CFLAGS) +# Pass additional PGO and LTO compiler options to the PGO build. +BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS) +override CFLAGS += $(BUILD_CFLAGS) +override CXXFLAGS += $(BUILD_CFLAGS) + +# Additional PGO and LTO compiler options to generate profiling data +# for the PGO build. +PGO_BUILD_GEN_FLAGS_TO_PASS = \ + PGO_BUILD_CFLAGS="@PGO_BUILD_GEN_CFLAGS@" \ + PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@" + +# NB: Filter out any compiler options which may fail PGO training runs. +PGO_BUILD_TRAINING_CFLAGS:= \ + $(filter-out -Werror=%,$(CFLAGS)) +PGO_BUILD_TRAINING_CXXFLAGS:=\ + $(filter-out -Werror=%,$(CXXFLAGS)) +PGO_BUILD_TRAINING_CFLAGS:= \ + $(filter-out -Wall,$(PGO_BUILD_TRAINING_CFLAGS)) +PGO_BUILD_TRAINING_CXXFLAGS:= \ + $(filter-out -Wall,$(PGO_BUILD_TRAINING_CXXFLAGS)) +PGO_BUILD_TRAINING_CFLAGS:= \ + $(filter-out -specs=%,$(PGO_BUILD_TRAINING_CFLAGS)) +PGO_BUILD_TRAINING_CXXFLAGS:= \ + $(filter-out -specs=%,$(PGO_BUILD_TRAINING_CXXFLAGS)) +PGO_BUILD_TRAINING_FLAGS_TO_PASS = \ + PGO_BUILD_TRAINING=yes \ + CFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CFLAGS)" \ + CXXFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CXXFLAGS)" + +# Ignore "make check" errors in PGO training runs. +PGO_BUILD_TRAINING_MFLAGS = -i + +# Additional PGO and LTO compiler options to use profiling data for the +# PGO build. +PGO_BUILD_USE_FLAGS_TO_PASS = \ + PGO_BUILD_CFLAGS="@PGO_BUILD_USE_CFLAGS@" \ + PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@" + +# PGO training targets for the PGO build. FIXME: Add gold tests to +# training. +PGO-TRAINING-TARGETS = binutils gas gdb ld sim +PGO_BUILD_TRAINING = $(addprefix maybe-check-,$(PGO-TRAINING-TARGETS)) + CREATE_GCOV = create_gcov TFLAGS = @@ -719,6 +762,12 @@ configure-target: [+ # The target built for a native non-bootstrap build. .PHONY: all + +# --enable-pgo-build enables the PGO build. +# 1. First build with -fprofile-generate. +# 2. Use "make maybe-check-*" to generate profiling data. +# 3. Use "make clean" to remove the previous build. +# 4. Rebuild with -fprofile-use. all: @if gcc-bootstrap [ -f stage_final ] || echo stage3 > stage_final @@ -727,7 +776,7 @@ all: $(MAKE) $(RECURSE_FLAGS_TO_PASS) `cat stage_final`-bubble @endif gcc-bootstrap @: $(MAKE); $(unstage) - @r=`${PWD_COMMAND}`; export r; \ + +@r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ @if gcc-bootstrap if [ -f stage_last ]; then \ @@ -735,7 +784,17 @@ all: $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \ else \ @endif gcc-bootstrap - $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target \ + $(MAKE) $(RECURSE_FLAGS_TO_PASS) \ + $(PGO_BUILD_GEN_FLAGS_TO_PASS) all-host all-target \ +@if pgo-build + && $(MAKE) $(RECURSE_FLAGS_TO_PASS) \ + $(PGO_BUILD_TRAINING_MFLAGS) \ + $(PGO_BUILD_TRAINING_FLAGS_TO_PASS) \ + $(PGO_BUILD_TRAINING) \ + && $(MAKE) $(RECURSE_FLAGS_TO_PASS) clean \ + && $(MAKE) $(RECURSE_FLAGS_TO_PASS) \ + $(PGO_BUILD_USE_FLAGS_TO_PASS) all-host all-target \ +@endif pgo-build @if gcc-bootstrap ; \ fi \ @@ -1818,25 +1877,46 @@ configure-target-[+module+]: maybe-all-gcc[+ (define dep-maybe (lambda () (if (exist? "hard") "" "maybe-"))) - ;; dep-kind returns "normal" if the dependency is on an "install" target, - ;; or if either module is not bootstrapped. It returns "bootstrap" for - ;; configure or build dependencies between bootstrapped modules; it returns - ;; "prebootstrap" for configure or build dependencies of bootstrapped - ;; modules on a build module (e.g. all-gcc on all-build-bison). All this - ;; is only necessary for host modules. + ;; dep-kind returns returns "prebootstrap" for configure or build + ;; dependencies of bootstrapped modules on a build module + ;; (e.g. all-gcc on all-build-bison); "normal" if the dependency is + ;; on an "install" target, or if the dependence module is not + ;; bootstrapped; otherwise, it returns "bootstrap" or + ;; "postbootstrap" depending on whether the dependent module is + ;; bootstrapped. All this is only necessary for host and target + ;; modules. It might seem like, in order to avoid build races, we + ;; might need more elaborate detection between prebootstrap and + ;; postbootstrap modules, but there are no host prebootstrap + ;; modules. If there were any non-bootstrap host modules that + ;; bootstrap modules depended on, we'd get unsatisfied per-stage + ;; dependencies on them, which would be immediately noticed. (define dep-kind (lambda () - (if (and (hash-ref boot-modules (dep-module "module")) - (=* (dep-module "on") "build-")) - "prebootstrap" + (cond + ((and (hash-ref boot-modules (dep-module "module")) + (=* (dep-module "on") "build-")) + "prebootstrap") + + ((or (= (dep-subtarget "on") "install-") + (not (hash-ref boot-modules (dep-module "on")))) + "normal") + + ((hash-ref boot-modules (dep-module "module")) + "bootstrap") - (if (or (= (dep-subtarget "on") "install-") - (not (hash-ref boot-modules (dep-module "module"))) - (not (hash-ref boot-modules (dep-module "on")))) - "normal" - "bootstrap")))) + (1 "postbootstrap")))) + + (define make-postboot-dep (lambda () + (let ((target (dep-module "module")) (dep "stage_last")) + (unless (= (hash-ref postboot-targets target) dep) + (hash-create-handle! postboot-targets target dep) + ;; All non-bootstrap modules' configure target already + ;; depend on dep. + (unless (=* target "target-") + (string-append "configure-" target ": " dep "\n")))))) ;; We now build the hash table that is used by dep-kind. (define boot-modules (make-hash-table 113)) + (define postboot-targets (make-hash-table 113)) +] [+ FOR host_modules +][+ @@ -1853,18 +1933,23 @@ configure-target-[+module+]: maybe-all-gcc[+ # to check for bootstrap/prebootstrap dependencies. To resolve # prebootstrap dependencies, prebootstrap modules are gathered in # a hash table. -[+ FOR dependencies +][+ (make-dep "" "") +] -[+ CASE (dep-kind) +] -[+ == "prebootstrap" - +][+ FOR bootstrap_stage +] -[+ (make-dep (dep-stage) "") +][+ - ENDFOR bootstrap_stage +] -[+ == "bootstrap" - +][+ FOR bootstrap_stage +] -[+ (make-dep (dep-stage) (dep-stage)) +][+ - ENDFOR bootstrap_stage +] -[+ ESAC +][+ -ENDFOR dependencies +] +[+ FOR dependencies +][+ CASE (dep-kind) +] +[+ == "prebootstrap" +][+ (make-dep "" "") +][+ FOR bootstrap_stage +] +[+ (make-dep (dep-stage) "") +][+ ENDFOR bootstrap_stage +] +[+ == "bootstrap" +][+ (make-dep "" "") +][+ FOR bootstrap_stage +] +[+ (make-dep (dep-stage) (dep-stage)) +][+ ENDFOR bootstrap_stage +] +[+ == "normal" +][+ (make-dep "" "") +] +[+ ESAC +][+ ENDFOR dependencies +] + +@if gcc-bootstrap +[+ FOR dependencies +][+ CASE (dep-kind) +] +[+ == "postbootstrap" +][+ (make-postboot-dep) +][+ ESAC +][+ +ENDFOR dependencies +]@endif gcc-bootstrap + +@unless gcc-bootstrap +[+ FOR dependencies +][+ CASE (dep-kind) +] +[+ == "postbootstrap" +][+ (make-dep "" "") +] +[+ ESAC +][+ ENDFOR dependencies +]@endunless gcc-bootstrap # Dependencies for target modules on other target modules are # described by lang_env_dependencies; the defaults apply to anything @@ -1941,6 +2026,7 @@ AUTOCONF = autoconf $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/config/acx.m4 \ $(srcdir)/config/override.m4 $(srcdir)/config/proginstall.m4 \ $(srcdir)/config/elf.m4 $(srcdir)/config/isl.m4 \ + $(srcdir)/config/gcc-plugin.m4 \ $(srcdir)/libtool.m4 $(srcdir)/ltoptions.m4 $(srcdir)/ltsugar.m4 \ $(srcdir)/ltversion.m4 $(srcdir)/lt~obsolete.m4 cd $(srcdir) && $(AUTOCONF)