Skip to content

Commit

Permalink
New gcc-11.4.0 patches; build without libsanitizer on Ventura
Browse files Browse the repository at this point in the history
  • Loading branch information
dhomeier committed Oct 4, 2023
1 parent c47a560 commit 920724f
Show file tree
Hide file tree
Showing 3 changed files with 1,200 additions and 4,823 deletions.
314 changes: 314 additions & 0 deletions 10.9-libcxx/stable/main/finkinfo/languages/gcc11-13.0.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
Info2: <<
Package: gcc11
Version: 11.4.0
Revision: 2
Type: gccver (11)
Distribution: 13.0
Source: mirror:gnu:gcc/gcc-%v/gcc-%v.tar.xz
Source-Checksum: SHA256(3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9)
PatchFile: %n-arm.patch
PatchFile-MD5: 5114fba28067ab381fe923c92db9dc38
PatchScript: <<
#!/bin/sh -ev
patch -p1 < %{PatchFile}
# don't update live infodoc dir
find . -name Makefile.in | xargs perl -pi -e 's/install-info --version/false/g'
<<
NoSetCPPFLAGS: True
NoSetLDFLAGS: True
UseMaxBuildJobs: True
Conflicts: <<
gcc5, gcc6, gcc7, gcc8,
gcc9,
gcc10,
gcc11,
gcc12,
gcc13
<<
Replaces: <<
gcc5, gcc6, gcc7, gcc8,
gcc9,
gcc10,
gcc11,
gcc12,
gcc13
<<
Depends: <<
%N-compiler (= %v-%r)
<<
BuildDepends: <<
fink (>= 0.32),
fink-package-precedence,
gettext-tools,
gmp5 (>= 6.0.0a-3),
install-info,
isl22,
libgettext8-dev,
libiconv-dev,
libmpc3 (>= 1.0.3-1),
libmpfr6,
x11-dev
<<
ConfigureParams: <<
--prefix=%p/lib/gcc%type_num[gccver] \
--mandir=%p/share/man \
--infodir=%p/lib/gcc%type_num[gccver]/info \
--enable-languages=c,c++,fortran,lto,objc,obj-c++ \
--with-gmp=%p \
--with-libiconv-prefix=%p \
--with-isl=%p \
--with-mpc=%p \
--with-system-zlib \
--program-suffix=-fsf-%type_num[gccver] \
--disable-multilib \
--enable-stage1-checking \
${USE_SYSROOT} \
--with-pkgversion="Fink %n %v-%r" \
--with-bugurl="https://github.com/fink/fink-distributions/issues"
<<
InfoTest: <<
TestDepends: <<
autogen,
dejagnu,
( "%m" != "arm64" ) apple-gdb
<<
TestScript: <<
#!/bin/bash -ev
if [ "%m" = "arm64" ]; then
echo "The gcc testsuite requires Apple's gdb, which is not available on this architecture."
exit 0
elif [ $UID = 0 ]; then
if [ -e /usr/bin/csrutil && `csrutil status | grep -c disabled` ]; then
cd ../darwin_objdir; make -k check RUNTESTFLAGS="--target_board=unix'{-m64}'" || :
else
echo "The gcc testsuite must be run with SIP disabled or package installed."
exit 0
fi
else
echo "The gcc testsuite must be run as root due to its use of gdb."
exit 0
fi
<<
<<
InfoDocs: gcc.info gfortran.info cpp.info gccinstall.info libgomp.info cppinternals.info gccint.info
CompileScript: <<
#!/bin/bash -ev
set +x
if [ -e /usr/local/lib/libgmp.a ] || [ -e /usr/local/lib/libgmp.dylib ]; then
echo "-----WARNING-----WARNING-----WARNING-----"
echo "You seem to have GMP installed in /usr/local."
echo "This is known to cause %N to fail to build."
echo "Please move aside /usr/local and try again."
echo "-----WARNING-----WARNING-----WARNING-----"
exit 1
else
echo "Good, /usr/local/lib/libgmp* not present."
fi
set -x
ulimit -s `ulimit -s`
mkdir ../darwin_objdir
cd ../darwin_objdir
# build doesn't play well with GNU-make
# unsupported option '-static-libgcc'
export MAKE=/usr/bin/make
# Only need sysroot on 10.14+ because /usr/include has been removed
OSX_MAJOR_VERSION=`sw_vers -productVersion | cut -d. -f1-2`
if dpkg --compare-versions "$OSX_MAJOR_VERSION" ge "10.14"; then
# Get the unversioned SDK path
SDK_PATH=`dirname $(xcrun --sdk macosx --show-sdk-path)`/MacOSX.sdk
# This should really be --with-build-sysroot but that's not getting propagated through the entire build process.
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885
export USE_SYSROOT="--with-sysroot=${SDK_PATH}"
fi
# check for incompatible clang ( 6.0 << bad-clang << 7.2)
clangvers=`clang --version | cut -d\ -f4`
$(`dpkg --compare-versions $clangvers '>>' 6.0`) && $(`dpkg --compare-versions $clangvers '<<' 7.2`) && clangcheck='y'
if [ "$clangcheck" = "y" ]; then
../gcc-%v/configure %c --with-build-config=bootstrap-debug
else
../gcc-%v/configure %c
fi
# Use bootstrap-lean to reduce disk usage.
# Note that this causes plugin testsuite failures
# since the plugin headers must come from prev-gcc.
# make bootstrap-lean
make bootstrap
fink-package-precedence --prohibit-bdep=%n .
<<
InstallScript: <<
#!/bin/sh -ev
darwinvers=`uname -r`
cd ../darwin_objdir
make -j 1 install DESTDIR=%d
mkdir -p %i/bin

# Add symlinks to recreate previous naming of executables in %p/bin
# as well as %p/lib/gcc%type_num[gccver]/bin and new -fsf-%type_num[gccver] naming in %p/bin.
binfiles="gcc g++ c++ cpp gcov"
for binfile in $binfiles ; do
ln -s %p/lib/gcc%type_num[gccver]/bin/$binfile-fsf-%type_num[gccver] %i/lib/gcc%type_num[gccver]/bin/$binfile-%type_num[gccver]
ln -s %p/lib/gcc%type_num[gccver]/bin/$binfile-fsf-%type_num[gccver] %i/bin/$binfile-%type_num[gccver]
ln -s %p/lib/gcc%type_num[gccver]/bin/$binfile-fsf-%type_num[gccver] %i/bin/$binfile-fsf-%type_num[gccver]
done
binfiles="gfortran"
for binfile in $binfiles ; do
ln -s %p/lib/gcc%type_num[gccver]/bin/$binfile-fsf-%type_num[gccver] %i/lib/gcc%type_num[gccver]/bin/$binfile
ln -s %p/lib/gcc%type_num[gccver]/bin/$binfile-fsf-%type_num[gccver] %i/bin/$binfile
ln -s %p/lib/gcc%type_num[gccver]/bin/$binfile-fsf-%type_num[gccver] %i/bin/$binfile-fsf-%type_num[gccver]
done

# Remove unsupported executables
binfiles="gcc-ar gcc-nm gcc-ranlib"
for binfile in $binfiles ; do
rm -f %i/lib/gcc%type_num[gccver]/bin/$binfile-fsf-%type_num[gccver] %i/lib/gcc%type_num[gccver]/bin/*-apple-darwin${darwinvers}-$binfile-fsf-%type_num[gccver]
done

# Add symlinks for manpages under old names.
man1files="cpp g++ gcc gcov"
for man1file in $man1files ; do
ln -s $man1file-fsf-%type_num[gccver].1 %i/share/man/man1/$man1file-%type_num[gccver].1
done
man1files="gfortran"
for man1file in $man1files ; do
ln -s $man1file-fsf-%type_num[gccver].1 %i/share/man/man1/$man1file.1
done

# Rename manpages with -fsf-%type_num[gccver] suffix and create symlinks to old names.
man7files="fsf-funding gfdl gpl"
for man7file in $man7files ; do
mv %i/share/man/man7/$man7file.7 %i/share/man/man7/$man7file-fsf-%type_num[gccver].7
ln -s $man7file-fsf-%type_num[gccver].7 %i/share/man/man7/$man7file.7
done

# Add dir for installed info files, and link them to %i/share/info.
# the %i/lib/gcc%type_num[gccver]/info/* files will go into the -compiler package
# and the files in %i/share/info go into the main package, this allows
# the info files for specific compiler versions to be accessed with
# e.g. `info -d /fink_install_dir/lib/gcc%type_num[gccver]/info gcc', but the "main" info files will
# be available for the install gccXX package in %p/share/info, as usual
install -d -m 755 %i/share/info
for infofile in $(find %i/lib/gcc%type_num[gccver]/info -name '*.info*'); do
infobase=$(basename $infofile)
case $infofile in
*info) %p/bin/install-info --infodir=%i/lib/gcc%type_num[gccver]/info ${infofile} ;;
esac
ln -s %p/lib/gcc%type_num[gccver]/info/$infobase %i/share/info/$infobase
done

# remove build path from .la files
perl -pi -e "s, \-L[^ ']*/%n-%v-%r/darwin_objdir/[^ ']*,,g" `find %i/lib/gcc%type_num[gccver]/lib -name '*.la'`

if [ "%m" = "arm64" ]; then
arch=aarch64
else
arch=%m
fi

# @rpath install_names are required for aarch64 build, but break some linked binaries
# - enforce actual install paths here; take care to update the cross-referenced dylibs.
cd %d
for dylib in .%p/lib/gcc%type_num[gccver]/lib/lib*.[0-9].dylib; do
install_name_tool -id ${dylib#.} $dylib
install_name_tool -change @rpath/libgcc_s.1.1.dylib %p/lib/gcc%type_num[gccver]/lib/libgcc_s.1.1.dylib \
-change @rpath/libstdc++.6.dylib %p/lib/gcc%type_num[gccver]/lib/libstdc++.6.dylib \
-change @rpath/libquadmath.0.dylib %p/lib/gcc%type_num[gccver]/lib/libquadmath.0.dylib $dylib
done
otool -L .%p/lib/gcc%type_num[gccver]/lib/lib*.[0-9].dylib | grep '@rpath' && exit 2

cp %b/gcc/config/darwin-sections.def %i/lib/gcc%type_num[gccver]/lib/gcc/${arch}-apple-darwin${darwinvers}/%v/plugin/include/config
<<
SplitOff: <<
Package: %N-shlibs
Replaces: <<
gcc4 (<= 20050130-4),
gfortran-shlibs
<<
Provides: <<
gfortran-shlibs
<<
Description: Shared libraries for %N
DocFiles: gcc/COPYING gcc/COPYING.LIB
Files: <<
lib/gcc%type_num[gccver]/lib/libgfortran.5*.dylib
lib/gcc%type_num[gccver]/lib/libstdc++.6*.dylib
lib/gcc%type_num[gccver]/lib/libgcc_s.1*.dylib
lib/gcc%type_num[gccver]/lib/libitm.1*.dylib
lib/gcc%type_num[gccver]/lib/libssp.0*.dylib
lib/gcc%type_num[gccver]/lib/libobjc-gnu.4*.dylib
lib/gcc%type_num[gccver]/lib/libgomp.1*.dylib
lib/gcc%type_num[gccver]/lib/libquadmath.0*.dylib
lib/gcc%type_num[gccver]/lib/libatomic.1*.dylib
<<
Shlibs: <<
%p/lib/gcc%type_num[gccver]/lib/libgfortran.5.dylib 6.0.0 %n (>= 11.0.0-1)
%p/lib/gcc%type_num[gccver]/lib/libstdc++.6.dylib 7.0.0 %n (>= 11.0.0-1)
( "%m" = "arm64" ) %p/lib/gcc%type_num[gccver]/lib/libgcc_s.1.1.dylib 1.0.0 %n (>= 11.0.0-1)
( "%m" != "arm64" ) %p/lib/gcc%type_num[gccver]/lib/libgcc_s.1.dylib 1.0.0 %n (>= 11.0.0-1)
( "%m" != "arm64" ) !%p/lib/gcc%type_num[gccver]/lib/libgcc_s.1.1.dylib
%p/lib/gcc%type_num[gccver]/lib/libitm.1.dylib 2.0.0 %n (>= 11.0.0-1)
%p/lib/gcc%type_num[gccver]/lib/libssp.0.dylib 1.0.0 %n (>= 11.0.0-1)
%p/lib/gcc%type_num[gccver]/lib/libobjc-gnu.4.dylib 5.0.0 %n (>= 11.0.0-1)
%p/lib/gcc%type_num[gccver]/lib/libgomp.1.dylib 2.0.0 %n (>= 11.0.0-1)
%p/lib/gcc%type_num[gccver]/lib/libquadmath.0.dylib 1.0.0 %n (>= 11.0.0-1)
%p/lib/gcc%type_num[gccver]/lib/libatomic.1.dylib 4.0.0 %n (>= 11.0.0-1)
<<
<<
SplitOff2: <<
Package: %N-compiler
Depends: <<
gmp5-shlibs (>= 6.0.0a-3),
isl22-shlibs,
libgettext8-shlibs,
libgmpxx5-shlibs (>= 6.0.0a-3),
libiconv,
libmpc3-shlibs (>= 1.0.3-1),
libmpfr6-shlibs,
%N-shlibs (= %v-%r)
<<
BuildDependsOnly: False
Description: Compiler Binaries for gcc%type_num[gccver]
DocFiles: gcc/COPYING gcc/COPYING.LIB gcc/ChangeLog gcc/ABOUT-GCC-NLS gcc/README.Portability
Files: <<
bin/*-fsf-%type_num[gccver]
lib/gcc%type_num[gccver]
share/man/man1/*-fsf-%type_num[gccver].1
share/man/man7/*-fsf-%type_num[gccver].7
<<
<<
License: GPL
Description: GNU Compiler Collection Version %type_num[gccver]
DescDetail: <<
GCC, the GNU Compiler Collection, includes front ends for
C, C++, Objective-C, Objective-C++, Fortran and Ada.
.
C, C++, Objective C and Fortran are included in this package.
.
The C and C++ compilers are named gcc-11 and g++-11 to avoid
conflicts with gcc and g++ installed by the Apple Developer Tools.
<<
DescPackaging: <<
Build with -fsf-%type_num[gccver] suffix and place non-overlapping files into new gcc%type_num[gccver]-compiler
package which can co-exist with other gccXX-compiler packages. Overlapping files
are left in main gcc%type_num[gccver] package which still conflicts with other gccXX packages.

macOS10.14 no longer supports building 32bit libraries, so must disable multilib.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87030

We use --with-sysroot to find the hidden system-headers in case /usr/include is not
populated. Ideally want --with-build-sysroot because we only need the headers to build
gcc and that should not impact the end product, but then anything using gccX will
need to add it's own -isysroot flag.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885

Homebrew patches for arm64/aarch64 build and macOS 13 from
https://github.com/Homebrew/formula-patches/blob/master/gcc/gcc-%v.diff
- libasan.* and libsubsan.* currently not built on darwin22+ - see
https://github.com/iains/gcc-darwin-arm64/commit/e722a1f4
and missing from the 13.0 package until resolved.
There are both "1" and "1.1" versions of libgcc_s.dylib now, but only "1" on arm64.
Manual fixes of @rpath install_names required for aarch64 build to maintain downstream
package compatibility.
<<
Homepage: http://gcc.gnu.org/
Maintainer: None <[email protected]>
<<
Loading

0 comments on commit 920724f

Please sign in to comment.