From d8cee0a48b5dd72643e9a8059cebdd4d7a5ddc78 Mon Sep 17 00:00:00 2001 From: John Marino Date: Fri, 3 Feb 2017 05:29:43 +0000 Subject: [PATCH] gnatdroid: Prepare for new cross-compiler The gnatdroid binutils and compiler master ports have been expanded to support an upcoming FreeBSD/DF -to- FreeBSD-ARM64 cross-compiler. This backports the gcc7 aarch64-*-freebsd* support to gcc6-aux along with a customization of mine for the gnat compiler. This also adds the missing LINK_SPEC replacement and removes a now-obsolete post-extract directory creation. Apparently the fortran option has been broken since the rebasing on gcc6-aux, now fixed, but nobody reported it. --- lang/gcc6-aux/Makefile.version | 4 +- lang/gcc6-aux/files/diff-ada | 122 +++++++++++++++-- lang/gcc6-aux/files/diff-core | 227 ++++++++++++++++++++++++++++++- lang/gnatdroid-armv7/Makefile | 40 ++++-- lang/gnatdroid-binutils/Makefile | 7 +- 5 files changed, 367 insertions(+), 33 deletions(-) diff --git a/lang/gcc6-aux/Makefile.version b/lang/gcc6-aux/Makefile.version index c9eeef54045d..bd2bbce8eba7 100644 --- a/lang/gcc6-aux/Makefile.version +++ b/lang/gcc6-aux/Makefile.version @@ -7,7 +7,9 @@ SNAPSHOT= 20161221 BUILD_RELEASE= yes MAIN_PR= 0 UTIL_PR= 0 -ARMV7_PR= 0 +ARMV7_PR= 1 +ARM64_PR= 0 +X86_PR= 1 .if ${BUILD_RELEASE:Mno} # Snapshot naming pattern diff --git a/lang/gcc6-aux/files/diff-ada b/lang/gcc6-aux/files/diff-ada index 6b2eee05721a..d40eed2845b6 100644 --- a/lang/gcc6-aux/files/diff-ada +++ b/lang/gcc6-aux/files/diff-ada @@ -1003,7 +1003,7 @@ THREADSLIB = -lposix4 -lthread MISCLIB = -lposix4 -lnsl -lsocket SO_OPTS = -Wl,-h, -@@ -1390,6 +1394,39 @@ +@@ -1475,10 +1479,45 @@ LIBRARY_VERSION := $(LIB_VERSION) endif @@ -1040,10 +1040,7 @@ + LIBRARY_VERSION := $(LIB_VERSION) +endif + - # x86 kfreebsd - ifeq ($(strip $(filter-out %86 kfreebsd%,$(target_cpu) $(target_os))),) - LIBGNAT_TARGET_PAIRS = \ -@@ -1450,6 +1487,8 @@ + # x86 FreeBSD ifeq ($(strip $(filter-out %86 freebsd%,$(target_cpu) $(target_os))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.ads. */ ++ ++#ifndef GCC_AARCH64_FREEBSD_H ++#define GCC_AARCH64_FREEBSD_H ++ ++#undef SUBTARGET_CPP_SPEC ++#define SUBTARGET_CPP_SPEC FBSD_CPP_SPEC ++ ++#if TARGET_BIG_ENDIAN_DEFAULT ++#define TARGET_LINKER_EMULATION "aarch64fbsdb" ++#else ++#define TARGET_LINKER_EMULATION "aarch64fbsd" ++#endif ++ ++#undef SUBTARGET_EXTRA_LINK_SPEC ++#define SUBTARGET_EXTRA_LINK_SPEC " -m" TARGET_LINKER_EMULATION ++ ++#undef FBSD_TARGET_LINK_SPEC ++#define FBSD_TARGET_LINK_SPEC " \ ++ %{p:%nconsider using `-pg' instead of `-p' with gprof (1) } \ ++ %{v:-V} \ ++ %{assert*} %{R*} %{rpath*} %{defsym*} \ ++ %{shared:-Bshareable %{h*} %{soname*}} \ ++ %{symbolic:-Bsymbolic} \ ++ %{static:-Bstatic} \ ++ %{!static: \ ++ %{!static: --hash-style=gnu -rpath @PREFIX@/@GCCAUX@/lib} \ ++ %{rdynamic:-export-dynamic} \ ++ %{!shared:-dynamic-linker " FBSD_DYNAMIC_LINKER " }} \ ++ -X" SUBTARGET_EXTRA_LINK_SPEC " \ ++ %{mbig-endian:-EB} %{mlittle-endian:-EL}" ++ ++#if TARGET_FIX_ERR_A53_835769_DEFAULT ++#define CA53_ERR_835769_SPEC \ ++ " %{!mno-fix-cortex-a53-835769:--fix-cortex-a53-835769}" ++#else ++#define CA53_ERR_835769_SPEC \ ++ " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}" ++#endif ++ ++#ifdef TARGET_FIX_ERR_A53_843419_DEFAULT ++#define CA53_ERR_843419_SPEC \ ++ " %{!mno-fix-cortex-a53-843419:--fix-cortex-a53-843419}" ++#else ++#define CA53_ERR_843419_SPEC \ ++ " %{mfix-cortex-a53-843419:--fix-cortex-a53-843419}" ++#endif ++ ++#undef LINK_SPEC ++#define LINK_SPEC FBSD_TARGET_LINK_SPEC \ ++ CA53_ERR_835769_SPEC \ ++ CA53_ERR_843419_SPEC ++ ++#define GNU_USER_TARGET_MATHFILE_SPEC \ ++ "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" ++ ++#undef ENDFILE_SPEC ++#define ENDFILE_SPEC \ ++ GNU_USER_TARGET_MATHFILE_SPEC " " \ ++ FBSD_ENDFILE_SPEC ++ ++#undef TARGET_OS_CPP_BUILTINS ++#define TARGET_OS_CPP_BUILTINS() \ ++ do \ ++ { \ ++ FBSD_TARGET_OS_CPP_BUILTINS (); \ ++ } \ ++ while (false) ++ ++#define TARGET_ASM_FILE_END file_end_indicate_exec_stack ++ ++/* Uninitialized common symbols in non-PIE executables, even with ++ strong definitions in dependent shared libraries, will resolve ++ to COPY relocated symbol in the executable. See PR65780. */ ++#undef TARGET_BINDS_LOCAL_P ++#define TARGET_BINDS_LOCAL_P default_binds_local_p_2 ++ ++/* Static stack checking is supported by means of probes. */ ++#define STACK_CHECK_STATIC_BUILTIN 1 ++#endif /* GCC_AARCH64_FREEBSD_H */ +--- /dev/null ++++ gcc/config/aarch64/t-aarch64-freebsd +@@ -0,0 +1,21 @@ ++# Machine description for AArch64 architecture. ++# Copyright (C) 2016 Free Software Foundation, Inc. ++# ++# This file is part of GCC. ++# ++# GCC is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3, or (at your option) ++# any later version. ++# ++# GCC is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GCC; see the file COPYING3. If not see ++# . ++ ++LIB1ASMSRC = aarch64/lib1funcs.asm ++LIB1ASMFUNCS = _aarch64_sync_cache_range --- gcc/config/i386/freebsd.h.orig +++ gcc/config/i386/freebsd.h @@ -77,6 +77,12 @@ @@ -40,6 +164,18 @@ %{static:-Bstatic}} \ + %{!static:" ELF_HASH_STYLE "-rpath @PREFIX@/@GCCAUX@/lib} \ %{symbolic:-Bsymbolic}" +--- configure.orig ++++ configure +@@ -3483,6 +3483,9 @@ + *-*-vxworks*) + noconfigdirs="$noconfigdirs ${libgcj}" + ;; ++ aarch64*-*-freebsd*) ++ noconfigdirs="$noconfigdirs target-libffi" ++ ;; + alpha*-*-*vms*) + noconfigdirs="$noconfigdirs ${libgcj}" + ;; --- gcc/Makefile.in.orig +++ gcc/Makefile.in @@ -1185,7 +1185,6 @@ @@ -50,7 +186,7 @@ insn-opinit.o \ insn-output.o \ insn-peep.o \ -@@ -1556,6 +1555,7 @@ +@@ -1557,6 +1556,7 @@ $(OBJS-libcommon-target) main.o c-family/cppspec.o \ $(COLLECT2_OBJS) $(EXTRA_GCC_OBJS) $(GCOV_OBJS) $(GCOV_DUMP_OBJS) \ $(GCOV_TOOL_OBJS) $(GENGTYPE_OBJS) gcc-ar.o gcc-nm.o gcc-ranlib.o \ @@ -58,7 +194,7 @@ lto-wrapper.o collect-utils.o # This lists all host object files, whether they are included in this -@@ -1563,6 +1563,11 @@ +@@ -1564,6 +1564,11 @@ ALL_HOST_OBJS = $(ALL_HOST_FRONTEND_OBJS) $(ALL_HOST_BACKEND_OBJS) BACKEND = libbackend.a main.o libcommon-target.a libcommon.a \ @@ -70,7 +206,7 @@ $(CPPLIB) $(LIBDECNUMBER) # This is defined to "yes" if Tree checking is enabled, which roughly means -@@ -2217,6 +2222,7 @@ +@@ -2218,6 +2223,7 @@ insn-modes.c: s-modes; @true insn-modes.h: s-modes-h; @true @@ -78,7 +214,7 @@ min-insn-modes.c: s-modes-m; @true s-modes: build/genmodes$(build_exeext) -@@ -2234,6 +2240,12 @@ +@@ -2235,6 +2241,12 @@ $(SHELL) $(srcdir)/../move-if-change tmp-min-modes.c min-insn-modes.c $(STAMP) s-modes-m @@ -91,7 +227,7 @@ insn-preds.c: s-preds; @true tm-preds.h: s-preds-h; @true tm-constrs.h: s-constrs-h; @true -@@ -3419,6 +3431,9 @@ +@@ -3420,6 +3432,9 @@ ( cd $(DESTDIR)$(bindir) && \ $(LN) $(GCC_INSTALL_NAME)$(exeext) $(FULL_DRIVER_NAME) ); \ fi; \ @@ -101,3 +237,84 @@ if [ ! -f gcc-cross$(exeext) ] \ && [ "$(GCC_INSTALL_NAME)" != "$(GCC_TARGET_INSTALL_NAME)" ]; then \ rm -f $(DESTDIR)$(bindir)/$(target_noncanonical)-gcc-tmp$(exeext); \ +--- gcc/config.gcc.orig ++++ gcc/config.gcc +@@ -941,6 +941,11 @@ + done + TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'` + ;; ++aarch64*-*-freebsd*) ++ tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file}" ++ tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-freebsd.h" ++ tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-freebsd" ++ ;; + aarch64*-*-linux*) + tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h" + tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-linux.h" +@@ -1445,12 +1450,16 @@ + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/x86-64.h i386/freebsd.h i386/freebsd64.h" + ;; + i[34567]86-*-netbsdelf*) +- tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h" ++ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h freebsd-stdint.h" + extra_options="${extra_options} netbsd.opt netbsd-elf.opt" ++ tmake_file="${tmake_file} i386/t-crtstuff" ++ use_gcc_stdint=wrap + ;; + x86_64-*-netbsd*) +- tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/x86-64.h i386/netbsd64.h" ++ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/x86-64.h i386/netbsd64.h freebsd-stdint.h" + extra_options="${extra_options} netbsd.opt netbsd-elf.opt" ++ tmake_file="${tmake_file} i386/t-crtstuff" ++ use_gcc_stdint=wrap + ;; + i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123]) + tm_file="i386/i386.h i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h openbsd-oldgas.h openbsd.h i386/openbsd.h" +--- gcc/config.host.orig ++++ gcc/config.host +@@ -99,7 +99,7 @@ + esac + + case ${host} in +- aarch64*-*-linux*) ++ aarch64*-*-freebsd* | aarch64*-*-linux*) + case ${target} in + aarch64*-*-*) + host_extra_gcc_objs="driver-aarch64.o" +--- libgcc/config.host.orig ++++ libgcc/config.host +@@ -242,7 +242,8 @@ + extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o" + ;; + *-*-netbsd*) +- tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver" ++ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip" ++ tmake_file="$tmake_file t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver" + # NetBSD 1.7 and later are set up to use GCC's crtstuff for + # ELF configurations. We will clear extra_parts in the + # a.out configurations. +@@ -333,6 +334,11 @@ + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" + tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + ;; ++aarch64*-*-freebsd*) ++ extra_parts="$extra_parts crtfastmath.o" ++ tmake_file="${tmake_file} ${cpu_type}/t-aarch64" ++ tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" ++ ;; + aarch64*-*-linux*) + extra_parts="$extra_parts crtfastmath.o" + md_unwind_header=aarch64/linux-unwind.h +@@ -597,9 +603,12 @@ + md_unwind_header=i386/freebsd-unwind.h + ;; + i[34567]86-*-netbsdelf*) ++ tmake_file="${tmake_file} i386/t-crtstuff" ++ #md_unwind_header=i386/netbsd-unwind.h + ;; + x86_64-*-netbsd*) + tmake_file="${tmake_file} i386/t-crtstuff" ++ #md_unwind_header=i386/netbsd-unwind.h + ;; + i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123]) + ;; diff --git a/lang/gnatdroid-armv7/Makefile b/lang/gnatdroid-armv7/Makefile index 5ce73282fabf..c3678bac1d3b 100644 --- a/lang/gnatdroid-armv7/Makefile +++ b/lang/gnatdroid-armv7/Makefile @@ -6,7 +6,7 @@ PORTVERSION= ${SNAPSHOT} PORTREVISION?= ${ARMV7_PR} CATEGORIES= lang MASTER_SITES= GCC/releases/gcc-${GCC_VERSION} -PKGNAMEPREFIX= gnatdroid- +PKGNAMEPREFIX?= gnatdroid- DISTFILES= ${IDENTIFICATION}.tar.bz2 MAINTAINER?= marino@FreeBSD.org @@ -15,7 +15,7 @@ COMMENT?= C/Ada cross-compiler, target: Android ARMv7 LICENSE= GPLv3 GPLv3RLE LICENSE_COMB= multi -BUILD_DEPENDS= ${SYSROOT}>=19:lang/${SYSROOT} \ +BUILD_DEPENDS= ${SYSROOT}>=0:lang/${SYSROOT} \ ${GDBINUTILS}>=2.21:lang/${GDBINUTILS} RUN_DEPENDS:= ${BUILD_DEPENDS} @@ -40,17 +40,23 @@ CPUVERSION?= ARMv7 ARG_ARCH?= --with-arch=armv7-a ARG_FPU?= --with-fpu=neon ARG_FLOATSOFT?= --with-float=soft +ARG_TARGET_SPECIFIC?= --enable-target-optspace \ + --enable-cxx-flags=-frtti \ + --disable-sjlj-exceptions \ + --disable-tls ALL_TARGET= all GARCH= ${ARCH:S/amd64/x86_64/} BITS= ${GARCH:S/x86_64/64/:S/i386/32/} -OS_LABEL4VERS= [${OPSYS}${BITS} x Android ${CPUVERSION}] +LABEL_TARGET?= Android ${CPUVERSION} +OS_LABEL4VERS= [${OPSYS}${BITS} x ${LABEL_TARGET}] WRKSRC= ${WRKDIR}/${IDENTIFICATION} BUILD_WRKSRC= ${WRKDIR}/build -PATCHDIR= ${.CURDIR}/../${AUXPORT}/files +DIFFDIR= ${.CURDIR}/../${AUXPORT}/files CFG_SCRIPT= ${WRKSRC}/configure REVFILE= ${WRKSRC}/gcc/REVISION SRPREFIX?= ${LOCALBASE}/android -PREFIX= ${SRPREFIX}/${CPUVERSION} +GNATPREFIX?= ${SRPREFIX}/${CPUVERSION} +PREFIX= ${GNATPREFIX} SYSROOT?= gnatdroid-sysroot GDBINUTILS?= gnatdroid-binutils PLIST_SUB+= TARGET="${DROID_TARGET}" @@ -65,14 +71,13 @@ CROSS= gnat gnatbind gnatchop gnatclean gnatfind gnatkr \ .if ${PORT_OPTIONS:MFORT} LANGS+= fortran -APPLY_DIFFS+= fortran .endif .if ${PORT_OPTIONS:MOBJC} LANGS+= objc .endif -INSTALL_ENV= ${MAKE_ENV:C/^PATH=/&${SRPREFIX}\/${CPUVERSION}\/bin:/} +INSTALL_ENV= ${MAKE_ENV:C/^PATH=/&${PREFIX}\/bin:/} ADA_CONFIG_ARGS= --enable-languages=${LANGS:Q} ADA_CONFIG_ARGS+= --target=${DROID_TARGET} @@ -87,9 +92,8 @@ ADA_CONFIG_ARGS+= ${ICONV_CONFIGURE_ARG} ADA_CONFIG_ARGS+= --with-sysroot=${SRPREFIX} ADA_CONFIG_ARGS+= ${ARG_FLOATSOFT} ADA_CONFIG_ARGS+= ${ARG_FPU} -ADA_CONFIG_ARGS+= --enable-target-optspace +ADA_CONFIG_ARGS+= ${ARG_TARGET_SPECIFIC} ADA_CONFIG_ARGS+= --enable-threads=posix -ADA_CONFIG_ARGS+= --enable-cxx-flags=-frtti ADA_CONFIG_ARGS+= --enable-checking=release ADA_CONFIG_ARGS+= --disable-bootstrap ADA_CONFIG_ARGS+= --disable-shared @@ -99,27 +103,35 @@ ADA_CONFIG_ARGS+= --disable-libmudflap ADA_CONFIG_ARGS+= --disable-libquadmath ADA_CONFIG_ARGS+= --disable-libsanitizer ADA_CONFIG_ARGS+= --disable-libitm -ADA_CONFIG_ARGS+= --disable-sjlj-exceptions -ADA_CONFIG_ARGS+= --disable-tls +ADA_CONFIG_ARGS+= --disable-libcc1 ADA_CONFIG_ARGS+= --disable-nls post-extract: # Personalize GNAT for each different machine @${ECHO} "-=> GNAT AUX ${OS_LABEL4VERS}" > ${REVFILE} - ${MKDIR} ${WRKSRC}/libstdc++-v3/config/locale/dragonfly - ${MKDIR} ${WRKSRC}/libstdc++-v3/config/os/bsd/dragonfly # Apply required composite diff files .for suffix in ${APPLY_DIFFS} @${ECHO} "Applying composite patch diff-${suffix}" - @${PATCH} -d ${WRKSRC} -s -E < ${PATCHDIR}/diff-${suffix} + @${PATCH} -d ${WRKSRC} -s -E < ${DIFFDIR}/diff-${suffix} .endfor @(cd ${WRKSRC}/gcc/testsuite/ada/acats && \ ${CP} run_remote.sh run_all.sh) + @${CHMOD} 755 ${WRKSRC}/gcc/testsuite/ada/acats/run_all.sh ${REINPLACE_CMD} -e 's|@REMOTE_TARGET@|${DROID_TARGET}|' \ ${WRKSRC}/gcc/testsuite/ada/acats/run_all.sh ${REINPLACE_CMD} -e 's|||' \ ${WRKSRC}/libstdc++-v3/libsupc++/guard.cc +post-patch: + # Update LINK_SPEC to add gcc-aux lib runpath in every binary + @${ECHO} "Configuring LINK_SPEC runpath" + @${REINPLACE_CMD} -e 's;\@PREFIX\@;${LOCALBASE};' \ + -e 's;\@GCCAUX\@;${AUXPORT};' \ + ${WRKSRC}/gcc/config/dragonfly.h \ + ${WRKSRC}/gcc/config/i386/freebsd64.h \ + ${WRKSRC}/gcc/config/i386/freebsd.h \ + ${WRKSRC}/gcc/config/aarch64/aarch64-freebsd.h + do-configure: ${MKDIR} ${BUILD_WRKSRC} (cd ${BUILD_WRKSRC} && ${SETENV} ${CONFIGURE_ENV} \ diff --git a/lang/gnatdroid-binutils/Makefile b/lang/gnatdroid-binutils/Makefile index f940c2aebb6d..77cee293365c 100644 --- a/lang/gnatdroid-binutils/Makefile +++ b/lang/gnatdroid-binutils/Makefile @@ -5,7 +5,7 @@ PORTNAME= binutils PORTVERSION= 2.27 CATEGORIES= lang MASTER_SITES= SOURCEWARE/binutils/releases -PKGNAMEPREFIX= gnatdroid- +PKGNAMEPREFIX?= gnatdroid- MAINTAINER?= marino@FreeBSD.org COMMENT?= Infrastructure for C/Ada Android cross-compiler (ARMv7) @@ -13,7 +13,7 @@ COMMENT?= Infrastructure for C/Ada Android cross-compiler (ARMv7) LICENSE= GPLv3 LGPL3 LICENSE_COMB= multi -BUILD_DEPENDS= ${SYSROOT}>=19:lang/${SYSROOT} \ +BUILD_DEPENDS= ${SYSROOT}>0:lang/${SYSROOT} \ ${LOCALBASE}/lib/libgmp.so:math/gmp \ ${LOCALBASE}/lib/libmpfr.so:math/mpfr RUN_DEPENDS:= ${BUILD_DEPENDS} @@ -26,6 +26,7 @@ NO_LICENSES_INSTALL= yes WRKSRC= ${WRKDIR}/binutils-${PORTVERSION} PREFIX?= ${LOCALBASE}/android +SRPREFIX?= ${PREFIX} BRANCH2?= ARMv7 BR2_PREFIX= ${PREFIX}/${BRANCH2} XCCTARGET?= arm-aux-linux-androideabi @@ -35,7 +36,7 @@ PLIST_SUB+= BRANCH2="${BRANCH2}" CONFIGURE_ARGS+= --target=${XCCTARGET} CONFIGURE_ARGS+= --prefix=${BR2_PREFIX} -CONFIGURE_ARGS+= --with-sysroot=${PREFIX} +CONFIGURE_ARGS+= --with-sysroot=${SRPREFIX} CONFIGURE_ARGS+= --with-gmp=${LOCALBASE} CONFIGURE_ARGS+= --with-mpfr=${LOCALBASE} CONFIGURE_ARGS+= --disable-werror