Skip to content

Commit

Permalink
lang/gcc7: Apply our GCC changes.
Browse files Browse the repository at this point in the history
 - Add ALTERNATIVES files.
 - Include necessary object files in the -libs package.
 - Prune unnecessary libraries from the -libs package.
 - Set local prefix to LOCALBASE (except tools build), and link against
   it by default.
 - Disable -fomit-frame-pointer, we like stack traces.
 - Disable --as-needed to avoid libgcc_s dependency.
 - Disable __stack_chk_fail_local (fixes 32-bit)
 - Support -fclone-functions, -fstrict-calling-conventions, -msave-args
 - Fix check-shlibs in -libs
 - Fix TritonDataCenter/pkgsrc-legacy#264 (avoid tls emulation)
  • Loading branch information
jperkin authored and github-actions[bot] committed Jan 7, 2025
1 parent 4317e15 commit 0858de1
Show file tree
Hide file tree
Showing 25 changed files with 821 additions and 8 deletions.
20 changes: 17 additions & 3 deletions lang/gcc7-libs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ RELRO_SUPPORTED= no
## Depend on exactly ${GCC7_DIST_VERSION}.
TOOL_DEPENDS+= ${GCC_PKGNAME}-${GCC7_DIST_VERSION}{,nb[0-9]*}:../../lang/gcc7

# Finds libs from gcc7 due to rpath
CHECK_SHLIBS= no

.include "../../mk/bsd.prefs.mk"

LIBGCC_SUBPREFIX= ${GCC_PKGNAME}
Expand All @@ -47,23 +50,34 @@ SHLIB_EXT= so
.endif

LIBRARY_FILES= ${WRKDIR}/lib_files
OBJECT_FILES= ${WRKDIR}/obj_files

GENERATE_PLIST+= ${SED} -e 's,^,${LIBGCC_SUBPREFIX}/${GCC_TARGET_MACHINE}/,' \
${LIBRARY_FILES};
-e 's,gcc/${MACHINE_GNU_PLATFORM}/${GCC7_DIST_VERSION}/,,' \
${LIBRARY_FILES} ${OBJECT_FILES};
GENERATE_PLIST+= ${GREP} -q 'lib/' ${LIBRARY_FILES} || \
${ECHO} '@pkgdir ${LIBGCC_SUBPREFIX}/${GCC_TARGET_MACHINE}/lib';

${LIBRARY_FILES}:
${PKG_INFO} -qL '${GCC_PKGNAME}-${GCC7_DIST_VERSION}*' | \
${SED} -n -e's,^${LIBGCC_PREFIX}/,,' -e'/libexec\//d' \
-e'/libgij/d;/libgcj/d;/libjvm/d' \
-e'/libgij/d;/libgcj/d;/libjvm/d;/libgo\./d' \
-e'/libcc1plugin/d;/libcp1plugin/d;' \
-e'/lib.*\.${SHLIB_EXT}/p' >${LIBRARY_FILES}

do-install: ${LIBRARY_FILES}
${OBJECT_FILES}:
${PKG_INFO} -qL '${GCC_PKGNAME}-${GCC7_DIST_VERSION}*' | \
${SED} -n -e 's,^${LIBGCC_PREFIX}/,,' \
-e '/\.o/p' -e '/libgcc\.a/p' -e '/libssp_nonshared\.a/p' >${OBJECT_FILES}

do-install: ${LIBRARY_FILES} ${OBJECT_FILES}
${TEST} -d ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib || \
${MKDIR} ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib
cd ${LIBGCC_PREFIX} && \
${PAX} -rw ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE} <${LIBRARY_FILES}
cd ${LIBGCC_PREFIX} && \
${PAX} -r -s ',gcc/${MACHINE_GNU_PLATFORM}/${GCC7_DIST_VERSION}/,,' \
-w ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE} <${OBJECT_FILES}

.include "../../mk/dlopen.buildlink3.mk"
.include "../../mk/pthread.buildlink3.mk"
Expand Down
20 changes: 20 additions & 0 deletions lang/gcc7/ALTERNATIVES
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
bin/c++ @PREFIX@/gcc7/bin/c++
bin/cc @PREFIX@/gcc7/bin/cc
bin/cpp @PREFIX@/gcc7/bin/cpp
bin/g++ @PREFIX@/gcc7/bin/g++
bin/gcc @PREFIX@/gcc7/bin/gcc
bin/gcc-ar @PREFIX@/gcc7/bin/gcc-ar
bin/gcc-nm @PREFIX@/gcc7/bin/gcc-nm
bin/gcc-ranlib @PREFIX@/gcc7/bin/gcc-ranlib
bin/gcov @PREFIX@/gcc7/bin/gcov
bin/gcov-dump @PREFIX@/gcc7/bin/gcov-dump
bin/gcov-tool @PREFIX@/gcc7/bin/gcov-tool
bin/gfortran @PREFIX@/gcc7/bin/gfortran
bin/@MACHINE_GNU_PLATFORM@-c++ @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-c++
bin/@MACHINE_GNU_PLATFORM@-g++ @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-g++
bin/@MACHINE_GNU_PLATFORM@-gcc @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc
bin/@MACHINE_GNU_PLATFORM@-gcc-@GCC7_DIST_VERSION@ @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-@GCC7_DIST_VERSION@
bin/@MACHINE_GNU_PLATFORM@-gcc-ar @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-ar
bin/@MACHINE_GNU_PLATFORM@-gcc-nm @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-nm
bin/@MACHINE_GNU_PLATFORM@-gcc-ranlib @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gcc-ranlib
bin/@MACHINE_GNU_PLATFORM@-gfortran @PREFIX@/gcc7/bin/@MACHINE_GNU_PLATFORM@-gfortran
33 changes: 33 additions & 0 deletions lang/gcc7/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ FORCE_C_STD= gnu99
UNLIMIT_RESOURCES+= datasize
UNLIMIT_RESOURCES+= stacksize

FILES_SUBST+= GCC7_DIST_VERSION=${GCC7_DIST_VERSION}
FILES_SUBST+= MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM}

SUBST_CLASSES+= vars
SUBST_MESSAGE.vars= Setting target machine name path in ${SUBST_FILES.vars}
SUBST_STAGE.vars= pre-configure
Expand All @@ -63,6 +66,28 @@ CHECK_PORTABILITY_SKIP+= \

.include "../../mk/bsd.prefs.mk"

# This includes some multiarch configuration but is left in the miscfix branch
# to ease merging.
SUBST_CLASSES+= rpaths
SUBST_STAGE.rpaths= pre-configure
SUBST_FILES.rpaths= gcc/config/sol2.h
SUBST_VARS.rpaths= PREFIX
.if !empty(MULTIARCH:M[Yy][Ee][Ss])
SUBST_SED.rpaths= -e 's,@MARCH64_SUBDIR@,ARCH64_SUBDIR,g'
SUBST_SED.rpaths+= -e 's,@MARCH64_SLASH@,/,g'
.else
SUBST_SED.rpaths= -e 's,@MARCH64_SUBDIR@,,g'
SUBST_SED.rpaths+= -e 's,@MARCH64_SLASH@,,g'
.endif
# For the tools build (i.e. when not using USE_GCC_LOCALBASE_PREFIX) we
# do not want to include any of the PREFIX library paths added by
# patch-gcc_config_sol2.h, otherwise they would leak into the non-tools
# builds. The SUBST used here relies on SUBST_VARS coming after SUBST_SED.
.if ${USE_GCC_LOCALBASE_PREFIX:Uno:tl} == "no"
SUBST_SED.rpaths+= -e '/-R@PREFIX@/d'
SUBST_SED.rpaths+= -e 's/:%R@PREFIX@[^}]*//'
.endif

LANGS= c

# In some cases LINKER_RPATH_FLAG needs a trailing space.
Expand Down Expand Up @@ -122,7 +147,11 @@ CFLAGS+= -Wno-missing-attributes
CONFIGURE_ARGS+= --enable-languages=${LANGS:Q}
CONFIGURE_ARGS+= --enable-shared
CONFIGURE_ARGS+= --enable-long-long
.if ${USE_GCC_LOCALBASE_PREFIX:Uno:tl} == "yes"
CONFIGURE_ARGS+= --with-local-prefix=${LOCALBASE:Q}
.else
CONFIGURE_ARGS+= --with-local-prefix=${GCC_PREFIX:Q}
.endif
CONFIGURE_ARGS+= --enable-threads=posix
CONFIGURE_ARGS+= --with-boot-ldflags=${BOOT_LDFLAGS:Q}
# multilib on Darwin requires fat-binaries
Expand Down Expand Up @@ -163,6 +192,8 @@ MAKE_ENV+= lt_cv_path_SED=${TOOLS_SED}

# Determine whether to use binutils
.if ${OPSYS} == "SunOS"
# Disable --as-needed as it pulls in libgcc_s as a dependency.
MAKE_ENV+= gcc_cv_ld_as_needed=no
. if exists(/usr/sfw/bin/gobjdump)
CONFIGURE_ENV+= OBJDUMP=/usr/sfw/bin/gobjdump
. endif
Expand Down Expand Up @@ -213,6 +244,8 @@ GENERATE_PLIST+= \
cd ${DESTDIR}${PREFIX} && \
${FIND} ${GCC_SUBPREFIX} \( -type f -o -type l \) -print | ${SORT};

CTF_FILES_SKIP+= */gengtype

.include "../../mk/dlopen.buildlink3.mk"
.include "../../mk/pthread.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"
22 changes: 20 additions & 2 deletions lang/gcc7/distinfo
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SHA512 (isl-0.18.tar.bz2) = 85d0b40f4dbf14cb99d17aa07048cdcab2dc3eb527d2fbb1e84c
Size (isl-0.18.tar.bz2) = 1658291 bytes
SHA1 (patch-contrib_download__prerequisites) = 86c6c16e0e3e3a0bcb38579a8b4004f603fac1ca
SHA1 (patch-gcc_Makefile.in) = d96a57a098e49a2c5ea6478dd5d22aba584fc1bc
SHA1 (patch-gcc_caller-save.c) = 8b667a6d3129a912339c23a6ed64b10ccca7733f
SHA1 (patch-gcc_common.opt) = b7123b7119c524da1bc310429da9fd0338e17b55
SHA1 (patch-gcc_common_config_arm_arm-common.c) = 7c973cb9554a52f4b85f8fc98708f5e5cce8e8bd
SHA1 (patch-gcc_config.gcc) = 20d1444cc2c031c8adc96289e1ccc6c1d29eb72f
SHA1 (patch-gcc_config.host) = 1b1e11cd199eb93f49443d51c0063b09b7327858
Expand All @@ -22,26 +24,42 @@ SHA1 (patch-gcc_config_arm_netbsd-eabi.h) = 9c1d2148e306024e8de3bdc9802fb63b976e
SHA1 (patch-gcc_config_arm_netbsd-elf.h) = 80a07645fab197969b4a6f518fdc81bda7376375
SHA1 (patch-gcc_config_darwin-driver.c) = d6e59feef5f6611aabd56028ca29db5919797f88
SHA1 (patch-gcc_config_host-netbsd.c) = 765295f07edb8a68f1910e3a9b4dd2a7dcd491a5
SHA1 (patch-gcc_config_i386_i386.c) = cd11cff11c217eed3601da9cd209b5cb74fd0dad
SHA1 (patch-gcc_config_i386_i386.h) = b23863a9baf6d5aa20939e0d58ca343db15c8513
SHA1 (patch-gcc_config_i386_i386.opt) = f0e325859409bd10a6fb60a85d659a23509f2f27
SHA1 (patch-gcc_config_netbsd-elf.h) = 5a9b5ef26c03bec3cd58e2f446224aa6e94a30d5
SHA1 (patch-gcc_config_netbsd-protos.h) = 6d28864b4ccc8c1a63fe28e43601b84b63a00633
SHA1 (patch-gcc_config_netbsd.h) = 662226f4491f94b641f78b1273a9047434d75aed
SHA1 (patch-gcc_config_sol2-c.c) = 7dac7d9a4111240fbff9099d7a9bcd08c898b07d
SHA1 (patch-gcc_config_sol2.h) = b948b5e02c5b5e8bc0f86a5e579f5e6c714cf6cd
SHA1 (patch-gcc_config_sparc_sparc.c) = 7d37f33744d620faa5a2154056ba80bede0d67f6
SHA1 (patch-gcc_config_t-netbsd) = 802ad5706aa7ca9629f8e237f08fbb1569d28846
SHA1 (patch-gcc_config_x-netbsd) = 6dc3d78e26df62054ea29f98ca51592858e671e3
SHA1 (patch-gcc_configure) = 15fb7af267b79965f83bc64ce8aad1279b0ea52d
SHA1 (patch-gcc_configure) = 1b66a9ac0af5e3be39410f82b1de84f217f5c2ef
SHA1 (patch-gcc_dojump.c) = 8b6f5263e7ce251aa0a00f24cc06daf84d290eec
SHA1 (patch-gcc_dwarf2out.c) = 1cd7645095205b340305094fd31ed475fa1cc927
SHA1 (patch-gcc_ggc-common.c) = a5d2dba635859f5d680c3f80d7c30b42461c752b
SHA1 (patch-gcc_ginclude_stddef.h) = fb1f83801e0f5bcec110667dc868c47ff2d10343
SHA1 (patch-gcc_ira.c) = aa4b8d35356201f307f568238817e870a0527542
SHA1 (patch-gcc_lto_lto.c) = 825b632e2a7ff5777d4fbfdcf6f0ea3f64c4742b
SHA1 (patch-gcc_plugin.c) = 7a7ebc6650fe327fa7be1f7a4d26e8edc7597fcf
SHA1 (patch-gcc_symtab.c) = a84091f6892e421081546ce3ea381e771f0041db
SHA1 (patch-gcc_system.h) = 4c959a6b1c4d524cbdf44cfb80f0e5758ec20783
SHA1 (patch-gcc_targhooks.c) = 6268d548058b6325ead1115f78c2c17c6d786296
SHA1 (patch-gcc_testsuite_gcc.dg_fno-clone-preserves-unused-args.c) = e3b58e623df14d01fdcdb7ae1978b1876cedf657
SHA1 (patch-gcc_testsuite_gcc.target_i386_local.c) = a6f2f056cb742f8723d775746e0394b7ada02c37
SHA1 (patch-gcc_testsuite_gcc.target_i386_msave-args-mov.c) = 1b48c98ea87a6e2370e6379e63f6f318bfe019d0
SHA1 (patch-gcc_testsuite_gcc.target_i386_msave-args-push.c) = 65afdee3521d29cbcd9a06d602bed34a53465d7e
SHA1 (patch-gcc_testsuite_gcc.target_i386_strict-cc.c) = f99944d55366c609def436f997c24e90664ec859
SHA1 (patch-gcc_tree-inline.c) = f646054b34b4dd953c1d372c8f42f82055b092f4
SHA1 (patch-include_dwarf2.def) = 52e6977b842ca3257ed2ef9f7ff9d0c914a06505
SHA1 (patch-isl_configure) = 36b37778ee13c0b364fb24d5864d6a9e65b29b7d
SHA1 (patch-libcilkrts_configure) = ec76313d8103e0c525ebd26e9013ee3ca9e93391
SHA1 (patch-libcilkrts_runtime_os-unix.c) = b25632587d9fbe8ff38377fe34cb16225355b521
SHA1 (patch-libdecnumber_decNumber.c) = cec90e49c829bfc6ba1ec605d2fac7daaad62762
SHA1 (patch-libffi_configure) = bcfbfe8abddc378e2de4a39ad0669583b37e0292
SHA1 (patch-libffi_testsuite_libffi.call_float2.c) = 6321dde308579448c27c2b6e1e30633699dd145f
SHA1 (patch-libgcc_config.host) = 4fa15e83a446e026507ac4f16c4f7ef686544c43
SHA1 (patch-libgcc_config.host) = a6cc52ef4e4529d7bf77f1c7cf892a7a2d0b6e00
SHA1 (patch-libgcc_config_arm_t-netbsd) = fe986b09ccbfc253aaaca263e8e38f06da4891cc
SHA1 (patch-libgcc_config_arm_t-netbsd-eabi) = 1e818e92fe79f57d305ff42ce3449dddf87c3179
SHA1 (patch-libgcc_config_i386_cpuinfo.h) = d217e3c65178c96c7314cb88c740b9586d4e8fed
Expand Down
2 changes: 2 additions & 0 deletions lang/gcc7/options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ LANGS+= fortran

.if !empty(PKG_OPTIONS:Mgcc-c++)
LANGS+= c++
.if ${OPSYS} != "SunOS"
CONFIGURE_ARGS+= --enable-__cxa_atexit
.endif
CONFIGURE_ARGS+= --with-gxx-include-dir=${GCC_PREFIX}/include/c++/
.else
CONFIGURE_ARGS+= --disable-build-with-cxx
Expand Down
15 changes: 15 additions & 0 deletions lang/gcc7/patches/patch-gcc_caller-save.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$NetBSD$

Disable -fomit-frame-pointer.

--- gcc/caller-save.c.orig 2017-01-01 12:07:43.905435000 +0000
+++ gcc/caller-save.c
@@ -378,7 +378,7 @@ saved_hard_reg_compare_func (const void
const struct saved_hard_reg *p1 = *(struct saved_hard_reg * const *) v1p;
const struct saved_hard_reg *p2 = *(struct saved_hard_reg * const *) v2p;

- if (flag_omit_frame_pointer)
+ if (0)
{
if (p1->call_freq - p2->call_freq != 0)
return p1->call_freq - p2->call_freq;
29 changes: 29 additions & 0 deletions lang/gcc7/patches/patch-gcc_common.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$NetBSD$

Support -fclone-functions and -fstrict-calling-conventions.

--- gcc/common.opt.orig 2017-06-22 11:38:22.113724000 +0000
+++ gcc/common.opt
@@ -1076,6 +1076,11 @@ fcode-hoisting
Common Report Var(flag_code_hoisting) Optimization
Enable code hoisting.

+fclone-functions
+Common Report Var(flag_clone_functions) Init(1)
+Allow the compiler to clone functions to facilitate certain optimizations.
+Enabled by default.
+
fcombine-stack-adjustments
Common Report Var(flag_combine_stack_adjustments) Optimization
Looks for opportunities to reduce stack adjustments and stack references.
@@ -2341,6 +2346,10 @@ fstrict-aliasing
Common Report Var(flag_strict_aliasing) Optimization
Assume strict aliasing rules apply.

+fstrict-calling-conventions
+Common Report Var(flag_strict_calling_conventions) Init(1)
+Use strict ABI calling conventions even for static functions
+
fstrict-overflow
Common Report Var(flag_strict_overflow) Optimization
Treat signed overflow as undefined.
Loading

0 comments on commit 0858de1

Please sign in to comment.