CERNLIB

CERNLIB in Fedora

 * CERN Program Library
 * http://cernlib.web.cern.ch/cernlib/
 * https://www-zeuthen.desy.de/linear_collider/cernlib/new/cernlib_2005.html

-rw-rw-r-- 1 musinsky musinsky 28974483 2010-05-05 20:29:33 cernlib-2006-35.fc14.src.rpm -rw-r--r-- 1 musinsky musinsky   59057 2010-05-05 18:46:36 cernlib.spec %changelog * Wed May 05 2010 Jon Ciesla  2006-35 - Apply debian cernlib 2006.dfsg.2-14 patchset.
 * Posledny udrziavany balik CERNLIB bol v Fedore 14 cernlib-2006-35.fc14.src.rpm
 * Tento CERNLIB balik je stale pritomny v Koji RPM building and tracking system
 * https://kojipkgs.fedoraproject.org/packages/cernlib/2006/35.fc14/src/cernlib-2006-35.fc14.src.rpm
 * Source rpm baliky (koji a archive) su absolutne identicke, minimalny rozdiel vo velkosti je sposobeny inymi casmi build-ovania (a teda ina Signature vnutri balika). Fungujem dalej s Koji source rpm balikom.
 * Original subor a posledny  v nom
 * Fedora balik pouziva pre-patch-ovanu verziu CERNLIB 2006 z Debian distribucie (aka new Debian's cernlib) s poslednym patchset-om . Balik sa build-uje s gfotran-om (a nie g77).

Build CERNLIB in Fedora
$ dnf builddep cernlib-2006-35.fc14.src.rpm $ rpmbuild -ra cernlib-2006-35.fc14.src.rpm  # for RPM version < 4.12 => $ rpmbuild --rebuild cernlib-2006-35.fc14.src.rpm $ cp -p $HOME/rpmbuild/SPECS/cernlib.spec $HOME/rpmbuild/SPECS/cernlib.spec.orig
 * Fedora 29, GNU Fortran a gcc(GCC) 8.3.1 20190223
 * Instalacia zavislosti (ako root)
 * Zaciname s build-ovanim cernlib (dalej vsetko ako user)
 * 1) many errors
 * Vsetky subory su teraz v vratane  (definovane pomocou  makier, resp. )
 * Zaciname build-ovat a postupne patch-ovat spec file

error01
$ rm -rf $HOME/rpmbuild/BUILD/; rpmbuild -ba $HOME/rpmbuild/SPECS/cernlib.spec

+ sed -i.optflags -e 's/FOPT \+=.*/FOPT = "-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection"/' -e 's/COPT \+=.*/COPT = "-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE"/' p4boot.sh sed: -e expression #1, char 183: unknown option to `s'
 * Nekorektna zamena a  parametrov v subore
 * vo vyraze pouziva premenu, ktora obsahuje slash(es) (char / ), riesenie je pouzit alternativny regex delimiter, t.j. namiesto pouzit
 * edit lines 918, 919

error02
$ rm -rf $HOME/rpmbuild/BUILD/; rpmbuild -ba $HOME/rpmbuild/SPECS/cernlib.spec

gfortran -c -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -m-cypatch.f gfortran: fatal error: no input files Fortran   name : gfortran Fortran options : -c -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -m-c CC   name : cc             CC options : -c -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -m
 * Chybne generovanie Fortran a CC options programom
 * Su to presne tie options, ktore boli zamenene (uz korektne) pri rieseni predchadzajuceho problemu error01
 * Tieto options su zjavne "umelo useknute", co je sposobene malou hodnotou velkosti parametra pola v subore  (dlzka options string je cca 350 znakov)
 * add line 920

!!! POZOR !!! teoreticky mozno obidva riadky s prikazom zakomentovat. Vyriesi sa naraz error01 aj error02. Kompilacia prejde, ale bude s inymi options ako kompilacia ostatneho kodu. Options zo suboru set FOPT  = "-O2"                # Fortran compiler options set FOPTC = "-c $FOPT -posix" set COPT  = "-O2"                # C compiler options set COPTC =  "-c $COPT -posix" set FOPT = "-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection" set FOPTC = "-c $FOPT -posix" set COPT = "-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE" set COPTC =  "-c $COPT -posix"
 * default hodoty
 * zamiename na (po patch-ovani)

error03
$ rm -rf $HOME/rpmbuild/BUILD/; rpmbuild -ba $HOME/rpmbuild/SPECS/cernlib.spec

GFORTRAN  -c -o kuipcc.o /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/programs/kuipc/kuipcc.c In file included from /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/kuip/kuip.h:10, from /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/programs/kuipc/kuipcc.c:46: /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/kuip/kstring.h:77:14: error: conflicting types for 'strfromd' extern char* strfromd( double d, size_t prec ); ^~ In file included from /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/kuip/ksys.h:419, from /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/kuip/kuip.h:9, from /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/programs/kuipc/kuipcc.c:46: /usr/include/stdlib.h:212:12: note: previous declaration of 'strfromd' was here extern int strfromd (char *__dest, size_t __size, const char *__format,           ^~
 * Funkcia zo suboru  je v konflikte so standardnou glibc funkciou
 * add lines 945-958

error04
$ rm -rf $HOME/rpmbuild/BUILD/; rpmbuild -ba $HOME/rpmbuild/SPECS/cernlib.spec

GFORTRAN /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/code_kuip/kmenu.c -o archive/kmenu.o /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/code_kuip/kmenu.c: In function 'interactive_find': /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/code_kuip/kmenu.c:1070:20: warning: variable 'cmd0' set but not used [-Wunused-but-set-variable] KmCommand *cmd0, *cmd; ^ /home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/src/packlib/kuip/code_kuip/kmenu.c:1407:14: error: format not a string literal and no format arguments [-Werror=format-security] printf (flis_name[i]); ^
 * chybne formatovanie v subore
 * add lines 960-961 (see also)

error05
$ rm -rf $HOME/rpmbuild/BUILD/; rpmbuild -ba $HOME/rpmbuild/SPECS/cernlib.spec

gmake[2]: Leaving directory '/home/musinsky/rpmbuild/BUILD/cernlib-2006/2006/build/kernlib/umon' rebuild shared library libkernlib.so.1_gfortran.2006 in /kernlib Mon 29 Apr 21:05:27 MSK 2019 /usr/bin/ld: cannot find -lnsl collect2: error: ld returned 1 exit status

$ dnf list libnsl\*64 Installed Packages libnsl2.x86_64 Available Packages libnsl.x86_64         # legacy (not needed) libnsl2-devel.x86_64  # required this package
 * Nenainstalovana potrebna kniznica, hladam pomocou


 * add line 93

RPM
$ rpm --eval "default arch = %{_arch}" default arch = x86_64 $ rpm -E "system prefix = %{_prefix}"  # -E same as --eval system prefix = /usr $ rpm --eval %{optflags}  # Fedora 29 (x86_64) -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection $ rpm --eval %{optflags}  # Fedora 26 (x86_64) -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic $ rpm --querytags | grep -i flag  # list of all tags (and grep) $ rpm -q astyle astyle-3.1-6.fc29.x86_64 $ rpm -q --queryformat "name=%{NAME} ver=%{VERSION} rel=%{RELEASE} arch=%{ARCH}\n" astyle name=astyle ver=3.1 rel=6.fc29 arch=x86_64 $ rpm -q --queryformat "%{OPTFLAGS}\n" astyle -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection $ rpmspec -q --srpm $HOME/rpmbuild/SPECS/cernlib.spec cernlib-2006-35.fc29.x86_64 $ rpmspec -q --queryformat "%{OPTFLAGS}\n" $(rpm --eval %{_specdir})/cernlib.spec -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
 * RPM pouziva mnozstvo roznych macros, ktore sa vyuzivaju pri build-ovani
 * Macro Configuration subory su definovane na viacerych miestach, pripadne
 * rpmrc Configuration subory analogicky, alebo
 * For definitions of more macros, examine the output of . To see the expanded definition of a macro use the command (more info in )
 * Z rpm balika mozeme ziskat (dopytat sa ho ) mnozstvo tag-ov, informacie (more info in )
 * Analogicky pre spec file, is a tool for querying a spec file (more info in )

RPM build flags
$ rpm --eval %{__global_cflags} -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection $ rpm --eval %{configure} full complement of flags $ rpm --eval %{set_build_flags}  # fc29.x86_64 CFLAGS="${CFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection}" ; export CFLAGS ; CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection}" ; export CXXFLAGS ; FFLAGS="${FFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules}" ; export FFLAGS ; FCFLAGS="${FCFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules}" ; export FCFLAGS ; LDFLAGS="${LDFLAGS:--Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld}" ; export LDFLAGS
 * The macro contains flags that determine CFLAGS, CXXFLAGS, FFLAGS, etc. ( macro evaluates to the same string)


 * Using RPM build flags aktualne info pre Fedoru
 * for the C compiler flags (also known as the CFLAGS variable). Also historically available as . The environment variable is set to this value.
 * for the C++ compiler flags (usually assigned to the CXXFLAGS shell variable).
 * for the Fortran compiler flags (also known as FFLAGS or FCFLAGS variable).
 * for the link editor (ld) flags (usually known as LDFLAGS). Note that the contents quotes linker arguments using -Wl, so this variable is intended for use with the gcc compiler driver. The environment variable is set to this value.


 * https://docs.fedoraproject.org/en-US/packaging-guidelines/
 * Using and  (macro style) vs  and  (variable style). V principe je jedno, ktory styl pouzit, ale netreba ich navzajom miesat.

$ rpmbuild -ba --define "optflags -O" $HOME/rpmbuild/SPECS/cernlib.spec

ako prepisat macro primao v spec ?? optflags %_smp_mflags -j3    # to your ~/.rpmmacros

rm -rf $HOME/rpmbuild/BUILD/; rpmbuild -ba --define "optflags -O -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic" $HOME/rpmbuild/SPECS/cernlib.spec
 * preslo na strela205