# Workaround LTO related issue when stripping the target files # See related issue for cross-gcc: #1863378 %global __brp_strip_lto %{nil} Name: fpcross Version: 3.3.1 Release: 1%{?dist} Summary: Free Pascal Compiler License: GPLv2+ and LGPLv2+ with exceptions URL: http://www.freepascal.org/ %global build_commit 74b6e69e21160195ec68d2877f260ba17917cd4b %global fpc_commit 3cea1706e9208fb739b0482519fe48420ca520ea %global docs_commit 770f75016ce748397b76f15eb53dfb3910b3f569 Source0: https://gitlab.com/freepascal.org/fpc/build/-/archive/%{build_commit}/build-%{build_commit}.tar.gz Source1: https://gitlab.com/freepascal.org/fpc/source/-/archive/%{fpc_commit}/source-%{fpc_commit}.tar.gz Source2: https://gitlab.com/freepascal.org/fpc/documentation/-/archive/%{docs_commit}/documentation-%{docs_commit}.tar.gz # On Fedora we do not want stabs debug-information. (even on 32 bit platforms) # https://bugzilla.redhat.com/show_bug.cgi?id=1475223 Patch0: fpc-3.3.0--dwarf-debug.patch # Allow for reproducible builds # https://bugzilla.redhat.com/show_bug.cgi?id=1778875 Patch1: fpc-3.2.0--honor_SOURCE_DATE_EPOCH_in_date.patch # Upstream assumes /usr/lib/ for aarch64, but Fedora uses /usr/lib64/ # Patch2: fpc-3.2.0--fix-lib-paths-on-aarch64.patch # Update for new glibc >= 2.34 # RHBZ bug: https://bugzilla.redhat.com/show_bug.cgi?id=2005910 # Upstream bug: https://gitlab.com/freepascal.org/fpc/source/-/issues/39295 # Patch3: fpc-3.2.2--glibc-2.34.patch # Fix missing TOC loads on ppc64le. A backport of upstream commits: # - https://gitlab.com/freepascal.org/fpc/source/-/commit/12f48c230bccd49f368be1e5a2855cb6c3a60c0f # - https://gitlab.com/freepascal.org/fpc/source/-/commit/9314bbbf080418827eef94a8bc392ce0497bf72b # - https://gitlab.com/freepascal.org/fpc/source/-/commit/2de72c854115908271912cd9b260a607c826eadb # - https://gitlab.com/freepascal.org/fpc/source/-/commit/83c18df69a79fe1035a0cf0bc0897c60d1af0293 # - https://gitlab.com/freepascal.org/fpc/source/-/commit/68b5ca633ca71a83c29b78cd3669bf15477cd94f # Some modifications were made to make the changes apply cleanly to v3.2.2. # Upstream bug report: https://gitlab.com/freepascal.org/fpc/source/-/issues/39542 # Patch4: fpc-3.2.2--ppc64le-toc-fixes.patch # The "pas2jni" util program shipped with FPC uses threads, # but is compiled without thread support and fails to actually do anything useful when run. # Submitted upstream: https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/185 # Patch5: fpc-3.2.2--pas2jni-cthreads.patch # Macros for enabling/disabling support for particular architectures %ifnarch %{arm} %global build_arm 1 %else %global build_arm 0 %endif %ifnarch aarch64 %global build_aarch64 1 %else %global build_aarch64 0 %endif %ifnarch ppc64le %global build_ppc64le 1 %else %global build_ppc64le 0 %endif %ifnarch x86_64 %global build_x86_64 1 %else %global build_x86_64 0 %endif # FPC requires support for 80-bit floats ("long double" in C) for cross-compilation to i386. # Out of our supported architectures - arm, aarch64, ppc64le, x86_64 - only x86_64 supports this. %ifarch x86_64 %global build_i386 1 %else %global build_i386 0 %endif # Units for MS Windows %ifnarch %{ix86} %global build_win32 %{build_i386} %else %global build_win32 1 %endif %ifnarch x86_64 %global build_win64 %{build_x86_64} %else %global build_win64 1 %endif BuildRequires: fpc%{?_isa} = %{version} BuildRequires: glibc-devel BuildRequires: make %if %{build_arm} BuildRequires: binutils-arm-linux-gnu %endif %if %{build_aarch64} BuildRequires: binutils-aarch64-linux-gnu %endif %if %{build_ppc64le} BuildRequires: binutils-powerpc64le-linux-gnu %endif %if %{build_i386}%{build_x86_64} BuildRequires: binutils-x86_64-linux-gnu %endif ExclusiveArch: %{arm} aarch64 %{ix86} x86_64 ppc64le %description Free Pascal is a free 32/64bit Pascal Compiler. It comes with a run-time library and is fully compatible with Turbo Pascal 7.0 and nearly Delphi compatible. Some extensions are added to the language, like function overloading and generics. Shared libraries can be linked. This package contains the command-line compiler and utilities. Provided units are the runtime library (RTL), free component library (FCL) and packages. # -- i386 %if %{build_i386} %package i386 Summary: Free Pascal Compiler - i386 cross-compilation support Requires: fpc%{?_isa} = %{version} %ifnarch %{ix86} Requires: binutils-x86_64-linux-gnu %endif %description i386 This package contains the files required for FPC to compile code for the i386 processor architecture. %endif %if %{build_win32} %package win32 Summary: Free Pascal Compiler - win32 cross-compilation support %ifnarch %{ix86} Requires: %{name}-i386%{?isa} = %{version}-%{release} %else Requires: fpc%{?isa} = %{version} %endif %description win32 This package contains the files required for FPC to compile code for the Microsoft Windows operating system (32-bit version). %endif # -- x86_64 %if %{build_x86_64} %package x86_64 Summary: Free Pascal Compiler - x86_64 cross-compilation support Requires: fpc%{?_isa} = %{version} %ifnarch x86_64 Requires: binutils-x86_64-linux-gnu %endif %description x86_64 This package contains the files required for FPC to compile code for the x86_64 processor architecture. %endif %if %{build_win64} %package win64 Summary: Free Pascal Compiler - win64 cross-compilation support %ifnarch x86_64 Requires: %{name}-x86_64%{?isa} = %{version}-%{release} %else Requires: fpc%{?isa} = %{version} %endif %description win64 This package contains the files required for FPC to compile code for the Microsoft Windows operating system (64-bit version). %endif # -- arm %if %{build_arm} %package arm Summary: Free Pascal Compiler - arm cross-compilation support Requires: fpc%{?_isa} = %{version} %ifnarch %{arm} Requires: binutils-arm-linux-gnu %endif %description arm This package contains the files required for FPC to compile code for the ARM processor architecture. %endif # -- aarch64 %if %{build_aarch64} %package aarch64 Summary: Free Pascal Compiler - aarch64 cross-compilation support Requires: fpc%{?_isa} = %{version} %ifnarch aarch64 Requires: binutils-aarch64-linux-gnu %endif %description aarch64 This package contains the files required for FPC to compile code for the aarch64 (ARM 64-bit) processor architecture. %endif # -- ppc64le %if %{build_ppc64le} %package ppc64le Summary: Free Pascal Compiler - ppc64le cross-compilation support Requires: fpc%{?_isa} = %{version} %ifnarch ppc64le Requires: binutils-powerpc64le-linux-gnu %endif %description ppc64le This package contains the files required for FPC to compile code for the PowerPC 64-bit Little Endian processor architecture. %endif # -- targets end %global smart _smart %global fpcopt -g -gl -gw -k"--build-id" %global fpmakeopt %{?_smp_build_ncpus:FPMAKEOPT='-T %{_smp_build_ncpus} --NoIDE=1'} %global targets %{expand: %if %{build_arm} arm-compiler arm-linux %endif %if %{build_aarch64} aarch64-compiler aarch64-linux %endif %if %{build_ppc64le} ppc64le-compiler ppc64le-linux %endif %if %{build_i386} i386-compiler i386-linux %endif %if %{build_win32} i386-win32 %endif %if %{build_x86_64} x86_64-compiler x86_64-linux %endif %if %{build_win64} x86_64-win64 %endif } %prep %setup -n build-%{build_commit} -q tar xzf %{SOURCE1} rmdir fpcsrc mv "source-%{fpc_commit}" fpcsrc tar xzf %{SOURCE2} rmdir fpcdocs mv "documentation-%{docs_commit}" fpcdocs pushd fpcsrc %patch0 -p1 %patch1 # %%patch2 # %%patch3 -p1 # %%patch4 -p2 # %%patch5 -p1 popd mkdir __vars/ cat > __vars/arm.sh << EOF CROSS_ARCH="arm" CROSS_BUPX="arm-linux-gnu-" CROSS_NAME="ppcrossarm" CROSS_OPTS='%{fpcopt} -dCROSS_ARMHF' EOF cat > __vars/aarch64.sh << EOF CROSS_ARCH="aarch64" CROSS_BUPX="aarch64-linux-gnu-" CROSS_NAME="ppcrossa64" CROSS_OPTS='%{fpcopt}' EOF cat > __vars/ppc64le.sh << EOF CROSS_ARCH="powerpc64" CROSS_BUPX="powerpc64le-linux-gnu-" CROSS_NAME="ppcrossppc64" CROSS_OPTS='%{fpcopt} -Cb- -Caelfv2' EOF cat > __vars/x86_64.sh << EOF CROSS_ARCH="x86_64" CROSS_BUPX="x86_64-linux-gnu-" CROSS_NAME="ppcrossx64" CROSS_OPTS='%{fpcopt}' EOF cat > __vars/i386.sh << EOF CROSS_ARCH="i386" CROSS_BUPX="x86_64-linux-gnu-" # Not a mistake, we want x86_64 bintuils here CROSS_NAME="ppcross386" CROSS_OPTS='%{fpcopt}' EOF %build FPC_ARCH="$(fpc -iSP)" TARGETS=(%{targets}) for TARGET in ${TARGETS[@]}; do TARGET_ARCH="${TARGET%%-*}" TARGET_OS="${TARGET##*-}" source "__vars/${TARGET_ARCH}.sh" pushd fpcsrc if [[ "${TARGET_OS}" == "compiler" ]]; then make %{?_smp_mflags} compiler_cycle OPT="%{fpcopt}" CPU_TARGET="${CROSS_ARCH}" CROSSOPT="${CROSS_OPTS}" BINUTILSPREFIX="${CROSS_BUPX}" else if [[ "${CROSS_ARCH}" != "${FPC_ARCH}" ]]; then PPCROSS="$(pwd)/compiler/${CROSS_NAME}" make %{fpmakeopt} \ rtl_clean rtl%{smart} packages%{smart} \ FPC="${PPCROSS}" \ CPU_TARGET="${CROSS_ARCH}" \ CROSSOPT="${CROSS_OPTS}" \ BINUTILSPREFIX="${CROSS_BUPX}" \ OS_TARGET="${TARGET_OS}" else make %{fpmakeopt} \ rtl_clean rtl%{smart} packages%{smart} \ OPT="%{fpcopt}" \ OS_TARGET="${TARGET_OS}" fi fi popd done %install FPC_ARCH="$(fpc -iSP)" TARGETS=(%{targets}) for TARGET in ${TARGETS[@]}; do TARGET_ARCH="${TARGET%%-*}" TARGET_OS="${TARGET##*-}" source "__vars/${TARGET_ARCH}.sh" if [[ "${TARGET_OS}" == "compiler" ]]; then MAKE_TARGETS="compiler_distinstall" INSTALL_FPC="FPC=$(pwd)/fpcsrc/compiler/${CROSS_NAME}" INSTALL_OS_TARGET="" else MAKE_TARGETS="rtl_distinstall packages_distinstall" INSTALL_FPC="" INSTALL_OS_TARGET="OS_TARGET=${TARGET_OS}" fi if [[ "${CROSS_ARCH}" != "${FPC_ARCH}" ]]; then INSTALL_BINUTILSPREFIX="BINUTILSPREFIX=${CROSS_BUPX}" INSTALL_CROSSINSTALL="CROSSINSTALL=1" else INSTALL_BINUTILSPREFIX="" INSTALL_CROSSINSTALL="" fi pushd fpcsrc make ${MAKE_TARGETS} \ ${INSTALL_FPC} \ ${INSTALL_OS_TARGET} \ ${INSTALL_BINUTILSPREFIX} \ ${INSTALL_CROSSINSTALL} \ INSTALL_PREFIX="%{buildroot}%{_prefix}" \ INSTALL_LIBDIR="%{buildroot}%{_libdir}" \ INSTALL_BASEDIR="%{buildroot}%{_libdir}/fpc/%{version}" \ INSTALL_BINDIR="%{buildroot}%{_bindir}" \ INSTALL_DOCDIR="%{buildroot}%{_defaultdocdir}/%{name}" \ INSTALL_EXAMPLEDIR="%{buildroot}%{_defaultdocdir}/%{name}/examples" \ CPU_TARGET="${CROSS_ARCH}" \ %{fpmakeopt} popd if [[ "${TARGET_OS}" == "compiler" ]]; then # Symlink the executable mkdir -p %{buildroot}%{_bindir} ln -sf "../%{_lib}/fpc/%{version}/${CROSS_NAME}" "%{buildroot}%{_bindir}/${CROSS_NAME}" fi done # We don't want to install the documentation, but calling "make compiler_distinstall" # does that for us, anyway. Remove any installed documentation files. # The user should install "fpc-doc" instead. rm -rf %{buildroot}%{_defaultdocdir} %files # -- i386 %if %{build_i386} %files i386 %{_bindir}/ppcross386 %{_libdir}/fpc/%{version}/ppcross386 %{_libdir}/fpc/%{version}/fpmkinst/i386-linux %{_libdir}/fpc/%{version}/units/i386-linux %endif # -- win32 %if %{build_win32} %files win32 %{_libdir}/fpc/%{version}/fpmkinst/i386-win32 %{_libdir}/fpc/%{version}/units/i386-win32 %endif # -- x86_64 %if %{build_x86_64} %files x86_64 %{_bindir}/ppcrossx64 %{_libdir}/fpc/%{version}/ppcrossx64 %{_libdir}/fpc/%{version}/fpmkinst/x86_64-linux %{_libdir}/fpc/%{version}/units/x86_64-linux %endif %if %{build_win64} %files win64 %{_libdir}/fpc/%{version}/fpmkinst/x86_64-win64 %{_libdir}/fpc/%{version}/units/x86_64-win64 %endif # -- arm %if %{build_arm} %files arm %{_bindir}/ppcrossarm %{_libdir}/fpc/%{version}/ppcrossarm %{_libdir}/fpc/%{version}/fpmkinst/arm-linux %{_libdir}/fpc/%{version}/units/arm-linux %endif # -- aarch64 %if %{build_aarch64} %files aarch64 %{_bindir}/ppcrossa64 %{_libdir}/fpc/%{version}/ppcrossa64 %{_libdir}/fpc/%{version}/fpmkinst/aarch64-linux %{_libdir}/fpc/%{version}/units/aarch64-linux %endif # -- ppc64le %if %{build_ppc64le} %files ppc64le %{_bindir}/ppcrossppc64 %{_libdir}/fpc/%{version}/ppcrossppc64 %{_libdir}/fpc/%{version}/fpmkinst/powerpc64-linux %{_libdir}/fpc/%{version}/units/powerpc64-linux %endif %changelog * Mon Jan 09 2023 Artur Frenszek-Iwicki - 3.3.1-1 - Update to latest git snapshot * Thu Dec 15 2022 Artur Frenszek-Iwicki - 3.2.2-3 - Disable building & installing the textmode IDE * Tue Dec 13 2022 Artur Frenszek-Iwicki - 3.2.2-2 - Add building MS Windows units * Mon Dec 12 2022 Artur Frenszek-Iwicki - 3.2.2-1 - Initial packaging (based on fpc.spec)