# Reflection on brittleness or fragility of complex software.



## Alain De Vos (Nov 2, 2021)

Freshports says for the port "math/sage" at least gcc10 and perl5.32
Offcourse I tried gcc11 and perl5.34 and the build failed.
Did the build failed because i changed the gcc version or the perl version ?
Now comes the interesting part.
-There is a range of versions which are too low and known not to work
-There is a range of higher versions which might work
-There is a middle range of versions known to work.
-There is a range of versions which might work
-There is a range of versions too high and known not to work.
And this is for every dependency.
But Freshports only mentions one number for the version of a dependency ?
Feel free to elaborate.

[SirDice would probably say you shouldn't touch the defaults. But it's only in touching the defaults that you get insight in what is happening]


----------



## grahamperrin@ (Nov 3, 2021)

Alain De Vos said:


> build failed.



Can you share a log? Thanks


----------



## astyle (Nov 3, 2021)

This is why I try to avoid messing with /etc/make.conf. The defaults you set there may work for a bit - until you run into a port where those defaults don't work.


----------



## Alain De Vos (Nov 3, 2021)

After one hour a very weird error.

```
[00:56:48] [gfortran-9.2.0] /wrkdirs/usr/ports/math/sage/work/build/usr/local/var/tmp/sage/build/gfortran-9.2.0/gcc-build/./gcc/xgcc -B/wrkdirs/usr/ports/math/sage/work/build/usr/local/var/tmp/sage/build/gfortran-9.2.0/gcc-build/./gcc/ -B/wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/bin/ -B/wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/lib/ -isystem /wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/include -isystem /wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/sys-include    -O2  -g -O2 -pipe -march=ivybridge  -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fpic -pthread -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -Wl,--version-script=libgcc.map -o ./libgcc_s.so.1.tmp -g -O2 -pipe -march=ivybridge -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulhc3_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divhc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o cpuinfo_s.o sfp-exceptions_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc && rm -f ./libgcc_s.so && if [ -f ./libgcc_s.so.1 ]; then mv -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup; else true; fi && mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1 && ln -s libgcc_s.so.1 ./libgcc_s.so
[00:56:48] [gfortran-9.2.0] ld: error: unable to find library -lc
[00:56:48] [gfortran-9.2.0] collect2: error: ld returned 1 exit status
[00:56:48] [gfortran-9.2.0] gmake[8]: *** [Makefile:992: libgcc_s.so] Error 1
[00:56:48] [gfortran-9.2.0] gmake[7]: *** [Makefile:11618: all-target-libgcc] Error 2
[00:56:48] [gfortran-9.2.0] gmake[6]: *** [Makefile:936: all] Error 2
```
Currently recompiling 1500 ports. In two days we'll know if it reproduces or was a glitch.


----------



## astyle (Nov 3, 2021)

Alain De Vos : All this compiling constantly is gonna fry your i7 sooner or later. If it doesn't - that's a feather in Intel's hat.


----------



## eternal_noob (Nov 3, 2021)

I'd like to use ports too but i'll stick to packages because i love my SD card.


----------



## zirias@ (Nov 3, 2021)

The snippet you share is a bootstrapping build of gcc itself, looks like it was bundled upstream to have a fortran compiler? I don't think a port should ever do this (but instead depend on a port providing gfortran)…


----------



## astyle (Nov 3, 2021)

Seems like /etc/make.conf is enabling some options that I would be careful to NOT enable. This does make my case against /etc/make.conf - it snuck in the gfortran option into the GCC port. I build my GCC _without_ Fortran. What if I wanted to enable Fortran in some ports but not others? I don't want to wait for days to finish compiling only to discover that I messed up something in /etc/make.conf. 

eternal_noob : Have you considered a Poudriere build server? you can use that to pre-make packages for your SD card.


----------



## zirias@ (Nov 3, 2021)

astyle look closer, this build is happening inside the workdir of the math/sage port, so this really smells of "bundled gcc" ... or something even more strange is completely broken.


----------



## eternal_noob (Nov 3, 2021)

astyle said:


> Have you considered a Poudriere build server?


I would use one if i could afford one.


----------



## astyle (Nov 3, 2021)

Zirias : yeah, on a closer look, bundling a compiler is strange. math/sage does in fact depend on gfortran10, which is only provided by devel/gcc10, but the makefile knobs (as seen on freshports) don't specify it as an option you can turn on and off. Looking at the port's Makefile from FreeBSD's Git repo, the string "fortran" was found only _once_ with `Ctrl-F`. Whoever was porting math/sage apparently didn't handle the Fortran dependency very well. I agree, bundling GCC is not the greatest idea.


----------



## hardworkingnewbie (Nov 3, 2021)

astyle: Sage has quite the elaborate build from source documentation here: https://doc.sagemath.org/html/en/installation/source.html#additional-software

It clearly states there that it depends on GCC and its Fortran. Furthermore when detecting LLVM, it automatically will build the bundled GCC/Fortran. LLVM support is on its way, but still inofficial and unfinished it seems. 

This bundling comes directly from upstream. Changing how it's done is probably a lot of work, if doable.


----------



## astyle (Nov 3, 2021)

hardworkingnewbie said:


> astyle: Sage has quite the elaborate build from source documentation here: https://doc.sagemath.org/html/en/installation/source.html#additional-software
> 
> It clearly states there that it depends on GCC and its Fortran. Furthermore when detecting LLVM, it automatically will build the bundled GCC/Fortran. LLVM support is on its way, but still inofficial and unfinished it seems.
> 
> This bundling comes directly from upstream. Changing how it's done is probably a lot of work, if doable.


Yeah, I think the port should _probably_ be marked as 'broken' until the makefile issues are addressed.


----------



## mer (Nov 3, 2021)

One often runs into this when building things using autoconf/automake.  
At any point in time, when you write a make-ish file that has dependencies, you can only "depend" on the versions of other stuff at that point in time.  
Yes, I know, that sentence could take 3rd place in an "Obfuscated English Sentence" contest.
If at time A there is only gcc10.3.4 and you write "I depend on gcc=10.3.4"  you are ok if gcc10.3.1 is installed, but mistakenly fail at gcc10.4.1.
That is an error on whomever wrote the dependency, they made a mistake.

If they wrote it as "gcc>=10.3.4" then 10.4.1, 11.5.7 should all be accepted.

So "blah blah blah" a bunch of words that basically say "I agree with astyle in post #13"  

Sorry it's not as epic as Trihexagonal, but it's only Wednesday.


----------



## Alain De Vos (Nov 3, 2021)

So , in make.conf ?

.if ${.CURDIR:M*/math/sage}
WITH-SYSTEM-GCC=force
.endif


----------



## Alain De Vos (Nov 5, 2021)

astyle said:


> Alain De Vos : All this compiling constantly is gonna fry your i7 sooner or later. If it doesn't - that's a feather in Intel's hat.


My CPU is heating my living room on this rainy day. I'm a bit more concerned about my SSD.
I had to reduce the frequency of updates in /usr/ports , because updates come in faster then i'm able to compile.
Sagebuild still fails for me but i try out a few
.if ${.CURDIR:M*/math/sage}
lines
in make.conf

Test1:
WITH-SYSTEM-GCC=force did not worked for me

Test2:
Downgrading perl from v 5.34 to perl5.32 (as described by freshports)
Rebuilding 900 packages.
... Will take a few days  ...


----------



## Alain De Vos (Dec 27, 2021)

Currently same error during fortran compilation :

```
[00:24:23] [gfortran-9.2.0] /wrkdirs/usr/ports/math/sage/work/build/usr/local/var/tmp/sage/build/gfortran-9.2.0/gcc-build/./gcc/xgcc -B/wrkdirs/usr/ports/math/sage/work/build/usr/local/var/tmp/sage/build/gfortran-9.2.0/gcc-build/./gcc/ -B/wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/bin/ -B/wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/lib/ -isystem /wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/include -isystem /wrkdirs/usr/ports/math/sage/work/build/usr/local/x86_64-unknown-freebsd13.0/sys-include    -O2  -g -O2 -pipe  -march=ivybridge  -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fpic -pthread -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -Wl,--version-script=libgcc.map -o ./libgcc_s.so.1.tmp -g -O2 -pipe -march=ivybridge -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulhc3_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divhc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o cpuinfo_s.o sfp-exceptions_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc && rm -f ./libgcc_s.so && if [ -f ./libgcc_s.so.1 ]; then mv -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup; else true; fi && mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1 && ln -s libgcc_s.so.1 ./libgcc_s.so
[00:24:23] [gfortran-9.2.0] ld: error: unable to find library -lc
[00:24:23] [gfortran-9.2.0] collect2: error: ld returned 1 exit status
[00:24:23] [gfortran-9.2.0] gmake[8]: *** [Makefile:992: libgcc_s.so] Error 1
[00:24:23] [gfortran-9.2.0] gmake[7]: *** [Makefile:11618: all-target-libgcc] Error 2
[00:24:23] [gfortran-9.2.0] gmake[6]: *** [Makefile:936: all] Error 2
[00:24:23] [gfortran-9.2.0] ********************************************************************************
[00:24:23] [gfortran-9.2.0] Error building gfortran-9.2.0
[00:24:23] [gfortran-9.2.0] ********************************************************************************
[00:24:23] [gfortran-9.2.0]
[00:24:23] [gfortran-9.2.0] real    7m0.749s
[00:24:23] [gfortran-9.2.0] user    2m42.824s
[00:24:23] [gfortran-9.2.0] sys    1m45.649s
```


----------



## grahamperrin@ (Dec 28, 2021)

Alain De Vos said:


> ld: error: unable to find library -lc





Alain De Vos said:


> ld: error: unable to find library -lc



Maybe GCC bug 97304 – Boostrap failure on freebsd: ld: error: unable to find library -lc?


----------

