--- old/make/devkit/Tools.gmk 2018-02-07 23:52:25.715404559 +0100 +++ new/make/devkit/Tools.gmk 2018-02-07 23:52:25.427394525 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2018, 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 @@ -44,24 +44,42 @@ $(info BUILD=$(BUILD)) ARCH := $(word 1,$(subst -, ,$(TARGET))) +$(info ARCH=$(ARCH)) ########################################################################################## # Define external dependencies # Latest that could be made to work. -gcc_ver := gcc-4.9.2 -binutils_ver := binutils-2.25 -ccache_ver := ccache-3.2.1 -mpfr_ver := mpfr-3.0.1 -gmp_ver := gmp-4.3.2 -mpc_ver := mpc-1.0.1 - -GCC := http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.bz2 -BINUTILS := http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.bz2 -CCACHE := http://samba.org/ftp/ccache/$(ccache_ver).tar.gz +GCC_VER := 7.3.0 +ifeq ($(GCC_VER), 7.3.0) + gcc_ver := gcc-7.3.0 + binutils_ver := binutils-2.30 + ccache_ver := ccache-3.3.6 + mpfr_ver := mpfr-3.1.5 + gmp_ver := gmp-6.1.2 + mpc_ver := mpc-1.0.3 + gdb_ver := gdb-8.1 +else ifeq ($(GCC_VER), 4.9.2) + gcc_ver := gcc-4.9.2 + binutils_ver := binutils-2.25 + ccache_ver := ccache-3.2.1 + mpfr_ver := mpfr-3.0.1 + gmp_ver := gmp-4.3.2 + mpc_ver := mpc-1.0.1 + gdb_ver := gdb-7.12.1 +else + $(error Unsupported GCC version) +endif + +GCC := http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.xz +BINUTILS := http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.xz +CCACHE := https://samba.org/ftp/ccache/$(ccache_ver).tar.xz MPFR := http://www.mpfr.org/${mpfr_ver}/${mpfr_ver}.tar.bz2 GMP := http://ftp.gnu.org/pub/gnu/gmp/${gmp_ver}.tar.bz2 -MPC := http://www.multiprecision.org/mpc/download/${mpc_ver}.tar.gz +MPC := http://ftp.gnu.org/pub/gnu/mpc/${mpc_ver}.tar.gz +GDB := http://ftp.gnu.org/gnu/gdb/${gdb_ver}.tar.xz + +OEL_URL := http://yum.oracle.com/repo/OracleLinux/OL6/4/base/$(ARCH)/ # RPMs in OEL6.4 LINUX_VERSION := OEL6.4 @@ -87,29 +105,6 @@ libffi libffi-devel \ fontconfig fontconfig-devel -ifeq ($(ARCH),x86_64) - RPM_DIR ?= $(RPM_DIR_x86_64) - RPM_ARCHS := x86_64 noarch - ifeq ($(BUILD),$(HOST)) - ifeq ($(TARGET),$(HOST)) - # When building the native compiler for x86_64, enable mixed mode. - RPM_ARCHS += i386 i686 - endif - endif -else - RPM_DIR ?= $(RPM_DIR_i686) - RPM_ARCHS := i386 i686 -endif - -# Sort to remove duplicates -RPM_FILE_LIST := $(sort $(foreach a,$(RPM_ARCHS),$(wildcard $(patsubst %,$(RPM_DIR)/%*$a.rpm,$(RPM_LIST))))) - -#$(info RPM_FILE_LIST $(RPM_FILE_LIST)) - -ifeq ($(RPM_FILE_LIST),) - $(error Found no RPMs, RPM_DIR must point to list of directories to search for RPMs) -endif - ########################################################################################## # Define common directories and files @@ -122,13 +117,14 @@ endif # Define directories -RESULT := $(OUTPUTDIR)/result -BUILDDIR := $(OUTPUTDIR)/$(HOST)/$(TARGET) +RESULT := $(OUTPUT_ROOT)/result +BUILDDIR := $(OUTPUT_ROOT)/$(HOST)/$(TARGET) PREFIX := $(RESULT)/$(HOST) TARGETDIR := $(PREFIX)/$(TARGET) SYSROOT := $(TARGETDIR)/sysroot -DOWNLOAD := $(OUTPUTDIR)/download -SRCDIR := $(OUTPUTDIR)/src +DOWNLOAD := $(OUTPUT_ROOT)/download +DOWNLOAD_RPMS := $(DOWNLOAD)/rpms +SRCDIR := $(OUTPUT_ROOT)/src # Marker file for unpacking rpms rpms := $(SYSROOT)/rpms_unpacked @@ -136,6 +132,16 @@ # Need to patch libs that are linker scripts to use non-absolute paths libs := $(SYSROOT)/libs_patched +################################################################################ +# Download RPMs +download-rpms: + mkdir -p $(DOWNLOAD_RPMS) + # Only run this if rpm dir is empty. + ifeq ($(wildcard $(DOWNLOAD_RPMS)/*.rpm), ) + cd $(DOWNLOAD_RPMS) && \ + wget -r -np -nd $(patsubst %, -A "*%*.rpm", $(RPM_LIST)) $(OEL_URL) + endif + ########################################################################################## # Unpack source packages @@ -147,7 +153,7 @@ $$($(1)_CFG) : $$($(1)_FILE) mkdir -p $$(SRCDIR) - tar -C $$(SRCDIR) -x$$(if $$(findstring .gz, $$<),z,j)f $$< + tar -C $$(SRCDIR) -xf $$< $$(foreach p,$$(abspath $$(wildcard $$(notdir $$($(1)_DIR)).patch)), \ echo PATCHING $$(p) ; \ patch -d $$($(1)_DIR) -p1 -i $$(p) ; \ @@ -159,15 +165,32 @@ endef # Download and unpack all source packages -$(foreach p,GCC BINUTILS CCACHE MPFR GMP MPC,$(eval $(call Download,$(p)))) +$(foreach p,GCC BINUTILS CCACHE MPFR GMP MPC GDB,$(eval $(call Download,$(p)))) ########################################################################################## # Unpack RPMS +ifeq ($(ARCH),x86_64) + RPM_ARCHS := x86_64 noarch + ifeq ($(BUILD),$(HOST)) + ifeq ($(TARGET),$(HOST)) + # When building the native compiler for x86_64, enable mixed mode. + RPM_ARCHS += i386 i686 + endif + endif +else ifeq ($(ARCH),i686)) + RPM_ARCHS := i386 i686 +else + RPM_ARCHS := $(ARCH) +endif + +RPM_FILE_LIST := $(sort $(foreach a, $(RPM_ARCHS), \ + $(wildcard $(patsubst %,$(DOWNLOAD_RPMS)/%*$a.rpm,$(RPM_LIST))) \ +)) + # Note. For building linux you should install rpm2cpio. define unrpm - $(SYSROOT)/$(notdir $(1)).unpacked \ - : $(1) + $(SYSROOT)/$(notdir $(1)).unpacked : $(1) $$(rpms) : $(SYSROOT)/$(notdir $(1)).unpacked endef @@ -210,19 +233,20 @@ ########################################################################################## # Create links for ffi header files so that they become visible by default when using the # devkit. +ifeq ($(ARCH), x86_64) + $(SYSROOT)/usr/include/ffi.h: $(rpms) + cd $(@D) && rm -f $(@F) && ln -s ../lib/libffi-*/include/$(@F) . -$(SYSROOT)/usr/include/ffi.h: $(rpms) - cd $(@D) && rm $(@F) && ln -s ../lib/libffi-*/include/$(@F) . - -$(SYSROOT)/usr/include/ffitarget.h: $(rpms) - cd $(@D) && rm $(@F) && ln -s ../lib/libffi-*/include/$(@F) . + $(SYSROOT)/usr/include/ffitarget.h: $(rpms) + cd $(@D) && rm -f $(@F) && ln -s ../lib/libffi-*/include/$(@F) . -SYSROOT_LINKS += $(SYSROOT)/usr/include/ffi.h $(SYSROOT)/usr/include/ffitarget.h + SYSROOT_LINKS += $(SYSROOT)/usr/include/ffi.h $(SYSROOT)/usr/include/ffitarget.h +endif ########################################################################################## # Define marker files for each source package to be compiled -$(foreach t,binutils mpfr gmp mpc gcc ccache,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done)) +$(foreach t,binutils mpfr gmp mpc gcc ccache gdb,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done)) ########################################################################################## @@ -234,7 +258,8 @@ PATHEXT = $(RESULT)/$(BUILD)/bin: PATHPRE = PATH=$(PATHEXT)$(PATH) -BUILDPAR = -j16 +NUM_CORES := $(shell cat /proc/cpuinfo | grep -c processor) +BUILDPAR = -j$(NUM_CORES) # Default commands to when making MAKECMD = @@ -317,6 +342,8 @@ --disable-nls \ --program-prefix=$(TARGET)- \ --enable-multilib \ + --enable-gold \ + --enable-plugins \ ) > $(@D)/log.config 2>&1 @echo 'done' @@ -392,7 +419,6 @@ --with-sysroot=$(SYSROOT) \ --enable-languages=c,c++ \ --enable-shared \ - --enable-multilib \ --disable-nls \ --with-gnu-as \ --with-gnu-ld \ @@ -410,6 +436,23 @@ $(mpfr) : $(gmp) $(mpc) : $(gmp) $(mpfr) +################################################################################ +# Build gdb but only where host and target match +ifeq ($(HOST), $(TARGET)) + $(BUILDDIR)/$(gdb_ver)/Makefile: $(GDB_CFG) + $(info Configuring $@. Log in $(@D)/log.config) + mkdir -p $(@D) + ( \ + cd $(@D) ; \ + $(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)" $(GDB_CFG) \ + $(CONFIG) \ + --with-sysroot=$(SYSROOT) \ + ) > $(@D)/log.config 2>&1 + @echo 'done' + + $(gdb): $(gcc) +endif + ########################################################################################## # very straightforward. just build a ccache. it is only for host. $(BUILDDIR)/$(ccache_ver)/Makefile \ @@ -434,7 +477,7 @@ if [ ! -e $(PREFIX)/bin/$(TARGET)-$$f ]; \ then \ cd $(PREFIX)/bin && \ - ln -s $$f $(TARGET)-$$f ; \ + ln -fs $$f $(TARGET)-$$f ; \ fi \ done @touch $@ @@ -451,7 +494,7 @@ if [ ! -e $(TARGETDIR)/$(l)/$$f ]; then \ mkdir -p $(TARGETDIR)/$(l) && \ cd $(TARGETDIR)/$(l)/ && \ - ln -s $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f; \ + ln -fs $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f; \ fi \ done;) @echo 'done' @@ -471,6 +514,7 @@ $(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $( $(&1 @echo -n 'installing...' $(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $( $(&1 + @mkdir -p $(@D) @touch $@ @echo 'done' @@ -488,6 +532,18 @@ echo 'DEVKIT_SYSROOT="$$DEVKIT_ROOT/$$host/sysroot"' >> $@ ########################################################################################## +# Copy these makefiles into the root of the kit +$(PREFIX)/Makefile: ./Makefile + rm -rf $@ + cp $< $@ + +$(PREFIX)/Tools.gmk: ./Tools.gmk + rm -rf $@ + cp $< $@ + +THESE_MAKEFILES := $(PREFIX)/Makefile $(PREFIX)/Tools.gmk + +########################################################################################## ifeq ($(TARGET), $(HOST)) $(PREFIX)/bin/%: @@ -496,7 +552,7 @@ missing-links := $(addprefix $(PREFIX)/bin/, \ addr2line ar as c++ c++filt elfedit g++ gcc gprof ld nm objcopy ranlib readelf \ - size strings strip) + size strings strip ld.bfd ld.gold) endif ########################################################################################## @@ -507,7 +563,9 @@ libs : $(libs) sysroot : rpms libs gcc : sysroot $(gcc) $(gccpatch) -all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links) $(SYSROOT_LINKS) +gdb : $(gdb) +all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links) $(SYSROOT_LINKS) \ + $(THESE_MAKEFILES) gdb # this is only built for host. so separate. ccache : $(ccache)