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.
 * Fedora Package Sources https://src.fedoraproject.org/rpms/cernlib
 * Posledny udrziavany balik CERNLIB bol v Fedore 14 cernlib-2006-35.fc14.src.rpm
 * Tento CERNLIB balik je stale pritomny v Koji Fedora 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 gfortran-om (a nie g77).

Build CERNLIB in Fedora
$ dnf builddep cernlib-2006-35.fc14.src.rpm $ # rpmbuild --rebuild cernlib-2006-35.fc14.src.rpm  # for RPM version < 4.12 $ rpmbuild -ra cernlib-2006-35.fc14.src.rpm $ cp -p $HOME/rpmbuild/SPECS/cernlib.spec $HOME/rpmbuild/SPECS/cernlib.spec.orig
 * Fedora 29 (x86_64), GNU Fortran and 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 slashes (char ). Riesenie je pouzit alternativny regex delimiter, t.j. namiesto pouzit napr. . V principe prikaz  umoznuje pouzit lubovolny char ako delimeter, separator (pozor, aby sa ten "novy" seprator char nevyskytoval vo vyraze, ktory pouziva premennu, co je prave tento problem).
 * 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 918 a 919 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
 * zamiena (po patch-ovani) na options pre kompilaciu definovane pomocou makra

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, tato funkcia sa celkovo vyskytuje v 12 suboroch.
 * The GNU C Library version 2.25 (glibc-2.25, 2017-02) added, among other things, function.
 * 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 prikazom v subore
 * Fedora pouziva pri build-ovani option (from )
 * 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

previous Fedora
Testing geant321 ... using exam1 $ rpm --eval %{optflags} -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
 * Fedora 25 (my old PC), 2017-03 gcc asi 6.4
 * Fedora 26 (strela205), 2019-04 gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
 * Fedora 27 (strela07), 2019-04 gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6)
 * 1) exam1 doesn't terminate
 * Problem s, ktory je sucastou testing geant321. Program sa nezakoncuje. Tento problem je aj s dalsimi programami (from testing geant321) . Vo Fedore 29 (gcc 8.3.1) tento problem uz nie je, Fedoru 28 nemam kde testovat.
 * S najvacsou pravdepodobnostou je to ten isty problem ako Feb 03, 2019: CERNLIB 2006 on newer Linux systems. Until a proper fix is found, one needs to make sure that all FORTRAN code is compiled with "-O" (i.e. "-O1") and not with the default "-O3" (even "-O2" results in misbehavior). Patch pre Debian cernlib-20061220+dfsg3.patches.2019.02.03.txt
 * v Fedore pouziva default options pre kompilaciu definovane pomocou makra  a nie ako v Debian default
 * 1) Fedora 26, gcc (GCC) 7.3.1

$ 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
 * Zamena na  tento problem riesi a vsetky  programy (from testing geant321) v Fedora 26 uspesne zbehnu


 * Stale vsak nie je jasne v com je problem (mozno gcc, mozno cernlib) ?!
 * Teoreticky mozno vykomentovat v subore  a teda testing programs  sa ani nebudu spustat. Samotna kompilacia CERNLIB prejde uspesne a baliky sa z-build-uju. V kazdom pripade to nie je riesenie, kedze zostava moznost, ze potom ani vlastne programy (kompilovane s CERNLIB) nebudu fungovat korektne.

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 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 )

$ 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 $ rpm -q --queryformat "%{OPTFLAGS}\n" cernlib-2006-35.fc25.x86_64.rpm -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
 * Z rpm balika mozeme ziskat (dopytat sa ho ) mnozstvo tag-ov, informacie (more info in )

$ 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
 * 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 $ rpmbuild --showrc | grep optflags $ 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.

$ rpmbuild -ba --define "optflags -O" $HOME/rpmbuild/SPECS/cernlib.spec $ rpmbuild --define "optflags -ABC" --showrc | grep optflags $ rpm --define "optflags -XYZ" --eval %{optflags}
 * https://docs.fedoraproject.org/en-US/packaging-guidelines/
 * https://rpm-packaging-guide.github.io/
 * Using and  (macro style) vs  and  (variable style). V principe je jedno, ktory styl pouzit, ale netreba ich navzajom miesat.
 * others

%define optflags my_super_opt %global optflags %{optflags} -dalsi
 * override optflags spec
 * https://www.altlinux.org/Spec/%D0%9F%D1%80%D0%B5%D0%B4%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%BD%D1%8B%D0%B5_%D0%BC%D0%B0%D0%BA%D1%80%D0%BE%D1%81%D1%8B
 * https://lists.fedoraproject.org/pipermail/devel/2015-September/214479.html

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