# How to compile math/librsb with poudriere ?



## Alain De Vos (Oct 15, 2021)

Ignored ports,
Search:


#PackageOriginSkippedReason1librsb-1.2.0.10math/librsb2has to be built manually: Optimizes for the local machine


my make.conf

```
DISABLE_LICENSES=yes
MAKE_JOBS_UNSAFE=yes
BATCH=yes
CPUTYPE?=core-avx-i
MAKE_JOBS_NUMBER=20
CCACHE_DIR=/ccache
WITH_CCACHE_BUILD=yes
WITHOUT_MANCOMPRESS=YES
DEFAULT_VERSIONS+=ssl=openssl
DEFAULT_VERSIONS+=llvm=12
DEFAULT_VERSIONS+=gcc=10
DEFAULT_VERSIONS+=lua=5.4
DEFAULT_VERSIONS+=lua5=5.4
DEFAULT_VERSIONS+=perl=5.34
DEFAULT_VERSIONS+=perl5=5.34
DEFAULT_VERSIONS+=python=3.8
DEFAULT_VERSIONS+=python3=3.8
DEFAULT_VERSIONS+=ruby=2.7
DEFAULT_VERSIONS+=ruby2=2.7
DEFAULT_VERSIONS+=pgsql=13
DEFAULT_VERSIONS+=mysql=10.5m
DEFAULT_VERSIONS+=php=8.0
DEFAULT_VERSIONS+=tcltk=8.6
```


----------



## zirias@ (Oct 15, 2021)

Uncomment this setting in /usr/local/etc/poudriere.conf:

```
# By default poudriere sets PACKAGE_BUILDING
# To disable it:
# NO_PACKAGE_BUILDING=yes
```


----------



## Alain De Vos (Oct 15, 2021)

This is my poudriere.conf, i don't have that setting,

```
a:root: /pou #cat poudriere.conf 
FREEBSD_HOST=ftp://ftp.nl.freebsd.org
SVN_HOST=svn.FreeBSD.org
ZPOOL=ZT
ZROOTFS=/jails/a/apou
BASEFS=/
POUDRIERE_DATA=/data
CCACHE_DIR=/ccache
RESOLV_CONF=/etc/resolv.conf
DISTFILES_CACHE=/usr/ports/distfiles
URL_BASE="http://127.0.0.1/"
HTML_TRACK_REMAINING=yes
HTML_TYPE="hosted"
WRKDIR_ARCHIVE_FORMAT=tar
USE_TMPFS=no
CHECK_CHANGED_DEPS=yes
CHECK_CHANGED_OPTIONS=verbose
COMMIT_PACKAGES_ON_FAILURE=no
NOLINUX=yes
TIMESTAMP_LOGS=yes
USE_COLORS=yes
USE_PORTLINT=no
PARALLEL_JOBS=5
PREPARE_PARALLEL_JOBS=16
ALLOW_MAKE_JOBS=yes
COMMIT_PACKAGES_ON_FAILURE=yes
```


----------



## zirias@ (Oct 15, 2021)

Then add it? 

And btw, be sure to understand the consequence. You will get a package optimized for the machine it is built on. It might not work at all on a machine with a different CPU.


----------



## SirDice (Oct 15, 2021)

For a long time math/openblas had a similar problem. But that has a DYNAMIC option you can switch on. Unfortunately math/librsb doesn't seem to have that. So you can end up with a package that simply doesn't work on another system that has a different CPU type than your build machine.


----------



## zirias@ (Oct 15, 2021)

SirDice said:


> But that has a DYNAMIC option you can switch on. Unfortunately math/librsb doesn't seem to have that.


Being curious whether something like this could be added more or less easily, I noticed there seems to be something like a re-rolled distfile as well? Every SF mirror results in `size mismatch: expected 2396127, actual 2396145`.

Guess I'll have to recreate distinfo first 

Ok, did that and now I'm confused, `./configure` generates the following output:

```
=============== Build Programs and Flags ===============================
(you can override these at build time; e.g.: 'make CC=cc')
        CC                     : cc
        CFLAGS                 : -g -O2 -fopenmp -std=c99
```

Is it lying to me?  or how does that "optimize for the local machine"?


----------



## SirDice (Oct 15, 2021)

Zirias said:


> or how does that "optimize for the local machine"?


Maybe through some `#ifdef` checks on flags in the code itself?


----------



## zirias@ (Oct 15, 2021)

SirDice said:


> Maybe through some `#ifdef` checks on flags in the code itself?


But the code can't modify compiler flags.

Anyways, found the culprit: configure.ac contains a LOT of weird magic to set `-march` and a few other optimization flags _if_ the compiler used is GCC, and guess what, the port has `USE_GCC=yes`.

Ok, funny, this whole magic doesn't seem to work here either :

```
cat: /proc/cpuinfo: No such file or directory
configure: Guessing the C compiler is gcc.
[...]
=============== Build Programs and Flags ===============================
(you can override these at build time; e.g.: 'make CC=cc')
    CC                     : gcc10
    CFLAGS                 : -O2 -pipe  -fPIC -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc10 -fno-strict-aliasing  -fopenmp -std=c99
```

Looks like pretty normal `CFLAGS` handling in ports. This leaves questions:

Does it even make sense to assume it would ever build "for the local machine"? /proc/cpuinfo is Linux stuff…
Does it really need GCC? Ok, it needs fortran and therefore depends on GCC anyways, so that's a bit pointless...


----------



## zirias@ (Oct 16, 2021)

I created PR 259200, if you have any additional info please comment there (and maybe test the patch I attached).


----------



## zirias@ (Oct 16, 2021)

Alain De Vos  forget fiddling with your poudriere.conf, instead just update your ports tree. My suggested patch was committed quickly


----------

