summaryrefslogtreecommitdiffstats
path: root/content/posts/openbsd-compiling-rakudo-star
diff options
context:
space:
mode:
authorDante Catalfamo2020-07-25 02:58:12 -0400
committerDante Catalfamo2020-07-25 02:58:12 -0400
commitbf693366e400a04d4ad748440e02c60398d4a10c (patch)
tree7d9de15a2d13f1fb5fd11b6ddf5e8b31b04fc809 /content/posts/openbsd-compiling-rakudo-star
parent10109a0188606cd14c92b5f07f1891b94166df5c (diff)
downloadblog-bf693366e400a04d4ad748440e02c60398d4a10c.tar.gz
blog-bf693366e400a04d4ad748440e02c60398d4a10c.tar.bz2
blog-bf693366e400a04d4ad748440e02c60398d4a10c.zip
Compiling rakudo star on OpenBSD post added
Diffstat (limited to 'content/posts/openbsd-compiling-rakudo-star')
-rw-r--r--content/posts/openbsd-compiling-rakudo-star/index.org163
1 files changed, 163 insertions, 0 deletions
diff --git a/content/posts/openbsd-compiling-rakudo-star/index.org b/content/posts/openbsd-compiling-rakudo-star/index.org
new file mode 100644
index 0000000..aaab55d
--- /dev/null
+++ b/content/posts/openbsd-compiling-rakudo-star/index.org
@@ -0,0 +1,163 @@
+#+TITLE: Compiling Rakudo Star on OpenBSD
+#+DATE: 2020-07-25T02:54:34-04:00
+#+DRAFT: true
+#+DESCRIPTION:
+#+TAGS[]: openbsd raku
+#+KEYWORDS[]: openbsd raku
+#+SLUG:
+#+SUMMARY:
+
+I really enjoy using [[https://raku.org/][raku]] to write small scripts for system
+maintenance and text parsing. Its regex and grammar engine are next
+level. The problem with using it on OpenBSD is that the packaged
+version is a couple years out of date. The version in ports is from
+2018, which contains various bugs surrounding nativecall on OpenBSD,
+not to mention a lot of performance gains and bug fixes.
+
+Instead of just compiling everything from source and installing them
+as I did on my last system, I installed it using the [[https://github.com/rakudo/star][rakudo star]]
+distribution and its =rstar= command. Rakudo Star is raku plus some
+community modules and the =zef= package manager. It also comes with
+the =rstar= command, which helps you in the build process.
+
+I ran into a couple issues compiling it on OpenBSD while using the
+=rstar= command, so I figured I'd turn it into a post.
+
+First, it requires =bash= to be present on the host system as a build
+dependency for the =rstar= install script, which isn't on OpenBSD by
+default. Not to mention that many OpenBSD users do not use bash by
+choice. Not that this is an issue with =rstar=, but more of a personal
+grievance.
+
+After installing =bash=, I came across another problem. Upon running
+=rstar fetch=, which fetches all of the materials required to compile
+and assemble the star distribution, it failed to pull in all 3 major
+components. All of the modules are pulled in via =git=, which worked
+well. The main rakudo components, =MoarVM=, =nqp=, and =rakudo=, are
+pulled in as gzipped tarballs. Each of them failed to download
+correctly, which I suspect is down to an issue with the bash
+scripts. Tar also throws a warning about one of its arguments,
+although it never gets used as the files it's supposed to be operating
+on never appear.
+
+#+BEGIN_SRC
+[2020-07-25T05:25:33] [NOTIC] Downloading https://www.moarvm.org/releases/MoarVM-2020.02.1.tar.gz to /home/dante/star/tmp/tmp.IMPt8mIFoC
+tar: WARNING! These patterns were not matched:
+--strip-components=1
+[2020-07-25T05:25:34] [CRIT] Failed to download /home/dante/star/src/moarvm-2020.02.1
+[2020-07-25T05:25:34] [NOTIC] Downloading https://github.com/perl6/nqp/releases/download/2020.02.1/nqp-2020.02.1.tar.gz to /home/dante/star/tmp/tmp.zDxiGW2Sxq
+tar: WARNING! These patterns were not matched:
+--strip-components=1
+[2020-07-25T05:25:40] [CRIT] Failed to download /home/dante/star/src/nqp-2020.02.1
+[2020-07-25T05:25:40] [NOTIC] Downloading https://github.com/rakudo/rakudo/releases/download/2020.02.1/rakudo-2020.02.1.tar.gz to /home/dante/star/tmp/tmp.W1mRYHVj1C
+tar: WARNING! These patterns were not matched:
+--strip-components=1
+[2020-07-25T05:25:46] [CRIT] Failed to download /home/dante/star/src/rakudo-2020.02.1
+#+END_SRC
+
+To work around this I downloaded the required files manually using
+OpenBSD's =ftp= command and extracted them into the =src= directory
+that had been created by the script. Another small caveat is that
+MoarVM automatically extracts into a directory called
+=MoarVM-2020.02.1=, which needs to be completely lower-cased for the
+=rstar= to work.
+
+#+BEGIN_SRC shell
+cd src
+ftp https://www.moarvm.org/releases/MoarVM-2020.02.1.tar.gz
+ftp https://github.com/perl6/nqp/releases/download/2020.02.1/nqp-2020.02.1.tar.gz
+ftp https://github.com/rakudo/rakudo/releases/download/2020.02.1/rakudo-2020.02.1.tar.gz
+tar -xzf MoarVM-2020.02.1.tar.gz
+tar -xzf nqp-2020.02.1.tar.gz
+tar -xzf rakudo-2020.02.1.tar.gz
+mv MoarVM-2020.02.1 moarvm-2020.02.1
+rm *.tar.gz
+cd ..
+#+END_SRC
+
+Running =rstar install= then began compiling things. =rstar install=
+will install rakudo star into the build directory by default, but you
+can change that with =-p= to specify a prefix location. MoarVM and nqp
+both compiled and installed fine, but when it came to compiling
+Rakudo, with a memory allocation error message.
+
+#+BEGIN_SRC
++++ Generating gen/moar/Compiler.nqp
++++ Generating gen/moar/Optimizer.nqp
++++ Compiling blib/Perl6/Optimizer.moarvm
++++ Compiling blib/Perl6/Compiler.moarvm
++++ Compiling rakudo.moarvm
++++ Generating gen/moar/BOOTSTRAP/v6c.nqp
++++ Generating gen/moar/Metamodel.nqp
++++ Compiling blib/Perl6/Metamodel.moarvm
++++ Compiling blib/Perl6/BOOTSTRAP/v6c.moarvm
++++ Compiling blib/CORE.c.setting.moarvm
+The following step can take a long time, please be patient.
+Stage start : 0.000
+MoarVM panic: Memory allocation failed; could not allocate 84800 bytes
+*** Error 1 in /home/dante/star/tmp/tmp.gqTyPvsgV1 (Makefile:800 'blib/CORE.c.setting.moarvm': @'/home/dante/star/bin/moar' --libpath='/home...)
+[2020-07-25T05:38:43] [ALERT] Build failed!
+#+END_SRC
+
+I tried then manually building rakudo to see if I could figure out
+what the problem was.
+
+#+BEGIN_SRC shell
+cd src/rakudo-2020.02.1
+./Configure.pl --prefix /home/dante/star/
+make install
+#+END_SRC
+
+While rakudo was compiling, I monitored memory usage in a separate
+=tmux= pane, and noticed that the =moarvm= process was using around
+760 MB of RAM before it crashed. 768 MB is the maximum amount of ram a
+process can use in OpenBSD under a user with the default login class,
+as specified in =/etc/login.conf=.
+
+To remedy the problem, I changed my user's class to =staff=, which
+grants it a much higher =datasize= limit, among a couple other
+things. If you're interested about how this works, you can check out
+[[https://man.openbsd.org/login.conf.5][=login.conf(5)=]] and the =/etc/login.conf= file on your system.
+
+#+BEGIN_SRC shell
+doas usermod -L staff dante
+#+END_SRC
+
+After that, I restarted the build and install using the =rstar=
+command as before, just to make sure it sets everything up how it
+wants.
+
+After a around half an hour of text scrolling, I was finally presented
+the following message.
+
+#+BEGIN_SRC
+[2020-07-25T06:34:06] [INFO] Rakudo Star has been installed into /home/dante/star!
+[2020-07-25T06:34:06] [INFO] The installation took 0h 25m 02s.
+[2020-07-25T06:34:06] [INFO]
+[2020-07-25T06:34:06] [INFO] You may need to add the following paths to your $PATH:
+[2020-07-25T06:34:06] [INFO] /home/dante/star/bin
+[2020-07-25T06:34:06] [INFO] /home/dante/star/share/perl6/site/bin
+[2020-07-25T06:34:06] [INFO] /home/dante/star/share/perl6/vendor/bin
+[2020-07-25T06:34:06] [INFO] /home/dante/star/share/perl6/core/bin
+#+END_SRC
+
+Alright!
+
+I added to my path by editing my =~/.profile= and added the following
+line.
+
+#+BEGIN_SRC diff
+ --- .profile.old Sat Jul 25 06:42:48 2020 +++ .profile Sat Jul 25
+ 06:42:31 2020 @@ -3,4 +3,5 @@ # sh/ksh initialization
+
+ PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games
+ +PATH=$PATH:/home/dante/star/bin:/home/dante/star/share/perl6/site/bin:/home/dante/star/share/perl6/vendor/bin:/home/dante/star/share/perl6/core/bin
+ export PATH HOME TERM
+#+END_SRC
+
+I chose to keep it in the =star= directory instead of installing it to
+=/usr/local= in case the version of rakudo in ports gets updated some
+time.
+
+I now have a proper up to date version of raku running on my OpenBSD
+machine! Happy hacking!