Building Musltronic GNAT: Part 1

Recently, I built a working Cuntoo workstation for testing. After this, I wanted to continue building Republican tooling on this workstation. Now that we have a proper keccak-vtron, which requires Ada to build, I wanted to get ave1's musltronic GNAT built statically, so I could try it out on my Cuntoo box. I began with ave1's version 2018-05-15, and this post discusses this version explicitly. In another post, I'll write up my findings when building his latest, 2018-09-24.

There has been much forum discussion surrounding the musltronic GNAT. Likewise, there are a whole number of blog posts by various TMSR Lords, including, ave1, and bvt. However, for this first attempt at building, I used these notes as my main source of help.
* asciilifeform's very useful comments in the forum - steps begin here.
* diana_coman's GNAT Compilation Notes.

To begin with, I downloaded the tarball and notes included at ave1's blog post onto my x86_64 (quad core) gentoo machine, which already had a working GNAT 2016 (from AdaCore) deployed into the environment. From there, I followed the steps that asciilifeform gave in the forum and was successful.

Here's a log of what I actually did:

mod6@gentoo-lappy ~/AVE1_GNAT $ curl -sL "http://ave1.org/tarpit/ada-musl-cross-2018-05-15.tgz" -O
mod6@gentoo-lappy ~/AVE1_GNAT $ curl -sL "http://ave1.org/tarpit/ada-musl-cross-2018-05-15.txt" -O
mod6@gentoo-lappy ~/AVE1_GNAT $ gpg --verify ada-musl-cross-2018-05-15.txt
gpg: Signature made Tue May 15 07:50:39 2018 CDT using RSA key ID 77BC59F9
gpg: Good signature from "ave--"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 57EE 94EA 6F20 49A4 7DAF  A856 8F4C E8F7 77BC 59F9
mod6@gentoo-lappy ~/AVE1_GNAT $ su
gentoo-lappy AVE1_GNAT # tar -xf ada-musl-cross-2018-05-15.tgz
gentoo-lappy AVE1_GNAT #
gentoo-lappy AVE1_GNAT # gnat --version
GNAT GPL 2016 (20160515-49)
Copyright (C) 1996-2016, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gentoo-lappy AVE1_GNAT #
gentoo-lappy AVE1_GNAT # cd ada-musl-cross-2018-05-15
gentoo-lappy ada-musl-cross-2018-05-15 # ls
README.md  build-ada.sh  build-native.sh  build.sh  clean.sh  config-static.sh  config.sh  defs.sh  download-adacore-2015.sh  download-adacore-2016.sh  extra  extraconfig.sh  hashes  patches  tarballs

#####
# The next part was specifically from asciilifeform's notes:
# http://btcbase.org/log/2018-05-15#1813719
# http://btcbase.org/log/2018-05-15#1813726
#####

gentoo-lappy ada-musl-cross-2018-05-15 # mkdir bin 

gentoo-lappy ada-musl-cross-2018-05-15 # vim /root/.bash_profile 

######
# Adding this PATH definition into my /root/.bashrc file:  PATH="/home/mod6/AVE1_GNAT/ada-musl-cross-2018-05-15/bin/x86_64-linux-musl/bin/:$PATH"; export PATH
######

gentoo-lappy ada-musl-cross-2018-05-15 # source /root/.bash_profile
gentoo-lappy ada-musl-cross-2018-05-15 # echo $PATH
/home/mod6/AVE1_GNAT/ada-musl-cross-2018-05-15/bin/x86_64-linux-musl/bin/:/usr/gnat/bin:/sbin:/bin:/usr/sbin:/usr/bin
gentoo-lappy ada-musl-cross-2018-05-15 # export MAKEOPTS=-j4
gentoo-lappy ada-musl-cross-2018-05-15 # echo $MAKEOPTS
-j4
gentoo-lappy ada-musl-cross-2018-05-15 # nohup ./build-ada.sh /home/mod6/AVE1_GNAT/ada-musl-cross-2018-05-15/bin & 

...

Some hours later...

...

gentoo-lappy ada-musl-cross-2018-05-15 # ls -al bin/
total 940944
drwxr-xr-x  7 root root       4096 Apr 13 23:42 .
drwx------ 12  902 users      4096 Apr 13 18:18 ..
drwxr-xr-x  8 root root       4096 Apr 13 21:20 aarch64-linux-musl
drwxr-xr-x  9 root root       4096 Apr 13 23:44 aarch64-linux-musl-native
drwxr-xr-x  8 root root       4096 Apr 13 19:04 bootstrap
-rw-r--r--  1 root root  316206446 Apr 13 23:44 muslaarch64-linux-musl-nativeada.tar.gz
-rw-r--r--  1 root root  146969625 Apr 13 21:20 muslaarch64-linux-muslada.tar.gz
-rw-r--r--  1 root root  341775984 Apr 13 22:32 muslx86_64-linux-musl-nativeada.tar.gz
-rw-r--r--  1 root root  158535800 Apr 13 20:15 muslx86_64-linux-muslada.tar.gz
drwxr-xr-x  8 root root       4096 Apr 13 20:15 x86_64-linux-musl
drwxr-xr-x  8 root root       4096 Apr 13 22:32 x86_64-linux-musl-native
gentoo-lappy ada-musl-cross-2018-05-15 # sha512sum bin/*.tar.gz
2de85d5b3b574eb8126007928b0a6a5e7d0a26a65a53b49699e5f61ad857acbf0d3666998775c5dcae513d0e58ec054f3eceda1b16dde053a52e41f55be3d02d  bin/muslaarch64-linux-musl-nativeada.tar.gz
c772632df48d6eae4c097203cb2d1605f7dc4118072df1a8d7d4aefec426479de23dbec365d6380f661d43a497bdbf2008afde503d25e9be943d212cdd67b24a  bin/muslaarch64-linux-muslada.tar.gz
2af6ba6aded0dbf5ee46cacd7727506889668c4d211a75b649d3d0439e953cb4602c61d88a4a15cb87c56e5241930b7d9e6f295d33ef2dc51eb95f403958b272  bin/muslx86_64-linux-musl-nativeada.tar.gz
2d32aa6f7bd6323813b3f2f119bab06c16dd9d39b63412b74b734f92a33e03460bb4261719a8f5b8732941f41028466f9d3ee10a4210b39e43bca5a332465372  bin/muslx86_64-linux-muslada.tar.gz

I then copied up these two tarballs to my cuntoo-test1 machine:
muslx86_64-linux-musl-nativeada.tar.gz
muslx86_64-linux-muslada.tar.gz

With the tarballs copied up, I simply extracted 'muslx86_64-linux-musl-nativeada.tar.gz' in /opt

Then modified my PATH in /home/mod6/.bashrc :
cuntoo-test1 /home/mod6 # tail -1 /home/mod6/.bashrc
export PATH="$PATH:/opt/x86_64-linux-musl-native/bin"

With a new mod6 shell open...

mod6@cuntoo-test1 ~ $ echo $PATH
/usr/x86_64-gentoo-linux-musl/gcc-bin/4.9.4:/usr/local/bin:/usr/bin:/bin:/opt/bin:/opt/x86_64-linux-musl-native/bin
mod6@cuntoo-test1 ~ $ gcc --version
gcc (Gentoo 4.9.4-r100 p1.0, pie-0.6.4) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mod6@cuntoo-test1 ~ $ gnat --version
GNAT GPL 2016 (20160515)
Copyright (C) 1996-2016, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mod6@cuntoo-test1 ~ $ curl -sL "http://ossasepia.com/vpatches/starter_v.zip" -O
mod6@cuntoo-test1 ~ $ curl -sL "http://ossasepia.com/vpatches/starter_v.zip.diana_coman.sig" -O
mod6@cuntoo-test1 ~ $ gpg --import diana_coman.asc
gpg: key 390F999E: public key "Diana Coman " imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
mod6@cuntoo-test1 ~ $ gpg --verify starter_v.zip.diana_coman.sig starter_v.zip
gpg: Signature made Wed Nov 14 10:39:50 2018 UTC using RSA key ID 390F999E
gpg: Good signature from "Diana Coman "
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: E72D CCB7 3A5E 0669 4C5C  D781 D519 6EE6 390F 999E

mod6@cuntoo-test1 ~ $ unzip starter_v.zip
Archive:  starter_v.zip
   creating: starter_v/
  inflating: starter_v/clean.sh
  inflating: starter_v/build.sh
   creating: starter_v/vtools/
  inflating: starter_v/vtools/vdiff.gpr
  inflating: starter_v/vtools/vpatch.gpr
  inflating: starter_v/vtools/Makefile
  inflating: starter_v/vtools/ksum.gpr
  inflating: starter_v/vtools/manifest
   creating: starter_v/v/
  inflating: starter_v/v/v.pl
  inflating: starter_v/v/v_quick_start.txt
  inflating: starter_v/v/manifest
   creating: starter_v/vtools/src/
  inflating: starter_v/vtools/src/bits.ads
  inflating: starter_v/vtools/src/keccak_c.adb
  inflating: starter_v/vtools/src/vpatch.adb
  inflating: starter_v/vtools/src/dir.c
  inflating: starter_v/vtools/src/util.c
  inflating: starter_v/vtools/src/keccak.h
  inflating: starter_v/vtools/src/diff.h
  inflating: starter_v/vtools/src/bits.adb
  inflating: starter_v/vtools/src/character_io.ads
  inflating: starter_v/vtools/src/context.c
  inflating: starter_v/vtools/src/smg_keccak.adb
  inflating: starter_v/vtools/src/character_io.adb
  inflating: starter_v/vtools/src/ksum.adb
  inflating: starter_v/vtools/src/analyze.c
  inflating: starter_v/vtools/src/keccak_c.ads
  inflating: starter_v/vtools/src/io.c
  inflating: starter_v/vtools/src/diff.c
  inflating: starter_v/vtools/src/smg_keccak.ads
  inflating: starter_v/vtools/src/system.h
   creating: starter_v/vtools/lib/
  inflating: starter_v/vtools/lib/hash.c
  inflating: starter_v/vtools/lib/cmpbuf.c
  inflating: starter_v/vtools/lib/progname.c
  inflating: starter_v/vtools/lib/filetype.h
  inflating: starter_v/vtools/lib/xalloc.c
  inflating: starter_v/vtools/lib/dirname.h
  inflating: starter_v/vtools/lib/filetype.c
  inflating: starter_v/vtools/lib/progname.h
  inflating: starter_v/vtools/lib/cmpbuf.h
  inflating: starter_v/vtools/lib/error.h
  inflating: starter_v/vtools/lib/error.c
  inflating: starter_v/vtools/lib/filenamecat.c
  inflating: starter_v/vtools/lib/dirname.c
  inflating: starter_v/vtools/lib/diffseq.h
  inflating: starter_v/vtools/lib/hash.h
  inflating: starter_v/vtools/lib/filenamecat.h
  inflating: starter_v/vtools/lib/xalloc.h
   creating: starter_v/vtools/obj/
 extracting: starter_v/vtools/obj/readme
mod6@cuntoo-test1 ~ $ cd starter_v
mod6@cuntoo-test1 ~/starter_v $ chmod +x build.sh
mod6@cuntoo-test1 ~/starter_v $ ./build.sh

Compile
   [C]            diff.c
   [C]            filetype.c
   [C]            error.c
   [C]            cmpbuf.c
   [C]            progname.c
   [C]            dirname.c
   [C]            hash.c
   [C]            filenamecat.c
   [C]            xalloc.c
   [C]            dir.c
   [C]            io.c
   [C]            util.c
   [C]            context.c
   [C]            analyze.c
   [Ada]          bits.adb
   [Ada]          ksum.adb
   [Ada]          character_io.adb
   [Ada]          keccak_c.adb
   [Ada]          smg_keccak.adb
Bind
   [gprbind]      diff.bexch
   [Ada]          bits.ali -n
Link
   [archive]      libvdiff.a
   [index]        libvdiff.a
   [link]         diff.c
Compile
   [Ada]          vpatch.adb
Bind
   [gprbind]      vpatch.bexch
   [Ada]          vpatch.ali
Link
   [link]         vpatch.adb
Bind
   [gprbind]      ksum.bexch
   [Ada]          ksum.ali
Link
   [link]         ksum.adb
Done.

mod6@cuntoo-test1 ~/starter_v $ ./ksum vk.pl
115b06a799eae048ffbd18642234dc234e9bf879ebdedf0ed9b4be69a410187537b618d2b4b581954b89d1f63ef0925f9ff1ae26f0882c28f05d3a1fcdb1a732  vk.pl
mod6@cuntoo-test1 ~/starter_v $ ./ksum vdiff
53751a217b0257f716955eff2177aea68815aa1f0076e1b5a7137e843a30a85741dc3b58ef63cdfc4fe5abdbe558f2f614f601da1797bc50032a43594a9b221d  vdiff
mod6@cuntoo-test1 ~/starter_v $ ./ksum vpatch
82b8851c2bbe6bf5e10558152d3bdbde448b6185af4cb2d41afd3339053e9b8b61539a28e55c8aa96fe44d3cdfec832fe5418b2977dab47b67222ee47b8cae67  vpatch
mod6@cuntoo-test1 ~/starter_v $ cd ..
mod6@cuntoo-test1 ~ $ mkdir ffa
mod6@cuntoo-test1 ~ $ cd ffa
mod6@cuntoo-test1 ~/ffa $ mv ../ffa-keccak.tar.gz .
mod6@cuntoo-test1 ~/ffa $ mkdir .wot
mod6@cuntoo-test1 ~/ffa $ mkdir .seals
mod6@cuntoo-test1 ~/ffa $ mkdir patches
mod6@cuntoo-test1 ~/ffa $ tar -xf ffa-keccak.tar.gz
mod6@cuntoo-test1 ~/ffa $ mv keccak/*.sig .seals/
mod6@cuntoo-test1 ~/ffa $ mv keccak/*.vpatch patches
mod6@cuntoo-test1 ~/ffa $ rm -rf keccak/
mod6@cuntoo-test1 ~/ffa $ mv ../asciilifeform.asc .wot/
mod6@cuntoo-test1 ~/ffa $ echo $PATH
/usr/x86_64-gentoo-linux-musl/gcc-bin/4.9.4:/usr/local/bin:/usr/bin:/bin:/opt/bin:/opt/x86_64-linux-musl-native/bin
mod6@cuntoo-test1 ~/ffa $ su
cuntoo-test1 /home/mod6/ffa # cp ../starter_v/{ksum,vdiff,vpatch} /usr/local/bin
cuntoo-test1 /home/mod6/ffa # exit
mod6@cuntoo-test1 ~/ffa $ cp ../starter_v/vk.pl .
mod6@cuntoo-test1 ~/ffa $ ./vk.pl f
ffa_ch1_genesis.kv.vpatch (asciilifeform)
ffa_ch2_logicals.kv.vpatch (asciilifeform)
ffa_ch3_shifts.kv.vpatch (asciilifeform)
ffa_ch4_ffacalc.kv.vpatch (asciilifeform)
ffa_ch5_egypt.kv.vpatch (asciilifeform)
ffa_ch6_simplest_rsa.kv.vpatch (asciilifeform)
ffa_ch7_turbo_egyptians.kv.vpatch (asciilifeform)
ffa_ch8_randomism.kv.vpatch (asciilifeform)
ffa_ch9_exodus.kv.vpatch (asciilifeform)
ffa_ch10_karatsuba.kv.vpatch (asciilifeform)
ffa_ch11_tuning_and_api.kv.vpatch (asciilifeform)
ffa_ch12_karatsuba_redux.kv.vpatch (asciilifeform)
ffa_w_borrow_expr.kv.vpatch (asciilifeform)
ffa_ch13_measure_and_qshifts.kv.vpatch (asciilifeform)
ffa_ch14_barrett.kv.vpatch (asciilifeform)
ffa_ch15_gcd.kv.vpatch (asciilifeform)
ffa_ch16_miller_rabin.kv.vpatch (asciilifeform)
ffa_ch17_peh.kv.vpatch (asciilifeform)
ffa_ch18_subroutines.kv.vpatch (asciilifeform)
mod6@cuntoo-test1 ~/ffa $
mod6@cuntoo-test1 ~/ffa $ ./vk.pl p v ch1 ffa_ch1_genesis.kv.vpatch
ffa_ch1_genesis.kv.vpatch
  creating ffa/README
  creating ffa/ffademo/README
  creating ffa/ffademo/bin/README
  creating ffa/ffademo/demo_ch1.adb
  creating ffa/ffademo/demo_ch1.ads
  creating ffa/ffademo/ffa_demo.adb
  creating ffa/ffademo/ffa_demo.gpr
  creating ffa/ffademo/ffa_io.adb
  creating ffa/ffademo/ffa_io.ads
  creating ffa/ffademo/obj/README
  creating ffa/libffa/README
  creating ffa/libffa/ffa.gpr
  creating ffa/libffa/fz_arith.adb
  creating ffa/libffa/fz_arith.ads
  creating ffa/libffa/fz_type.ads
  creating ffa/libffa/iron.ads
  creating ffa/libffa/lib/README
  creating ffa/libffa/obj/README
  creating ffa/libffa/restrict.adc
  creating ffa/libffa/w_shifts.ads
  creating ffa/libffa/word_ops.adb
  creating ffa/libffa/word_ops.ads
  creating ffa/libffa/words.ads
mod6@cuntoo-test1 ~/ffa $ cd ch1
mod6@cuntoo-test1 ~/ffa/ch1 $ cd ffa
mod6@cuntoo-test1 ~/ffa/ch1/ffa $ cd ffademo/
mod6@cuntoo-test1 ~/ffa/ch1/ffa/ffademo $ ls
README  bin  demo_ch1.adb  demo_ch1.ads  ffa_demo.adb  ffa_demo.gpr  ffa_io.adb  ffa_io.ads  obj
mod6@cuntoo-test1 ~/ffa/ch1/ffa/ffademo $ gprbuild
using project file ffa_demo.gpr
Compile
   [Ada]          ffa_demo.adb
   [Ada]          iron.ads
   [Ada]          word_ops.adb
   [Ada]          w_shifts.ads
   [Ada]          fz_arith.adb
   [Ada]          words.ads
   [Ada]          fz_type.ads
   [Ada]          demo_ch1.adb
   [Ada]          ffa_io.adb
Build Libraries
   [gprlib]       FFA.lexch
   [archive]      libFFA.a
   [index]        libFFA.a
Bind
   [gprbind]      ffa_demo.bexch
   [Ada]          ffa_demo.ali
Link
   [link]         ffa_demo.adb
mod6@cuntoo-test1 ~/ffa/ch1/ffa/ffademo $ ./bin/ffa_demo
X         =
0000000000000000000000000000000000000000000000000000000000000000
Y         =
0000000000000000000000000000000000000000000000000000000000005555
X + Y     =
0000000000000000000000000000000000000000000000000000000000005555
C         =  0
X - Y     =
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAAAB
C         =  1
mod6@cuntoo-test1 ~/ffa/ch1/ffa/ffademo $

As you can see, worked great! Was able to build diana_coman's keccak-vtron, and asciilifeform's FFA (Chapter 1, genesis) without problems at all.

Thanks to all who worked through this adventure before me and left good notes to work from. Much appreciated.

One Response to “Building Musltronic GNAT: Part 1”

  1. [...] mod6's Blog « Building Musltronic GNAT: Part 1 [...]

Leave a Reply